davydovanton / sidekiq-statistic

See statistic about your workers
MIT License
800 stars 81 forks source link

Limit the number of entries in timeslist. #107

Closed garethson closed 7 years ago

garethson commented 7 years ago

Trying to address the performance issues noted in https://github.com/davydovanton/sidekiq-statistic/issues/73 and https://github.com/davydovanton/sidekiq-statistic/issues/72.

Thinking about a solution for this, I tried to consider the following:

The solution I came up with here is to simply select a threshold for the number of jobs we want to sample timing data for and once we cross that threshold, safely remove the oldest (very arbitrary) 1/4 of the timing values in the list. Note that this does not affect any job status counts whatsoever, but rather the average, max, min, and total processing time displayed with each job. If this sounds concerning consider that:

Through some local and anecdotal testing, pushing 500,000 numbers into a list in Redis via lpush as we do via redis.lpush "#{worker_key}:timeslist", status[:time] consumes about 7 MB. Doesn't seem like much but for those having issues, pushing > 2M jobs per day, that's a minimum of 28 MB per day, and in only a few weeks you're over 1 GB of memory usage you won't get back.

I'll add more test results below, but initial testing shows this does fix the issue.

Thanks @davydovanton for this gem, it's the best one I've found for viewing and tracking Sidekiq history.

garethson commented 7 years ago

@davydovanton Great, thanks!

davydovanton commented 7 years ago

💯

tgxworld commented 7 years ago

@davydovanton Is a new release planned soon?