3

I have a plugin for a Hapi.js-based REST service that is sending logging data to a log ingestion API.

When the Hapi REST service generates a large volume of logging data, the log ingestion API can't handle the volume and I see socket disconnected errors from my plugin.

I can eliminate the socket disconnect errors by configuring a maxSockets property on the HTTP agent, but the problem now is that it takes minutes for the sockets to be freed new data to be sent by the plugin to the log ingestion API.

For example, if I configure maxSockets as 50 and send 200 requests to the Hapi REST service, the first 50 log events show up in the log ingestion endpoint right away.

The next 50 events start to trickle in after 5-10 minutes ... and so on.

My question is how to do debugging to understand the life cycle of the sockets and find out why they are apparently taking so long to be freed.

Everything I've read (e.g. node.js what happens when maxSockets are reached? and Node JS how to limit maximum number of sockets) describes that maxSockets queues the number of concurrent sockets, but nothing in more detail about how that queueing works.

5
  • This sounds like your logging server isn't sending a proper response back and its socket has to eventually timeout before the Agent will let any more requests go. FYI, your logging server can send a response immediately and then go about whatever it was going to do to also shorten the "in use" time for the socket that delivered the message. Commented Oct 31, 2019 at 1:39
  • FYI, you may also want to consider grouping requests so multiple messages are grouped together whenever the socket pool is busy. This reduces the number of roundtrip requests when the system gets busy. Commented Oct 31, 2019 at 1:42
  • I've done grouping / batching of requests and that can help somewhat, but if a high enough volume of logs are generate, I still get into a queueing situation. Also, if I just hit the logging server directly with requests from a simple Node.js application using the same request library as the Hapi plugin, I'm not seeing the same queueing issues. Commented Oct 31, 2019 at 21:25
  • So, you're saying this issue is being caused by the HAPI plugin? Commented Oct 31, 2019 at 22:00
  • It might be caused by the plugin or the overall Hapi ecosystem or something else entirely ... I'm not sure. Commented Nov 2, 2019 at 0:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.