-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Out of memory errors. #7
Comments
What did you end up doing? This is causing crashes on our prod environment. Guess I should read all GitHub issues before using something in the future... |
You can use a queue on top of this library, like this one: https://www.npmjs.com/package/queue
I haven't tried the code above, but it's pretty simple to have something like that |
Maybe fix your library instead ? |
haha, how can i fix if the logstash getting slow at receiving the messages through udp? if you have any ideas i'm open for them. |
Integrate the queue directly in the client instead of crashing the process seems like the best course of action. |
It seems that there is no write queue limiting for this library.
Once the connection is created and we start logging to logstash socket and logstash slows down to a trickle the write logs back up to such a degree that you
run out of heap.
Two solutions could be.
write queue for the socket with an async callback when the socket has emptied some of the queue to be sent. This is obviously limited to x size and after the queue is full logs are dropped. This would also help with batching (an optimisation that is really required for this library)
Write buffer ring (LMAX in mutli-threaded languages is awesome). Size limited array that is used as a buffer ring to write log messages into.
simplified untested psedo-code. note that the older versions just get stomped on so if you run out of space only the most recent logs will end up getting sent. You can always just get it to drop too but that is slightly more complex.
Im unsure that the consecutive writes will end up in the same buffer or will be send in separate tcp buffers. Im not too familiar with nodejs sockets.
I might have to switch to another library because of this ... or try create a pull request if i have the time.
Also have you though about integration with winston logging ?
The logstash-winston logger seems a bit badly done to be honest.
The text was updated successfully, but these errors were encountered: