I noticed yesterday that my DigitalOcean monthly spend was a little more than I was expecting, turns out I have launched the wrong instance size when I last rebuilt my machine, so to save myself a few dollars a month I migrated the instance to a fresh server with a lower spec.
By default DigitalOcean servers do not come with swap enabled, because of this you run the risk of oomkiller killing processes to try and keep the server accessible. Luckily as all DigitalOcean servers are SSD backed and come with a decent amount of disk space so enabling swap isn’t an issue;
as you can see the server now has a 1GB of RAM and 4GB of swap;
There are also a few other settings you can tune to help with performance;
These two options do the following;
- swappiness — this control is used to define how aggressively the kernel swaps out anonymous memory relative to pagecache and other caches. Increasing the value increases the amount of swapping.
- vfs_cache_pressure — this variable controls the tendency of the kernel to reclaim the memory which is used for caching of VFS caches, versus pagecache and swap. Increasing this value increases the rate at which VFS caches are reclaimed.
This will hopefully save me a little money and make sure that things like MySQL don’t randomly get killed :)