Linux OS Internals (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What are HugePages and why do databases use them?
senior LevelDatabases & SQL
In Simple Words: Standard Linux memory pages are 4 KB:
- A server with 256 GB of RAM requires millions of page table entries, filling the CPU's Translation Lookaside Buffer (TLB) cache and causing frequent TLB misses.
- HugePages: Allocates memory in 2 MB or 1 GB chunks:
- Dramatically reduces the number of page table entries by 500x.
- HugePages are locked in RAM; they are never swapped to disk.
- Significantly accelerates large in-memory databases (PostgreSQL, Oracle).