Ability to "close" sockets without dropping pending requests #874
Answered
by
e3dio
tayler-king
asked this question in
Q&A
Replies: 3 comments 4 replies
import { App, us_listen_socket_close } from 'uWebSockets.js';
let listenSocket;
const app = App().listen(port, s => listenSocket = s);
// block new requests
us_listen_socket_close(listenSocket); |
3 replies
Answer selected by
tayler-king
|
We could possibly consider something similar to maxLifetime where you can specify the maximum time a client can hold a http connection. We have it for websockets for this very reason but not for http |
0 replies
|
@tayler-king Browsers keep connections open with |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
To preface: assume no use of websockets, purely HTTP connections
I'm putting together an application that can handle automatic scaling of uWS server instances based on load. I'm binding each instance to the same port and letting
SO_REUSEPORTdo its thing.As an example, one method of scaling servers down would be to choose the uWS instance with the least amount of pending requests. By pending request I mean a request that has been accepted by the server and is being processed by the application, i.e. it is non-complete and has not finished responding to the client. Once all pending requests have been completed the instance would terminate.
The issue with the above approach is that I cannot fathom of a way to cleanly handling blocking of new requests when a uWS instance has been marked to be terminated, whilst using
SO_REUSEPORT.Would the better option be to just run each server on its own port and have the load balancer handle failing over if a request is rejected with status 503 for example? I would like to avoid this as then I would have to deal with the dynamic port selection of servers and assigning them to the load balancer.
All reactions