-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Rework analytics handling to fix performance issues on large datasets #2080
Comments
It's funny that you request this precisely now, because I happen to have just implemented it 😅 You can find more context on this other issue #2036 And these PRs:
The overview counts are the only ones missing, but it shouldn't be super hard to implement now. I did my testing with ~1M visits, 10k short urls and 20k tags, and everything was around 20x faster in average. |
This is now fully implemented. |
Sweet. Release soon? :D @acelaya |
Shlink 4.1.0 has just been released. |
Summary
Long time shlink user here with 10s of millions of recorded visits. Due to the design of the app, the visits/orphan visits counts, along with the link visits counts either never load or take forever to load. https://imgur.com/94hIXTx
Upon doing some research it appears that every time the admin page is loaded a direct database query is run (regardless of if using roadrunner or a web server) to count these entries. On our large dataset with a reasonably cheap VPS (4 core, 8GB ram) this takes over 2 minutes to complete.
localhost | shlink | Query | 147 | executing | SELECT COUNT(v0_.id) AS sclr_0 FROM visits v0_ WHERE v0_.short_url_id IS NOT NULL AND v0_.potential_bot = 0
A far more optimal way to do this would be to store the counts in the database and then query those, for both the global count and individual shortlinks.
In a perfect world, those counts would be iterated on each visit, and then checked for accuracy by doing a full database count on a scheduled basis. It could also just be the latter.
Use case
Visit counts never loading, and sorting short links by visit count taking forever.
The text was updated successfully, but these errors were encountered: