HTTP Server Throttling

103 views
Skip to first unread message

Chris Ackerman

unread,
Aug 30, 2012, 3:08:04 AM8/30/12
to nod...@googlegroups.com
I've been working on a web server framework of my own using a cluster of workers sharing a single listener. The documentation for clusters just says that workers workers sharing a listener will just automagically throttle themselves, but I find that unacceptable.

I want to be able to tell a listener in one of the workers to not accept new connections until I unblock it. I have found only one way of doing this and it's much less than satisfactory. You can call the close method on the server which will stop the server from accepting new connections, but the only way to restart it is to create a new server! This works, but a) it's creating a new server instance when all I really want to do is allow new connections to be accepted again, and b) I'm not sure how the backlog works in a node HTTP server. Is there a way to tell how large the backlog is? is there some way to just configure the maximum number of concurrent connections per listener? Is the backlog shared across all of the shared listeners in all of the workers? Is there documentation somewhere on the underlying implementation?

Ben Noordhuis

unread,
May 29, 2013, 8:51:13 AM5/29/13
to nod...@googlegroups.com
On Wed, May 29, 2013 at 9:25 AM, David Beneš <dbe...@gmail.com> wrote:
> Have you found your answer? I asked the same questions to google and end up
> here...

For context, the question is how to make a cluster worker stop
accepting connections until the master tells it it's okay again. The
cluster module doesn't support that: it's designed to be easy to use,
not to be configurable to death.

All the infrastructure is in place however. The child_process module
(which is what the cluster module sits on top of) lets you send and
receive handles and messages. You can roll your own cluster module
that behaves any way you like, you just have to sit down and write the
code. :-)

In this particular case, you probably want to have the master process
accept new connections, then send it to a worker of your choosing.
Reply all
Reply to author
Forward
0 new messages