# How much swap space is considered appropriate?



## getopt (Jun 7, 2014)

An ancient thumb rule says swap space should equal installed RAM. Is this still true when there are some GB available? Elsewhere double or even four times RAM is recommended.

Depends on is always a good answer, but how to determine a reasonable swap value, as usage might be very different? At least on my few boxes I rarely saw swap was ever used. The maximum I saw were a few hundred MB swap on a machine with only 1 GB RAM. Is there a way to get the maximum swap used logged somehow in a month's period or so?

I'm interested is this, because here are applications with 8 GB RAM and 40 GB SSD-HDs. So logging memory usage and swap usage is what I'm looking for. Any hints in terms of amount RAM/swap per user?


----------



## kpa (Jun 7, 2014)

That rule of thumb doesn't really hold anymore with FreeBSD. The swap on FreeBSD is just additional backing store in case something really needs to be paged out when real memory starts running low. Disk space is cheap however so you should be able to afford two times the size of the real memory to be absolutely sure you never run out of swap, there's no ill effect from using more than you will ever need. On the other hand you could also run as low as one fourth of the real memory and depending on usage never run out of swap either.


----------



## fonz (Jun 7, 2014)

getopt said:
			
		

> Is there a way to get the maximum swap used logged somehow in a month's period or so?


I'm not aware of a direct means to obtain such statistics, but I suppose you could script a simple daemon that runs swapinfo once every (five) minute(s) or so, isolates the swap usage and tots it up or remembers the maximum or something.


----------

