3 ms·
I have in one of my applications a background job that basically does the following: - Some quick database lookups (~ 10 ms total) - An API call (depends on t
by WJW 5y ago
I have in one of my applications a background job that basically does the following:
- Some quick database lookups (~ 10 ms total)
- An API call (depends on the time of day, but between 500-800 ms)
- Another quick database insert (~ 20 ms usually)
The job only needs a db connection for about 5% of the total runtime of the job and can give the connection back to the pool while the API call is running. Many mailer jobs in the system have a similar db-to-api-call ratio.
(Also, I am of the opinion that all but the very biggest sites should not have any problems with db connections. Get a database that handles tons of connections gracefully like MySQL or use something like pgbouncer when using Postgres. Having low connection limits should not be a problem in 2022)