Sudden issues with 512MB Ubuntu 14.04 WordPress droplet

September 11, 2014 4.1k views

The droplet was created with WordPress on Ubuntu 14.04 image.

I've had a WordPress site (with probably zero traffic) running for a while now. Suddenly I noticed it reported a database connection error, fair enough. So I checked:

"service mysql status"

That returned stop/waiting, fair enough. Easy to get back running. It then crashed again eventually, and so forth.

I read up and noticed comments on creating a swap, which I then did exactly according to this guide.

"free -m" shows:

             total       used       free     shared    buffers     cached
Mem:           490        485          4         12          0         20
-/+ buffers/cache:        464         25
Swap:         4095        897       3198

The result of adding swap?
My droplet is sometimes super slow while accessing it via SSH, i.e. typing into it lags. Never had this before, so I assume it is related.
Also, the website doesn't respond any longer. Ever. Sometimes the browser gets past connecting, but never past waiting.

What went wrong? Which logs should I check?

Surely a WordPress without almost no traffic shouldn't have issues on even the smallest droplet. I've previously had a few sites running on the 512MB perfectly fine.

  • After doing nothing, it seems to work now...... ? confusion

  • Why would you want 4GB Swap with a 512MB RAM ??

    I think you should not keep more than 512MB of swap..

    Also in case of wordpress, make sure you are running some cache plug in to reduce the load on system..

  • Thanks for the input.

    I just followed the guide, is there a negative in having a too large swap in relation to RAM?
    I noted the size in the guide of course, just didn't seem relevant since my site is (and will be) tiny and the droplet has 20GB.

    Currently "df -h" returns 5.9GB used. I'll probably never hit even 10GB.

    PS. Apparently my site is entirely unresponsive again. What. is. going. on. :(

  • I am not a Linux expert, but what I read about, large swap is not good at max swap should be 2 times the RAM or at MAX not more than 2GB on VPS..

    Everyone seems to say swap of 512MB with 512MB VPS.. If your system needs more than 512MB swap, its better to increase RAM..

    swap is really slow compare to RAM and swap is used as like Page file of Windows where HDD space is used as alternative to RAM in case of system running really low in memory to prevent crash..

  • I'm definitely not a Linux expert, so cheerio for that information! Linux meganovice perhaps.

    Will now look into commands for resizing the swap. :D

  • Other sites with mysql? What is the memory footprint of mysql proccess?
    Swapping is very bad for mysql performance. http://www.percona.com/blog/2010/01/18/why-swapping-is-bad-for-mysql-performance/
    Have you tried mysqld optimizations ?

  • Yeah the others had MySQL as well.
    Haven't tried optizimations.

    It seems this droplet goes to poo over time. Yesterday I resized swap to 1GB, and the site was dandy. This morning it was unresponsive again.

    So I looked at the memory situation:

                 total       used       free     shared    buffers     cached
    Mem:           490        473         16         10          0         16
    -/+ buffers/cache:        456         33
    Swap:         1023        852        171

    I then stopped apache2/mysql, and restarted them:

                 total       used       free     shared    buffers     cached
    Mem:           490        271        218         24          7        134
    -/+ buffers/cache:        129        360
    Swap:         1023         11       1012

    Immediately the site responds, and is also fast.

  • I'll try the optimizations you linked. Thanks!

  • The second post describes your problem and the restart effects.

    "It’s especially troublesome since the memory is allocated lazily and the memory usage builds up slowly. In some point caches are no longer caches, but swapped to a disk – virtual memory usage grows beyond available RAM."

  • Well, the optimizations to mysql might have done it. Did the ones you linked, and site has been fine the whole day.

    If it's still working dandy tomorrow, it's probably fixed.

    I also added various caching/optimization to the WordPress site, but even before that the site didn't seem to degrade.


    PS. This comment + answer thing is confusing. Keep adding things as answers.

  • I would still point 512MB Swap is more than enough.. More swap may cause issues.. Don't ask me why, I am not the expert, I read and I saw people posting about problem with larger swap.. If you really need more than 512MB swap, in that case you should upgrade to higher plans..

    Use swap just as back up in emergency cases, but if you see, your system is regularly using swap, in that case its time to move to 1Gb RAM..

    Secondly make sure swap priority is 60, not more than that..

  • Yeah, might make it 512M.

    Do you mean swappiness, or what by priority? The "sudo swapon -s" returns "-1".
    Swappiness I did according to the guide I found about Ubuntu swap here on DO.

  • https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

    Read more about that in Tweak your Swap Settings section..

    by Justin Ellingwood
    Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
  • Yeah that's the ones I did already. :)

  • Hope everything runs fine now !!