Skip to main content
InterviewHubPRO
Section Overview
Q40

Question 40 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

80%
Linux OS Internals (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Linux Swap Space, Swappiness (`vm.swappiness`), and ZRAM: When and how to configure swapping.

senior Levellinux-osAdvanced Internals

In Simple Words:

  • Swap: Disk space used when physical RAM is exhausted, paging inactive anonymous memory to disk.
  • vm.swappiness (0 - 100): Controls the kernel's balance between reclaiming page cache (file buffers) vs swapping anonymous memory.
    • swappiness = 60: Default desktop behavior.
    • swappiness = 1 - 10: Ideal for latency-sensitive databases (PostgreSQL, Kafka, Elasticsearch) to avoid blocking disk thrashing.
  • ZRAM: Creates a compressed block device directly inside RAM. Instead of writing slow pages to HDD/SSD, the kernel compresses idle pages by 3:1 in RAM with zero disk I/O.