You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the app is using falcon host or falcon virtual with the rack configuration, a preload of the rails environment, and endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:3000"). pretty simple.
I believe you need to invoke #close on conn after you are done with it... Are you able to check if this solves your problem? I will also take a look on my end if I have time.
#close works. canarying the change in production...
would it make sense to restrict async-http-faraday to faraday >= 1.0? might help others to put a call to close in the README instructions, as well. something like:
Faraday's myriad instantiation-time configurations and state makes sharing a connection difficult. what if different requests from the same thread need different middleware?
i guess i could create a separate thread-local class for each configuration, or a single thread-local with a hash of different options => different faraday connections...
Yeah, I understand your issue. For the sake of persistent connections, maybe we want a shared internal pool of HTTP connections. Most of the request/response processing won't actually impact the underlying connection pool...
No, you should avoid doing additional connection pooling.
The reason is, there are life-cycle issues at play.
Using thread-local for your connection object is the best but... I'll try to default to the shared connection pool provided by async-http. Please give me a day to check it and come back to you.
thought you might like to know: with falcon and async-http-faraday (and persistent faraday connections) our servers are about 50% more efficient. using a bit more CPU and slightly more memory, but able to handle (at least) 2x the traffic with half the latency.
Activity
ioquatix commentedon Feb 7, 2024
I believe you need to invoke
#closeonconnafter you are done with it... Are you able to check if this solves your problem? I will also take a look on my end if I have time.jakeonfire commentedon Feb 7, 2024
i thought about that but it doesn't seem closeable. faraday should close the adapter automatically after every request afaik.
ioquatix commentedon Feb 7, 2024
It should be this one:
https://github.com/lostisland/faraday/blob/main/lib/faraday/connection.rb#L122-L127
jakeonfire commentedon Feb 7, 2024
ah i'm looking at the wrong source. let me try with faraday 1.x.
jakeonfire commentedon Feb 7, 2024
#closeworks. canarying the change in production...would it make sense to restrict
async-http-faradaytofaraday >= 1.0? might help others to put a call toclosein the README instructions, as well. something like:ioquatix commentedon Feb 7, 2024
I recommend trying the
model to start with (as it seems you are). However, you won't get persistent connections this way.
So, after you tried that, use the
thread-localgem: https://github.com/socketry/thread-local?tab=readme-ov-file to share an instance:Using the persistent connection will improve throughput and latency.
jakeonfire commentedon Feb 7, 2024
getting a different issue now
jakeonfire commentedon Feb 7, 2024
despite the new issue, memory usage is stable, so closing the connection seems to have been the ticket 🥳
jakeonfire commentedon Feb 7, 2024
Faraday's myriad instantiation-time configurations and state makes sharing a connection difficult. what if different requests from the same thread need different middleware?
i guess i could create a separate thread-local class for each configuration, or a single thread-local with a hash of different options => different faraday connections...
ioquatix commentedon Feb 8, 2024
Yeah, I understand your issue. For the sake of persistent connections, maybe we want a shared internal pool of HTTP connections. Most of the request/response processing won't actually impact the underlying connection pool...
jakeonfire commentedon Feb 8, 2024
yeah that sounds about right. i may take a look.
jakeonfire commentedon Feb 8, 2024
you can close this issue 🙂
jakeonfire commentedon Feb 8, 2024
@ioquatix do you think using a process-wide connection pool instead of a thread-local one, via https://github.com/mperham/connection_pool (or https://github.com/socketry/async-pool which i think does the same thing?), might be more efficient in some ways?
i noticed
async-httpuses its own connection pool: https://github.com/socketry/async-http/blob/main/lib/async/http/client.rb#L39ioquatix commentedon Feb 8, 2024
No, you should avoid doing additional connection pooling.
The reason is, there are life-cycle issues at play.
Using
thread-localfor your connection object is the best but... I'll try to default to the shared connection pool provided byasync-http. Please give me a day to check it and come back to you.jakeonfire commentedon Feb 10, 2024
thought you might like to know: with
falconandasync-http-faraday(and persistent faraday connections) our servers are about 50% more efficient. using a bit more CPU and slightly more memory, but able to handle (at least) 2x the traffic with half the latency.ioquatix commentedon Feb 13, 2024
@jakeonfire is it okay to use your testimonial on my website?
jakeonfire commentedon Feb 15, 2024
@ioquatix sure!