Comparison
Connection poolvsThread pool
Connection pool
you reuse a fixed set of open database connections instead of paying the handshake on every query.
A cache of established connections shared by application threads. It removes per-request connection setup and, more importantly, bounds how many connections you can throw at the database. Pool size is a capacity decision on the database's behalf: too many and you overwhelm it, too few and requests queue in the application where you may not be measuring.
Full entry →Thread pool
you keep a fixed set of threads and hand them tasks, instead of spawning a new thread for every request.
A bounded set of reusable workers fed from a queue. It caps concurrency, which is the point: unbounded thread creation converts a traffic spike into memory exhaustion and context-switch thrash. Sizing is workload-dependent — roughly core count for CPU-bound work, much higher for I/O-bound — and a blocking call inside a pool sized for CPU work will stall everything.
Full entry →