Connection Pool Parking

1 minute read

Why Connection Pooling Is Like a Parking Lot

Connection pools are supposed to be like valet parking for database connections - efficient, organized, and faster than doing it yourself. In reality, they’re more like a parking lot where people abandon their cars and forget where they parked. At 21CT, we had connections that would get checked out and never returned, like library books that someone uses as furniture. The pool would slowly drain until the application couldn’t connect to the database at all.

The sizing problem is beautiful in its impossibility. Too few connections and you get threads waiting in line like it’s Black Friday at Best Buy. Too many and your database starts sweating like a teacher trying to manage forty kindergarteners. The “correct” size is always exactly one more or one less than what you have. We spent months tuning our pool size, creating elaborate spreadsheets and models, only to discover that the optimal size was “whatever doesn’t break.”

My favorite pooling bug was when connections would timeout while sitting in the pool, but we’d only find out when someone tried to use them. It was like a parking lot full of cars with dead batteries - they look fine until you try to drive one. Every morning, the first few requests would fail as the application tried dead connections, threw them away, and got new ones. We called it the “morning sacrifice” - the first few users of the day were offerings to the connection pool gods.

Updated: