How it works...
Being able to control the depth of our connection pool is very useful. This will allow us not to overload a database, but it's important to consider what it will mean in the context of timeouts. If you enforce both a set number of connections and strict context-based timeouts, as we did in this recipe, there will be cases where you'll have requests frequently timing out on an overloaded application trying to establish too many connections.
This is because connections will timeout waiting for a connection to become available. The newly added context functionality for database/sql makes it much simpler to have a shared timeout for the entire request, including the steps involved with performing the query.
With this and the other ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access