# Help with DigitalOcean droplet CPU spiking

**URL:** <https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822>\
**Category:** Developer help\
**Created:** [June 2, 2020, 6:38am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822 "2020-06-02T06:38:55Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenningg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/chenningg/32/6461_2.png) [@chenningg](https://forum.ghost.org/u/chenningg)\
**Post date:** [June 2, 2020, 6:38am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/1 "2020-06-02T06:38:56Z")

</div>

I’m running Ghost version 3.14.0, self-hosted on a DigitalOcean droplet via Docker containers (ghost and mysql in separate containers). I’ve been experiencing sudden spikes in CPU usage that brings down the database, as shown in the graphs below:

 ![CPU problem](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/5/5339e336ed6717919bb7731e1192293bbe505496.png)

You can see how the CPU spikes suddenly to 100% even though it usually barely uses 1%. I’ve narrowed down the problem to be caused by the MySQL container, bringing down the db.

Here are the logs from the Docker container:

 ![mysql problem](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/d/dbc6d57287436cdb1ea90cc89a9bc8f97a1e4bf1.png)

It repeats this for quite a while before finally succeeding. It seems to be an out of memory error, but I don’t know why the droplet is using up so much memory. It has 1GB RAM, and from the statistics, it’s barely using 30-40% of that, yet the graphs show a consistent 90% RAM usage.

Attached are my free memory and top memory:  
 ![Free memory](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/4/492dc973aad1f5043463cd75cfec7d6371dc064c.png) ![Top memory](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/e/e109e35242d2f7ec58455c1d5157071a1ae9817e.png)

Not sure why the graphs show so much memory is used even though I’m only using at beast 40-50% memory. Should I add swap or some other thing although DigitalOcean doesn’t recommend adding swap?

Does anyone have any idea how to fix this issue? The server randomly crashes due to this (luckily, thanks to Docker, it restarts immediately). I can’t pinpoint the exact reason either - running top doesn’t show anything, and I can’t access the server through ssh during the flareup. Thank you!

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [June 3, 2020, 4:53pm UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/2 "2020-06-03T16:53:46Z")

</div>

Hey @chenningg 👋  
Have you added any caching in front of your Ghost installation? It’s one of the things we recommend doing:  
[https://ghost.org/docs/concepts/server-recommendations/#optimising-for-scale](https://ghost.org/docs/concepts/server-recommendations/#optimising-for-scale)

---

<div class="post-metadata">

**Author:** ![chenningg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/chenningg/32/6461_2.png) [@chenningg](https://forum.ghost.org/u/chenningg)\
**Post date:** [June 4, 2020, 6:48am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/3 "2020-06-04T06:48:09Z")

</div>

Hi David, I do have Cloudflare in front of my server that does serve ~70%+ cached documents (according to Cloudflare analytics). The memory issue seems to stem from MySQL, so I’m not sure if there’s any expensive database queries being done on a cron job but I’m not sure how to check that.

Either way, I’m going to set up swapping for the server so we’ll see if the downtime improves.

---

<div class="post-metadata">

**Author:** ![andrii](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/andrii/32/11786_2.png) [@andrii](https://forum.ghost.org/u/andrii)\
**Post date:** [June 23, 2021, 7:43am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/4 "2021-06-23T07:43:53Z")

</div>

@chenningg seems I have a similar issue… Were you able to solve it?

---

<div class="post-metadata">

**Author:** ![dietrich](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/dietrich/32/13780_2.png) [@dietrich](https://forum.ghost.org/u/dietrich)\
**Post date:** [June 23, 2021, 7:53am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/5 "2021-06-23T07:53:30Z")

</div>

I’m having the same issue! Weird… I’ve had 2 spikes in a span of 3 hrs and my site is currently down.

---

<div class="post-metadata">

**Author:** ![chenningg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/chenningg/32/6461_2.png) [@chenningg](https://forum.ghost.org/u/chenningg)\
**Post date:** [June 23, 2021, 9:07am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/6 "2021-06-23T09:07:03Z")

</div>

@andrii @dietrich Yes, I was able to solve it by setting up swap space in the droplet. It’s disabled by default: [How To Add Swap Space on Ubuntu 20.04 | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04)

Alternatively, provision a higher memory (RAM) instance.

---

<div class="post-metadata">

**Author:** ![andrii](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/andrii/32/11786_2.png) [@andrii](https://forum.ghost.org/u/andrii)\
**Post date:** [June 23, 2021, 9:12am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/7 "2021-06-23T09:12:18Z")

</div>

thanks @chenningg! doing that now. I’m also installing CloudFlare, will that help?

---

<div class="post-metadata">

**Author:** ![chenningg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/chenningg/32/6461_2.png) [@chenningg](https://forum.ghost.org/u/chenningg)\
**Post date:** [June 23, 2021, 9:31am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/8 "2021-06-23T09:31:29Z")

</div>

Cloudflare does help provide a layer of caching on your setup, so in theory that means less load on your server (and less reads and writes on your MySQL database). However, it does add a layer of complexity to deal with the certificates and all that. I do recommend setting it up though.

---

<div class="post-metadata">

**Author:** ![DonaldH](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/donaldh/32/13880_2.png) [@DonaldH](https://forum.ghost.org/u/DonaldH)\
**Post date:** [June 24, 2021, 6:00am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/9 "2021-06-24T06:00:41Z")

</div>

I’m curious why Digital Ocean have an article on how to add swap space in droplets when they say,

> placing swap on SSDs can cause issues with hardware degradation over time. Due to this, we do not recommend enabling swap on DigitalOcean or any other provider that uses SSD storage

I guess that whatever hardware degradation occurs must be quite minimal.

---

<div class="post-metadata">

**Author:** ![chenningg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/chenningg/32/6461_2.png) [@chenningg](https://forum.ghost.org/u/chenningg)\
**Post date:** [June 24, 2021, 6:33am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/10 "2021-06-24T06:33:44Z")

</div>

Swap is often needed so servers don’t run out of memory when processes spike in memory. The reason DigitalOcean (and other hardware providers) discourage enabling swap is because it does degrade SSDs, and because they own the SSDs, they would naturally discourage it so they can save cost on replacing their hardware. However, since anyone with an above moderate use case would generally enable swapping, they do have an article on it.

---

<div class="post-metadata">

**Author:** ![dietrich](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/dietrich/32/13780_2.png) [@dietrich](https://forum.ghost.org/u/dietrich)\
**Post date:** [June 24, 2021, 3:18pm UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/11 "2021-06-24T15:18:28Z")

</div>

@chenningg I haven’t got the chance to put the swap space. Has it solved the spiking on your end?

---

<div class="post-metadata">

**Author:** ![chenningg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/chenningg/32/6461_2.png) [@chenningg](https://forum.ghost.org/u/chenningg)\
**Post date:** [June 24, 2021, 4:08pm UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/12 "2021-06-24T16:08:43Z")

</div>

I’m no longer hosting a Ghost server, but yes, it did help last time.

---

<div class="post-metadata">

**Author:** ![bastien](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/bastien/32/40675_2.png) [@bastien](https://forum.ghost.org/u/bastien)\
**Post date:** [August 25, 2022, 8:01am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/13 "2022-08-25T08:01:37Z")

</div>

hi everyone, I also get some random CPU spikes, I don’t understand why. Frequentation of my blog is very low. What should I do? Following DO tutorial to add some swap space? Does this affect the maintenance of Ghost or the update process?

---

<div class="post-metadata">

**Author:** ![dmnk](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/dmnk/32/23521_2.png) [@dmnk](https://forum.ghost.org/u/dmnk)\
**Post date:** [March 13, 2023, 12:52pm UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/14 "2023-03-13T12:52:21Z")

</div>

Hello,

Has anyone sorted this out? My blog has literally got 3 users and it keeps maxing out a decent size droplet in DigitalOcean.

---

<div class="post-metadata">

**Author:** ![Darry\_Shan](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/darry_shan/32/23265_2.png) [@Darry\_Shan](https://forum.ghost.org/u/Darry_Shan)\
**Post date:** [March 17, 2023, 12:50am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/15 "2023-03-17T00:50:39Z")

</div>

I’m testing DO As well and I had just a couple visitors as the site is just 2 days up and it’s spikes. See image

 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/3X/e/6/e6eb6e3d21fb96204935a5b0b3c804092757afc7.jpeg)

---

<div class="post-metadata">

**Author:** ![filipesm](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@filipesm](https://forum.ghost.org/u/filipesm)\
**Post date:** [November 1, 2025, 12:33am UTC](https://forum.ghost.org/t/help-with-digitalocean-droplet-cpu-spiking/14822/16 "2025-11-01T00:33:36Z")

</div>

What are the sizes of the servers of people here? I had this problem with a 6$/month 1CPU/1GB VPS. Is that the case for everyone? Or does the server spike even with big servers?
