Quote:
Originally Posted by devUnix
what percentage of the Physical RAM is determined after which the system must use the SWAP Memory?
|
It is not at all that simple because SWAP space is used for anonymous memory and not for file mappings. File mappings includes most of the executable code in both main executables and .so's.
Unless you are short of disk space, you should have swap space set to significantly more than you ever expect to need. That way if you ever have an unexpectedly high memory load your system will just slow down a little rather than failing.
Quote:
Physical RAM: 1 GB
SWAP Partition: 2 GB
|
Absent any info about how you use that system, I think you guessed the swap size correctly. Even more than the other posters here, I disagree with the old rule of 2x ram size. So I don't think the reason 2GB swap is a good guess is because it is 2x ram size. I think 2GB is a good guess because that is a generous but not absurd amount of swap for most lightly to moderately loaded Linux systems with typical current software. If you had .5GB of ram or 4GB of ram, I'd still think 2GB is a good guess for swap size.
Quote:
Also, what level of RAM and SWAP should we set as "Crtitical" in a production enviroment? For example, 90%?
|
You should occasionally check your swap usage. If any significant fraction of the swap space gets used, you should check the rate of swap-in I/O activity. If there is a moderate to high rate of swap-in, you should get more ram. If a significant fraction of swap space is used but swap-in rates are very low, you should increase the amount of swap space.
In your example of 1GB ram and 2GB of swap, you should probably think of that as up to .5GB of swap for actual use and 1.5GB swap as reserve for rare unexpected incidents. If you notice more than .5GB swap in use, you don't have enough swap space (or depending on swap in rate, you may not have enough ram).
Quote:
Originally Posted by acid_kewpie
you can say that swap would be used when you are requiring more than 1gb of active memory.
|
But that isn't correct. You could be using far more than 1GB of active memory and still not need any swap, maybe not even use any swap if you have swap.
It depends on the mix of anonymous vs. file mapped memory use. No matter how much file mapped memory use you have, non of that use will ever go into the swap file.
If your anonymous memory use gets to 3/4 or more of ram, you will almost certainly need swap space. But even at a lower level of anonymous memory use if the file mapped use is more active than some of the anonymous use, the kernel may be able to make the system faster by swapping out stale anonymous memory to allow more memory use by file mappings.
There are also rare cases where an individual process requests far more anonymous memory than it actually uses, causing the system to need swap space to exist even though it never actually uses that swap space.
Quote:
Generally on a dedicated function server you should *NEVER* need swap, if you do, you are doing something wrong.
|
In a narrow sense of "need" that may be correct. But a server (even more than a workstation) is likely to make good use of a little swap space even when there is plenty of ram. Most service processes use some anonymous memory at startup and shutdown that they don't use in between. Once the kernel figures out that those pages are stale (which might take half an hour on a moderately loaded server or days on a lightly loaded server) it can improve memory use a little by swapping those pages out.
Depending of the services you are running the benefits may be trivial to moderate. That doesn't qualify as "need" but generally qualifies as a good idea.
On the Linux servers where I work, the typical swap partition size is many GB. The typical amount of used swap space is 150MB. The typical swap in rate is zero. These are systems with 3GB to 12GB of ram, so the performance benefits of kicking out 150MB of stale anonymous memory are pretty small (but not zero). The big swap space is there because the memory loads are not directly managed. Different activities that each take most of ram typically run at different times, but could accidentally run at the same time. If that happens we want the system merely slower, not broken.