Notes around database
Introduction Random notes and summary of database.
Connection pooling Connection pooling is a technique to keep the reusable open database connections so that applications do not need to open and close a new connection for every request.
Why connections are expensive:
Creating a connection requires TCP handshake The DB must authenticate and allocate memory/resources PostgreSQL forks a process per connection MySQL creates a thread per connection (context switching for thread is 5x faster than process) Connection Pool Size Formula (HikariCP recommendation):