kodepett
I’ve been experiencing a bit of timeout in production with respect to my queries. I’ve going through the docs and a few resources here, I came up with the below configuration. Kindly advise if it will suffice for production.
Configuration file:
config :debitor, Debitor.Repo,
url: database_url,
pool_size: String.to_integer(System.get_env(“POOL_SIZE”) || “10”)
timeout: 60000
Repo call:
`Repo.all(query, [timeout: 120_000])`
Thanks.
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Latest Phoenix Threads
Latest on Elixir Forum
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
I would probably leave the default timeout alone, and only increase it for specific Repo calls. Regularly needing to support queries up to 60 seconds seems like an issue.
kodepett
@benwilson512, thanks a lot sir, you’ve been a great source of inspiration and a mentor. I’m most grateful.
How do I use
queue_timeoutandqueue_targetand what’s the difference. I’ve not been successful in getting any material onqueue_target. How do I use this with Ecto. Just like the others, should it be configured for the Repo.dimitarvp
Not the most intuitive of documentation location so here’s the link explaining those config options: DBConnection — db_connection v2.10.1
kodepett
Thanks for the documentation. I’m trying to wrap my head around those parameter. How does the DBConnection fits into Ecto architecture. For
queue_timeoutandqueue_target, I believe I have to set them alongside the Repo configuration in the config file like above.Thanks.
dimitarvp
db_connectionis whatecto_sqlsteps on. It is the lower-level library that Ecto’s DB handling code (namely theecto_sqllibrary) is wrapping in a more convenient package for us.And yes, you simply have to add
queue_timeoutandqueue_targetto the Repo configuration. If you expect long transactions then it’s worth to simply increasequeue_targetto something larger and ignore the other option. In my hobby and professional apps I usually bump it up all the way to 5000 (ms) to give the apps breathing room to wait for a connection from the pool in high-load conditions. Having Ecto error out in such a situation isn’t very useful to me so I first increase thequeue_targetand then start analysing why my transactions take so long.Alternatively, you can just increase
pool_sizeto a bigger number. I rarely accept the default of 10 and usually set it to 20.EDIT: Here’s my Repo config in one of my hobbyist projects that does ingestion of public retail datasets:
kodepett
It makes a lot of sense now. Thanks a lot for the awesome explanation as well as the configuration details. I will apply changes to my config file on production and monitor.
dimitarvp
To post an update 5.5 years later, I use those a little differently now.
Revised understanding
queue_intervalis the time during which DBConnection (and effectively Ecto) monitors if every single checkout takesqueue_targetor more time. If so,queue_targetis doubled and then another duration ofqueue_intervalis being monitored. If every single checkout takes takes 2xqueue_targetor more time for the nextqueue_intervaltime then DBConnection starts dropping messages on the Elixir level so as to protect the DB.This is very rarely what I wanted, both in hobby and professional projects. Most users I spoke with said they prefer to occasionally have to twiddle their thumbs and wait for 10-30 seconds for a page to load, as opposed to being hit in the face with a cryptic error message and a page full of stack traces (or the dreaded empty page with the single line of text of “Sorry, something went wrong”) that stops them dead on their tracks.
Example
Setting
queue_targetto 200 andqueue_intervalto 10000 means that if for 10 seconds every single connection checkout takes 200ms or more, then the tolerance for waiting a connection checkout gets raised to 400ms. If during the next 10 seconds every connection checkout takes 400ms or more, then DBConnection starts dropping messages (i.e. nothing goes to the DB).If I am tragically misunderstanding this and misleading others then please, anyone who is informed better, correct me.
LostKobrakai
It’s fine for individual requests beings slow. If everything is slow you need to eventually shed load or your queue(s) might grow faster than it can shrink leading to other problematic effects. One can argue that default limits might be too tight, but you want the behaviour in general.
dimitarvp
I agree on “eventually” – that’s always the goal. And I agree that the default limits are too tight to be practically useful because the alerts produced by them often lead to an APM notification fatigue.
LostKobrakai
There’s hardly a good way to have a generally useful default. A db on the same host will always be faster than a db on another host and even more so if both machines are not within the same DC. So you need to figure out what a realistic number for
queue_targetactually is. It furthermore depends on how long the avg query takes, because that’ll affect how long a query needs to wait once the queue is fully utilized. The latter will also affect howqueue_intervalshould be sized.