Help wanted: /rest/v3/tags/stats runs for 180 seconds after migration to a new server via Plesk #2001
-
Shlink version3.7.3 PHP version8.2.15 How do you serve ShlinkSelf-hosted Apache Database engineMariaDB Database version10.11.6-MariaDB-0+deb12u1 - Debian 12 SummaryShlink was running on a Debian 10 VM using Plesk Web Admin Edition (latest). Now we created a brand new VM with Debian 12, installed Plesk and used the migration tool to transfer shlink from the old to the new VM. After a few problems we could fix, shlink runs as expected - except for calling manage tags from https://app.shlink.io/ . Here we got 504 errors after 1 minute. We looked at server status with phpmyadmin and saw a query which needs about 180 seconds:
On the old VM this query needs ~16 seconds for the first time and less than 1 seconds when calling again. On the new VM it lasts always ~180 seconds every call. On both VMs the content of the database is the same:
Please note that shlinks runs since 2021 and recorded several visits ;-) Since everything else except for the debian version is the same on the new VM and because all configs were transfered using the plesk migration tool, we do not have any ideas what the reason is for the long time it lasts. Do you have any suggestions for us? I don't know what information you need, so please tell me and I'll provide. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is unfortunate, however, the performance issues with tag stats endpoint are known. You can see more details here #1346 (the "complex query" mentioned there is the one you pasted above) That doesn't explain why it is now way slower than before, but I'm thinking it might be related with internal database indexes/caches/whatever, that were set in the previous instance as opposed to the new one. Maybe performance improves once that whole dataset has been successfully loaded at least once. Perhaps you can try running it manually until it finishes. |
Beta Was this translation helpful? Give feedback.
-
@SWEIHER I have found a possible way to address this problem, although I think I'm working with a much smaller dataset than you. For me, with around 1M visits, 10k short URLs and 20k tags, this endpoint takes 4 seconds to load. With the changes I applied here, it goes down to 250ms. Also, I think there's room for improvement, as I just updated a very complex query (the one you originally shared) to count visits via new table that tracks aggregated visit counts, but I think with this, the whole query could be replaced and re-thought from scratch. Could you share with me some rough numbers of how many short URLs, visits and tags does your system have? It will help me verify potential improvements. |
Beta Was this translation helpful? Give feedback.
Shlink 4.1.0 has just been released, with a huge performance improvement when loading tags stats. Let me know if this helped.