Skip to main content
InterviewHubPRO
Section Overview
Q37

Question 37 of 50

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

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

HugePages and Transparent HugePages (THP): How they optimize database performance and why Redis advises disabling THP.

senior LevelFormsPerformanceDatabases & SQL

In Simple Words: Standard x86-64 page size is 4 KB. For applications managing 64 GB+ RAM (databases), navigating billions of 4 KB pages overloads the CPU TLB (Translation Lookaside Buffer) cache:

  • HugePages (2 MB / 1 GB): Reduces the number of page table entries by 500x, boosting database memory lookup throughput.
  • Transparent HugePages (THP): Automated kernel allocation of 2 MB pages.
    • Why Redis disables THP: Redis uses background fork() for RDB snapshots relying on Copy-on-Write (CoW). With standard 4 KB pages, writing a 10-byte key only clones 4 KB. With THP enabled, writing 10 bytes forces the kernel to copy an entire 2 MB page, causing severe latency spikes and memory bloat!