TimoMoss

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

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]
             }},

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement