TimoMoss
Finch unable to provide a connection
Hello, in our Phoenix API, we’re making numerous calls to external APIs like Opena Ai, with long responses that can take 2 to 15 seconds.
As an HTTP client, we use Req {:req, "~> 0.5.2"}, when the number of user requests to our API reaches approximately 20 per second, hence the same number of calls we’re doing to the external API we’re getting the following error: (RuntimeError) Finch was unable to provide a connection within the timeout due to excess queuing for connections. Consider adjusting the pool size, count, timeout, or reducing the rate of requests if it is possible that the downstream service is unable to keep up with the current rate.
I played with Finch opts, in the Application supervision children:
children = [
{Finch,
name: MyConfiguredFinch,
pools: %{
:default => [
size: 1000,
count: 200,
pool_max_idle_time: 120_000,
conn_max_idle_time: 120_000
]
}},
....
]
but seems it doesn’t help
I would highly appreciate any help since this happening in the production
Most Liked
oliveiragahenrique
Seems correct! But it for sure slow down the performance and the way it is right now it would apply for all services called by this MyConfiguredFinch instance.
So, I would suggest 2 things:
- Create a configuration for the specific service you are having trouble with.
- Do not decrease it to 1 on the first try, but measure and see
Somehting like this:
children = [
{Finch,
name: MyConfiguredFinch,
pools: %{
:default => # Keep as it is
"https://your-faulty-service.com" => [size: 10, count: 1]
}},
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









