Import tracker statistics in batches #428
Replies: 4 comments
-
If we don't need the statistic of all torrents at any given time, it makes sense to import the statistics for a particular torrent when the user visits the details page. Also background tasks has their own drawbacks as you mentioned. I'd like to do some research on message queues, but as of right now, I think option 2 it is a good idea. |
Beta Was this translation helpful? Give feedback.
-
Hi in the live demo with a small server, we can only import 1 torrent per second with the current server load. See #459 And we always import the same ones because the query is At least we should introduce an |
Beta Was this translation helpful? Give feedback.
-
@josecelano |
Beta Was this translation helpful? Give feedback.
-
Relates to: #569 |
Beta Was this translation helpful? Give feedback.
-
The Index has a cronjob called "statistics importer". It imports torrent statistics from the associated tracker. The default configuration executed the process every hour:
This tasks:
SELECT torrent_id, info_hash FROM torrust_torrents
).That solution has some problems:
It seems that the process does scale well and it's not even efficient. There are different solutions depending on which aspect you want to improve. For example, if you want to scale it you can add an importation date and just fetch statistics continuously only importing the torrents that have not been imported in the last hour. This solution does not solve the problem of making request to the tracker for torrents it does not have.
Proposed solution 1
A naive implementation could be:
Proposed solution 2
We could also not import statistics at all for all torrents and only import statistics for a single torrent when the users load the torrent details page. That would require an extra request to the tracker every time you load the page. It could work if we do not need statistics for other cases.
Other solutions
I will go with solution 2 and that would make the tracker API even simpler. This is related to using a DashMap for the tracker data. We would not need to use a BTreeMap to order torrents, because right now we only need it for the API. In addition, background tasks are hard to maintain:
cc @da2ce7 @WarmBeer @mario-nt @grmbyrn
Beta Was this translation helpful? Give feedback.
All reactions