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
I'm currently in the process of migrating from Puma to Falcon and was looking for a way to throttle the incoming request queue so that my upstream nginx reverse proxy doesn't overload a single thread with Fibers-per-request - someone else had this issue as well.
I'd like to prevent the actual Socket accept from happening until capacity is available:
This may or may not be the best way to go about this and this behavior should probably be customizable, but, I would abstractly like to be able to:
defaccept(server,timeout: nil,linger: nil,task: Task.current, **options, &block)loopdotask.asyncdosocket,address=server.acceptiflingersocket.setsockopt(SOL_SOCKET,SO_LINGER,1)endiftimeoutset_timeout(socket,timeout)end# Some sockets, notably SSL sockets, need application level negotiation before they are ready:ifsocket.respond_to?(:start)beginsocket.startrescuesocket.closeraiseendend# It seems like OpenSSL doesn't return the address of the peer when using `accept`, so we need to get it from the socket:address ||= socket.remote_addressyieldsocket,addressendendend
And then in Falcon, I can pass an Async::Semaphore to the endpoint.
This is currently working with the above monkey-patched into the class (in config/falcon.rb) - maybe there's a cleaner abstraction.
The text was updated successfully, but these errors were encountered:
I'm currently in the process of migrating from
Puma
toFalcon
and was looking for a way to throttle the incoming request queue so that my upstreamnginx
reverse proxy doesn't overload a single thread with Fibers-per-request - someone else had this issue as well.I'd like to prevent the actual Socket
accept
from happening until capacity is available:This may or may not be the best way to go about this and this behavior should probably be customizable, but, I would abstractly like to be able to:
And then in Falcon, I can pass an
Async::Semaphore
to the endpoint.This is currently working with the above monkey-patched into the class (in
config/falcon.rb
) - maybe there's a cleaner abstraction.The text was updated successfully, but these errors were encountered: