Some urban legends are created and maintained because they tell a story with satisfying irony or surprise. It’s some form of “It implies such a pleasing story that it ought to be true.”
For example, the claim that Western European and American railway gauge is derived from a long series of standards going back to Roman chariot axle length, and therefore, to the width of the back ends of Roman horses. And when that wasn’t picturesque enough, the story was further embellished by adding that railway gauge sets tunnel size, which limits freight dimensions, and therefore the diameter of the Space Shuttle’s solid-rocket boosters was derived from Roman horse dimensions. That’s nonsense.
You may have heard some version of that story. It’s commonly cited in engineering and technology as a warning against perpetuating a design feature “because that’s the way we’ve always done it.”
That is an important point! We just need to find a true story to support it…
The idea of virtual memory is that some of the system’s memory is, well, virtual. It’s as if we have that much memory available although we really don’t. There’s a certain amount of physical memory. The kernel of the operating system has to reside within RAM. User processes are allocated pages of memory, 4,096-byte pages in Linux these days. Some of the pages allocated to a process contain program text, the machine instructions. Other pages contain data, and the running program may ask the operating system to allocate more memory.
The idea of virtual memory is that you also have an area on the disk called the swap area. Disks are much cheaper per byte than RAM, so you might only be able to afford a limited amount of RAM. (and price aside, there are limited slots on the motherboard to hold it) But you could easily add much more space in swap area.
If the kernel and all the processes fit into RAM, great. If not, then memory pages that haven’t been used for a while can be moved to the swap area. This is called paging if it’s just a few pages of some processes. Conventional wisdom has been that light paging is a sign that your computer is computing, it is to be expected.
Once memory space gets tighter with more and larger processes running simultaneously, it becomes swapping as the entire memory space for some processes has to be moved to the disk. That means they will have to be moved back again when the process gets CPU cycles.
Disks are much cheaper, but they are also much slower. You will notice when processes start to swap, things get very sluggish. In Learning Tree’s Linux server administration course we show you how to use the
vmstat command to monitor swap area I/O and watch for associated problems with blocked processes forced to wait for disk I/O.
Consider Andy Tanenbaum’s remark “The nice thing about standards is that you have so many to choose from,” as many so-called “standards” aren’t, really.
That can certainly apply to suggestions about how much swap area you need. Red Hat Enterprise Linux, for example, comes with multiple conflicting suggestions for how much swap area you need, and new releases of RHEL bring new but still self-contradicting suggestions.
Then we always said “But if you are running Oracle, you will need significantly more than that.”
Not any more.
There is nothing special about Oracle. Yes, a large database needs a lot of memory, but that should be no surprise. If your database performance is important, it needs to fit into RAM, the same as any other process.
I think that the best way to think of this is that Oracle database size trends have sometimes grown faster than practical RAM sizes. Especially when you are thinking of Linux systems built around consumer home motherboards, worse yet in the day of 32-bit platforms. But now with at least tens of gigabytes of RAM being commonly practical, have enough RAM so your swap area is used very little, if at all.
Some people even advocate having no swap area at all. The performance loss taken when RAM pages have to move to disk and back should simply be avoided. Your Linux distribution may not like this at all, it might make an installation a bit of a struggle. So make a swap area, RHEL 7 recommends half the size of RAM over 8 GB. A few tens of gigabytes on a multi-terabyte drive is trivial. Then monitor with
vmstat and make sure that this token swap area isn’t really being used.