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

Increase the tracker stats importer exec interval #566

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/console/cronjobs/tracker_statistics_importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,28 @@ pub fn start(

info!("Tracker statistics importer cronjob starting ...");

// code-review: we set an execution interval to avoid intense polling to
// the database. If we remove the interval we would be constantly
// queering if there are torrent stats pending to update, unless there
// are torrents to update. Maybe we should only sleep for 100 milliseconds
// if we did not update any torrents in the latest execution.
// With this current limit we can only import 50 torrent stats every 100
// milliseconds which is 500 torrents per second (1800000 torrents per hour).
// If the tracker can handle a request in 100 milliseconds.

let execution_interval_in_milliseconds = 100;
// code-review:
//
// We set an execution interval to avoid intense polling to the
// database. If we remove the interval we would be constantly queering
// if there are torrent stats pending to update, unless there are
// torrents to update. Maybe we should only sleep for 100 milliseconds
// if we did not update any torrents in the latest execution. With this
// current limit we can only import 50 torrent stats every 2000 seconds,
// which is 500 torrents per second (1800000 torrents per hour).
//
// | Interval (secs) | Number of torrents imported per hour |
// ------------------|--------------------------------------|
// | 1 sec | 50 * (3600/1) = 180000 |
// | 2 sec | 50 * (3600/2) = 90000 |
// | 3 sec | 50 * (3600/3) = 60000 |
// | 4 sec | 50 * (3600/4) = 45000 |
// | 5 sec | 50 * (3600/5) = 36000 |
//
// The `execution_interval_in_milliseconds` could be a config option in
// the future.

let execution_interval_in_milliseconds = 2000;
let execution_interval_duration = std::time::Duration::from_millis(execution_interval_in_milliseconds);
let mut execution_interval = tokio::time::interval(execution_interval_duration);

Expand Down
Loading