Skip to content
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

Asynchronously send alerts #1285

Open
starsdeep opened this issue Mar 15, 2018 · 2 comments
Open

Asynchronously send alerts #1285

starsdeep opened this issue Mar 15, 2018 · 2 comments

Comments

@starsdeep
Copy link

starsdeep commented Mar 15, 2018

@brancz

cc @brian-brazil

We currently send alerts at every eval interval, and we sent alerts synchronously, see https://github.com/prometheus/alertmanager/blob/master/dispatch/dispatch.go#L371-L373, so when the reader read alerts from channel, it will not continue to read next alert until it successfully send the alert to all kinds of clients. And as we all know sending alert message to clients involve networking, which is slow. So, consumer can not catch up with producer, thus the channel will saturate.

Then, I propose to send alerts asynchronously:

// current synchronous code at https://github.com/prometheus/alertmanager/blob/master/dispatch/dispatch.go#L371-L373
ag.flush(func(alerts ...*types.Alert) bool {
	return nf(ctx, alerts...)
})

// asynchronous code I propose:
go func() {
	ag.flush(func(alerts ...*types.Alert) bool {
		return nf(ctx, alerts...)
	})
}()

With this simple optimization, the runtime.mach_semaphore_signal time can decrease from 33.3% to 16.6%

profile for current synchronous code
image

profile for asynchronous code I proposed:
image

@starsdeep
Copy link
Author

ref #1201

@brian-brazil
Copy link
Contributor

One thing to watch for is that currently we will be sending at most one notification per group, if this is made asynchronous this exasperate overload on the receiver. I think we should maintain the property that at most one notification attempt is ongoing for a group at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants