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

Randomize gravity update time #1747

Merged
merged 3 commits into from Oct 29, 2017

Conversation

Projects
None yet
4 participants
@DL6ER
Member

DL6ER commented Oct 21, 2017

By submitting this pull request, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your PR:

Please submit all pull requests against the development branch. Failure to do so will delay or deny your request

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How familiar are you with the codebase?:

10


See title. This PR implements a feature request on Discourse.
Instead of updating at a fixed local time of 01:59, we randomize the time on each update from 03:01 to 04:58.

Edit: We run the job after 3 AM to circumvent DST issues.

This template was created based on the work of udemy-dl.

DL6ER added some commits Oct 21, 2017

Randomize gravity update time
Signed-off-by: DL6ER <dl6er@dl6er.de>

@DL6ER DL6ER merged commit 9492ff2 into development Oct 29, 2017

5 checks passed

codacy/pr Good work! A positive pull request.
Details
code-review/pullapprove Approved by DL6ER, PromoFaux
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@DL6ER DL6ER deleted the tweak/gravity_update_time branch Oct 29, 2017

@PromoFaux

This comment has been minimized.

Member

PromoFaux commented on 06764d0 Nov 7, 2017

This change was implemented after a user made a feature request over on Discourse.

The thinking behind it is to stop blocklist servers all getting hammered at the same time when many pi-hole user's local blocklists update. As for why we exclude 4am, not sure! That's one for @DL6ER

This comment has been minimized.

Member

DL6ER replied Nov 7, 2017

This allows an update on one of the times in these intervals:

  • 03:01 - 03:58
  • 04:01 - 04:58

As you can see, it is not engineered to specifically exclude 4am.

Usually, cron jobs are coded to run either at a specific time or regularly, e.g. once an hour. The latter kind of jobs are usually scheduled to run at full hour, i.e. XX:00. Since many of jobs are depending on the web and hence on working DNS name resolution, I wanted to keep gravity from restarting dnsmasq close to full hours. I'm aware that this is not a perfect solution, but I think that it is a fair compromise and will work for most.

This comment has been minimized.

Contributor

Mausy5043 replied Nov 7, 2017

Just my 2ct:
For the very same reasons (to distribute the load on the server/network) I have my servers make backups at random times. However, I tend to use a fixed hour and then prepend the command entry of the cronjob with

perl -le 'sleep rand 3600';

This way the load is completely randomised. You can even change the '3600' to a larger number allowing the load to be spread across multiple hours.

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