Opening and closing a database connection every time new transactions take place becomes a bottleneck really quickly. Typically, opening a database connection is an expensive operation. This is mostly because of the associated TCP handshake that's required to create socket connections on both sides. The overhead is even more expensive if the database is hosted on a remote server, which is usually the case. If we could reuse the connection for every subsequent request that gets sent to our database, we might reduce the latency a great deal. An efficient way to mitigate this overhead is to employ database connection pooling. When a process needs a new connection, it is given an existing connection from the pool ...
Connection pooling with r2d2
Get Mastering Rust - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.