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 execution interval for the tracker stats importer #565

Open
josecelano opened this issue Apr 24, 2024 · 0 comments
Open

Increase the execution interval for the tracker stats importer #565

josecelano opened this issue Apr 24, 2024 · 0 comments
Assignees
Labels
Optimization Make it Faster

Comments

@josecelano
Copy link
Member

Relates to: torrust/torrust-demo#1

There is a background task that imports torrent stats from the Tracker. The Tracker Statistics Importer checks every 100 milliseconds if there are torrents to import. It executes a SQL query to fetch torrents that have not been updated in the last hour:

	"torrent_id"	INTEGER NOT NULL,
	"tracker_url"	VARCHAR(256) NOT NULL,
	"seeders"	INTEGER NOT NULL DEFAULT 0,
	"leechers"	INTEGER NOT NULL DEFAULT 0,
	"updated_at"	TEXT DEFAULT 1000-01-01 00:00:00,
	FOREIGN KEY("torrent_id") REFERENCES "torrust_torrents"("torrent_id") ON DELETE CASCADE,
	UNIQUE("torrent_id","tracker_url"),
	PRIMARY KEY("torrent_id")
);

The field updated_at stores the last update date. You can configure the importer in the config file:

[tracker_statistics_importer]
torrent_info_update_interval = 3600

That configuration means the Index should try to update torrents at least every hour.

It seems querying the database every 100 milliseconds is overloading the demo server. Although it's a tiny instance, we should increase the interval. It could be a configuration option or even calculated manually in the future.

According to the data I've collected we could increase it from 100 milliseconds to 2000 milliseconds.

@josecelano josecelano added the Optimization Make it Faster label Apr 24, 2024
@josecelano josecelano self-assigned this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Optimization Make it Faster
Projects
None yet
Development

No branches or pull requests

1 participant