System Design
2. Networking Fundamentals4. Database FundamentalsAnimated
Connection Pooling
Reusing a set of open connections instead of opening new ones.
The idea
Opening a connection is expensive (handshakes, authentication). A pool keeps a few open and lends them out.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- client
- gateway / proxy
- service
- cache
- data store
- queue / stream
Opening a database connection is slow.
- step:
- 1/4
- at:
- Connection pool
1/11
The green dot is a request moving through the system.
Step by step
- 1Create a small pool of connections
- 2A request borrows one
- 3It uses it and returns it
- 4Idle connections are kept or trimmed
Where it is used
Databases and HTTP clients.
Watch out for
A pool that is too big overloads the database; too small queues requests.