-
Notifications
You must be signed in to change notification settings - Fork 69
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
Deliver async reports from a goroutine pool #230
Conversation
## 2.3.1 (2024-03-18) ### Bug fixes * Handle empty pointers to complex structs in metadata.Add [bugsnag#221](bugsnag#221)
## 2.4.0 (2024-04-15) ### Enhancements * Sanitize for metadata should also handler json and []byte [bugsnag#226](bugsnag#226) [Chris Duncan](https://github.com/veqryn)
4eb61dc
to
92fd13f
Compare
Hi @DariaKunoichi, can I get some initial feedback on this idea? |
Hi @opsengine, thank you for preparing two solutions for this problem. |
Understood. I figured that backward compatibility needs to be preserved and discarded that idea.
Using pond with a large value of
A caller that wants to use its own pooling library will enable synchronous mode, so the pond pool will not be used.
This would shift more responsibility to the caller. As a user I would very much prefer that the library did the pooling by default and exposed the relative configs. In other words, it's preferable that the library protects the caller from unlimited goroutine growth as a default behavior, instead of providing ways to address the issue when it has already happened. Dropping some bug reports is much better than compromising the application stability further. |
Okay, let me explain in more detail. |
Can you give an example? I can't think of a situation where this would become problematic. Two alternative ideas to fix this upstream:
If none of these solutions are possible, we will have to either wrap the library or (worse) fork it. |
@opsengine – in the immediate term I would suggest forking this repo and using your solution would be the way to go for your usage. Whilst we see the benefits of your PR, and I appreciate you taking the time to raise it, we need more time than we have available to our team to consider the impact in full to all users of this SDK. There are a few improvements, including this one, to payload delivery that we'd like to make and I'll look to get them included in our Q3 plan at which point your PR will form part of the discussions. In the meantime, we'll leave the PR open for future discussion and potential use by other users and pick it up again in due course. |
Hi @opsengine, Just wanted to let you know that we have released some changes to async event delivery in v2.5.0 of bugsnag-go. The notifier will now use a single goroutine with a channel to queue events. Please do let us know if you have any questions about this. |
@hannah-smartbear that's great, thank you! is this feature enabled by default or do I have to edit the configuration? do I read it correctly that the client will enqueue up to 100 reports and deliver them sequentially to the bugsnag server? |
Hi @opsengine, A single goroutine for async delivery is now enabled by default. This will indeed queue up to 100 events, with any new events added while the queue is full to be dropped. Please let us know if you have any further questions about this. |
Goal
The goal is to avoid creating a new goroutine for each report when using asynchronous mode. The motivation is that an application that creates more reports than the server can handle, may experience high CPU and memory utilization, which can cause further instability in the application.
This problem has been reported before #49
Design
Allocate a pool of worker goroutines. When asynchronous mode is enabled,
Notify
submits the reports to the pool in a non-blocking fashion. If pool is full, the report will be dropped. This approach maintains the asynchronous behavior while avoiding unlimited proliferation of goroutines.Changeset
Testing