Published on

The Importance of a Properly Sized Swap

Authors

I use Ubuntu as my OS at work. The reason for this is that it is far easier to develop in Linux and especially Ubuntu due to:

  1. Immediate access to a good terminal with useful command line tools preloaded like: grep, less, vim, tail, awk, ssh and the other standard command line tools
  2. These tools make my job as a developer significantly easier
  3. Ubuntu also has container/Docker support from the outset without having to upgrade your kernel. This makes developing microservices easier without having to resort to using docker-machine
  4. There is a pretty large community around Ubuntu making it far easier to debug any issues you may encounter
  5. I can set it up just the way I like it

One of the things you encounter when installing Ubuntu is what swap size to use.

Today the importance of this decision became crystal clear. I have a menu bar plugin called indicator multiload which I use to keep track of resource usage while deving to see if anything has gone awry. I noticed while running our base microservice stack plus a few additional apps which are very RAM intensive that my RAM usage was maxing out. Before I had a chance to close anything basically everything except the mouse froze and I could not drop down to a virtual terminal using ctrl+alt+f1/2/3/4/5/6 so I had to force shutdown the machine and start from scratch.

The machine I have is dev spec with 16GB of RAM and an SSD. I checked the swap size I had configured and it was set to 2GB (the default one believe) which felt far too low. I asked a colleague what his swap was set to and discovered that he set it to at least the same size as his RAM to ensure that he can hibernate his system without issue. Additionally he routinely has much more running than I do without issues and has a similar speced machine.

Clearly I will have to investigate enlarging my swap size to avoid having additional crashes.