Skip to main content
InterviewHubPRO
Section Overview
Q30

Question 30 of 50

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

60%
SQL & Relational Databases (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

What is Database Connection Starvation and how do you size Connection Pools?

senior LevelDatabases & SQL

In Simple Words: Assigning 1,000 connections to a database with 16 CPU cores causes connection starvation:

  • CPU spends 90% of its time context switching between 1,000 threads rather than executing queries!
  • HikariCP Formula for Pool Sizing: $$\text{Pool Size} = (\text{CPU Cores} \times 2) + \text{Disk Spindle Count}$$
  • A 16-core database server typically performs best with a pool of 30 to 40 connections, handling thousands of web requests via queuing!