Linux and other Unix-like operating systems use the term "swap" to describe both the act of moving memory pages between RAM and disk, and the region of a disk the pages are stored on. It is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast as swap partitions. Now, many admins (both Windows and Linux/UNIX) follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. Let us say I've 32GB RAM, should I set swap space to 64 GB? Is 64 GB of swap space really required? How big should your Linux / UNIX swap space be? I think the '2x swap space' rule came from Old Solaris and Windows admins. Also, earlier memory mangers were very badly designed. There were not very smart. Today, we have very smart and intelligent memory manager for both Linux and UNIX. According to OpenBSD FAQ: Many people follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. This rule is nonsense. On a modern system, that's a LOT of swap, most people prefer that their systems never swap. You don't want your system to ever run out of RAM+swap, but you usually would rather have enough RAM in the system so it doesn't need to swap. Here is my rule for normal server (Web / Mail etc): My friend who is a true Oracle GURU recommends something as follows for heavy duty Oracle server with fast storage such as RAID 10: Swap space will just keep operation running for a while on heavy duty servers by swapping process. You can always find out swap space utilization using any one of the following command: Also, refer Linux kernel documentation for /proc/sys/vm/swappiness. With this you can fine tune swap space. If you are going to suspend to disk, then you need swap space more than actual RAM. For example, my laptop has 1GB RAM and swap is setup to 2GB. This only applies to Laptop or desktop but not to servers. If you are a kernel hacker (debugging and fixing kernel issues) and generating core dumps, you need twice the RAM swap space. If Linux kernel is going to use more than 2GiB swap space at a time, all users will feel the heat. Either, you get more RAM (recommend) and move to faster storage to improve disk I/O. There are no rules, each setup and configuration is unique. Adjust values as per your requirements. Select amount of swap that is right for you.
Linux: Should You Use Twice the Amount of Ram as Swap Space?
Old dumb memory managers
Nonsense rule: Twice the size of your main system RAM for Servers
Select right size for your setup
Swap will just keep running servers...
cat /proc/swaps
swapon -s
free -m
top
See how to find out disk I/O and related information under Linux. In the end, you need toadd more RAM, adjust software (like controlling Apache workers or using lighttpd web server to save RAM) or use some sort of load balancing.A note about Desktop and Laptop
Kernel hackers need more swap space
Conclusion
Thursday, November 20, 2008
What is the rule for setting RAM size in general esp in Linux
Posted by PNA Prasanna at 2:03 AM
Labels: Linux Articles
Subscribe to:
Post Comments (Atom)
0 Comments:
Post a Comment