Fork me on GitHub
#aleph
<
2017-07-02
>
dottedmag12:07:46

Is there a way to apply backpressure to the WebSocket handler in Aleph? I have a network server, and one kind of network messages it serves is bottlenecked on a shared resource. I'd like to make sure the producers of WebSocket messages are paused somehow when the server is not keeping up with the demand.

dottedmag12:07:49

The protocol is "fire-and-forget", and I can't change it, so there is not much possibility to do a backpressure on protocol level, so it has to be something lower-level, e.g. TCP backpressure.

dottedmag12:07:25

I don't care about proxies, as it's a server-to-server communication with no proxies in between.

dm313:07:41

@dottedmag, taking Aleph out of the equation, what is your expected outcome in the client-server interaction when the server can’t handle the load? What does fire-and-forget mean - does the client not wait for any response?

dottedmag14:07:31

@dm3 The expected outcome is that clients slow down until the server can handle the load. Clients do not wait for a WebSocket-level response, but every client uses only one WebSocket connection for communication.

dottedmag14:07:59

If I were starting from scratch, I'd do something like this: a bounded small queue, one thread reading from it and working on a shared resource, request handlers in a pool submitting jobs to this queue synchronously. If a queue is full, request handlers block, and no data is read from the network sockets.

dottedmag14:07:41

However I'd like to have other kinds of requests, not bottlenecked on this shared resource, to proceed.

dm315:07:23

I’m afraid I don’t know enough about Aleph to help here. I’d try to separate the handlers serving the two types of clients (bottlenecked/non-bottlenecked) though so that you don’t have to solve this problem generically.

dottedmag15:07:05

I can do that once the connection is established – the first message carries the kind of connection. But I don't think I have an option to say to Aleph "from now on use this pool to handle the WebSocket messages from this connection"

dottedmag15:07:12

All right, I'll go dig into source code a little.

dm315:07:38

on the Manifold side you have stream/onto which will put all of the callbacks onto the specified pool

dm315:07:04

however that’s probably not what you are looking for

dottedmag17:07:25

Actually it might be the thing I'm looking for.

dottedmag17:07:31

@dm3 Thanks, I'll give it a try.