cherti / mailexporter

Export Prometheus-style metrics about mail server functionality
https://prometheus.io
GNU General Public License v3.0
45 stars 9 forks source link

randomize startup offset of prober-coroutines #10

Closed cherti closed 7 years ago

cherti commented 7 years ago

currently the proper-coroutines have a constant, defined offset in which they are fired up. This might have the disadvantage that vor certain values of this offset we might end up having two prober-coroutines started at the same time again, for example if one fires up 5 prober-coroutines and chooses an offset of 15s. Then the fifth one is aligned in time with the first one, what should be avoided to reduce peak load the mailexporter causes on the system.

Randomizing the offset would mitigate this issue with high probability and reduce peak load caused by the mailexporter.

Either we choose for a constant offset that is used as the intervall for randomization or we choose this to be configurable as it is the case currently.

cherti commented 7 years ago

When the startup-offset is properly randomized, we could even drop the startup-offset-config-option as this would no longer be necessary.

Reasonable values might be in the range of 1s-5s?

So we should replace the time.Sleep(…) here by something with a random duration (see the example here).

We could also think about moving the duration offset into the monitor-function itself and let it wait at its beginning, which would probably be even more useful. But then we should randomize within an interval of higher upper value of 10s or 15s.

I think a random time like time.Duration(rand.Int()%10000) * time.Millisecond would be an appropriate offset for within the startMonitoringJobs()-function. Maybe even with an additional offset of 1s just as a precaution.