Data Storage - Paging or Swapping

1 - About

A transfer of pages between main memory (RAM) and an secondary storage such as hard disk drive, is referred to as paging or swapping.

Usage:

  • In virtual memory management. Over time, the operating system may “swap out” some of a process’ resident memory, according to a least-recently-used algorithm, to make room for other code or data. Thus, a process’ resident memory size may fluctuate independently of its virtual memory size. In a properly sized host there is enough physical memory, and thus swapping is disabled and should not be observed.

It's the ability to use the disk to extend the amount of RAM available.

  • Paging refers to writing portions, termed pages, of a process' memory to disk.
  • Swapping, strictly speaking, refers to writing the entire process, not just part, to disk.

In Linux, true swapping is exceedingly rare, therefore the terms paging and swapping often are used interchangeably.

Using swap space is not inherently bad. Rather, it's intense paging activity that's problematic. For instance, if your most-memory-intensive application is idle, it's fine for portions of it to be set aside when another large job is active. Memory pages belonging to an idle application are better set aside so the kernel can use physical memory for disk buffering.

Swap usage is a result of paging due to possible memory leaks or a high number of concurrent tasks.

3 - Page

3.1 - in

When pages are returned to physical memory, the event is called a page-in

Page-ins are common, normal and are not a cause for concern. For example, when an application first starts up, its executable image and data are paged-in. This is normal behavior.

3.2 - out

When pages are written to disk, the event is called a page-out,

Page-outs, however, can be a sign of trouble. When the kernel detects that memory is running low, it attempts to free up memory by paging out. Though this may happen briefly from time to time, if page-outs are plentiful and constant, the kernel can reach a point where it's actually spending more time managing paging activity than running the applications, and system performance suffers. This woeful state is referred to as thrashing.

3.3 - fault

A page fault occurs when the kernel needs a page, finds it doesn't exist in physical memory because it has been paged-out, and re-reads it in from disk.

4 - How to calculate the Swap Space ?

You need hard disk drives with sufficient space for swap. You can calculate the required swap space as follows:

  • For SAP application server instance, twice the main memory structure (2 x RAM) with a maximum of 20 GB
  • For the oracle database instance, you need:
    • Recommended: 3*RAM + 500 MB, at least 20 GB
    • Minimum: 2*RAM

You can display and – if required – modify the existing swap space: Linux - Swap / Paging

data_storage/swap.txt · Last modified: 2018/06/08 14:51 by gerardnico