Closed trevorturk closed 7 months ago
It's also very easy to run out of connections if you have long running requests as Rails doesn't checkin a connection until a request completes. You will have to wrap all your code which accesses DB with with_connection
to avoid this.
Ah, good to know!
Closing since we have better documentation in https://github.com/socketry/falcon/pull/220
I haven't tested in a while, and please feel free to ask me to do my own research, but I'm curious if there's anything else that likely needs configuring after setting
config.active_support.isolation_level = :fiber
in terms of Active Record's connection pool.In my case when I tested last I was connecting to Postgres but didn't have pgBouncer enabled and I was overwhelmed with connections once I flipped it on.
Currently, with
isolation_level
left on the default:thread
I have thisconfig/database.yml
:...but since I may have many more fibers running than threads, I'm concerned that the pool is effectively uncapped in real world usage. Is there some way to cap the pool size to the number of Falcon processes running or something like that? IIRC last time I inquired about this, we suspected that we might need to use an Async::Semaphore to limit connections, but I never did try to figure that out.
I suspect this might impact other Falcon + Rails users, so perhaps it's a good thing for us to try to sort out and document? Thank you!