dockerode
dockerode copied to clipboard
This article suggests performance issues under load
This is the article: https://runnable.com/blog/how-sockets-can-block-node-s-event-loop Suggests that demuxing Dockerode log stream with docker-modem may have issues under load. I'm not sure if this is the right place to post it. But it's here anyway.
Excerpt below
Dockerode, the Node.js Docker API, suggests using docker-modem’s demuxer to split up the messages and remove the header. We hooked it up, and it worked for a bit, but soon it started slowing down and crashing. What was wrong?
when you start adding more clients and more containers, the server can’t keep up with all the new messages, and everything snowballs. As sockets filled up with more data, the while loop has to process more messages per iteration of the readable method. The longer the while loop runs, the longer the event loop can’t be interrupted to serve more clients. And the longer the event loop is stuck, the longer the data on the sockets gets, increasing the time spent in the while loop.
Eventually, by the time a new container’s logs are read for the first time, its entire log could be waiting in the buffer. If that happens, the while loop will run until the buffer is emptied, while the other clients don’t get anything at all.
In the last section of the article, they do propose a solution. I have tested it a tiny bit myself and seems to work basically.
Disclaimer
I have not reproduced the bug myself or confirm their solution fixes it in any way.