Pria
What does queue_target and queue interval exactly mean in DBConnection?
I read the definition in the docs
https://hexdocs.pm/db_connection/DBConnection.html#start_link/2-queue-config
But I am confused as to what they mean and how do they work. The example given is confusing. Can someone explain me this?
Most Liked
dgigafox
This is an extremely late reply but would like to provide my own answer in case someone visits.
- A database connection has a limited number of pool connections.
- If we set queue interval to be 1s and queue target to 50ms then for every 1s (queue interval) it will check if all connections take longer than 50ms (queue target) to checkout or become available to accept a query. If yes, then it will double the target to 100ms.
- If again for the next interval it sees that connections take longer than 100ms to checkout then that is the time the connection will drop queries to prevent further burden to the database
dimitarvp
lkuty
See https://stackoverflow.com/q/66043381/452614
The timeouts you’re referring to are set with the
:timeoutoption in execution functions (i.e.execute/4),:queue_targetand:queue_intervalare only meant to affect the pool’s ability to begin new requests (for requests to checkout connections from the pool), not requests that have already checked out connections and are already being processed.
Keep in mind that all attempts to checkout connections during a
:queue_intervalmust take longer than:queue_targetin order for these values to affect anything. Normally you’d test different values and monitor your database’s ability to keep up in order to find optimal values for your environment.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









