hundreds of concurrent connections . However, after a certain point, I
would saturate my database (postgres) connection limit, and my users would
start to get errors instead of successful responses . The errors were
due to go trying to make connections after the database's connection limit
had been surpassed.
database/sql manages a connection pool, and it allows one to set
Max*Idle*Conns. However, it does not allow one to set an overall MaxConns.
Currently, there seem to be 3 options for the user: (a) don't manage
connections; when your app goes over the connection limit of the database
itself, your users will get errors; or (b) in your own app, keep an
estimate of the number of in-use connections made by database/sql, and do
not make queries until you believe a connection to be available; or (c)
fork database/sql or the driver for your specific database.
Given that database/sql is managing the connection pool, it seems
reasonable for database/sql to offer the option of limiting MaxConns.
In , bradfitz points out that, e.g., net/http doesn't prevent you from
opening too many outbound connections. This is true. I think maintaining
the option of having no limit (by default) makes good sense. Generally,
however, the file descriptor limit can be set up to ~1 million, whereas
database connection limits will be in the hundreds to low thousands. I
believe and will assert without evidence that database connection limits
are much more common and less easy to solve in software than are file
descriptor limits. I'm not sure that this comparison helps my case, but I
wanted to mention it because it has been brought up before.
This has been discussed in the context of a few other database issues in
, but I think the notion of MaxConns merits another discussion in its
 = http://loader.io/tests/3cb0f3931e2e92f89b0a67fb498c7c62#errors_rates
 = http://loader.io/tests/3cb0f3931e2e92f89b0a67fb498c7c62#connections
 = https://code.google.com/p/go/issues/detail?id=4805
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/groups/opt_out.