-
Notifications
You must be signed in to change notification settings - Fork 399
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
Announce Refactor #1117
Announce Refactor #1117
Conversation
- cleanup - rearrange - better comments
- minor cleanup
- Shorten If Else Statement
- add observers and cache
[ci skip] [skip ci]
Apply fixes from StyleCI
- merged the two function and added a filter_flag parameter
- keep cache fresh on retrieved function
@HDVinnie Is the only objective in this particular PR to improve performance? Or are we interested in slimming-down this controller considerably and delegating most of the functionality to other areas of the application? If the latter, my preference is that we write tests before moving anything else around. |
The main purpose at this point is to improve performance. I know some other PHP based trackers out there dont use PHP for announce and instead use https://github.com/Empornium/Radiance or https://github.com/OlafvdSpek/xbt which are written in C++. Now I could be wrong but from what I gather is they use it because it can handle the load better over PHP. But from my tests PHP is not the bottleneck and instead MySQL/MariaDB is and those packages also use MySQL. So idk. |
Good to know, re: the other options for announcing. A compiled binary will always be fastest, but as you said, the problem doesn't seem to be with PHP, per se. Furthermore, it looks like there are some custom stats and computations being performed at the announce layer that might be difficult (if not impossible) to replicate in another solution. What is the |
- there is no need to use the retrieved event.
There is no longer any slow queries using the default 1 sec. |
Just to clarify, is that true under load? And were there slow queries at the 1 second setting prior to making the caching changes in this PR? I suppose I'm asking, "So, we're good?" 😁 |
There was indeed some slow queries prior to the caching. Sometimes the query was slow and sometimes the same query was not. There still is sometimes when mass announcements happen. Like a users client that is seeding 1500 torrents boots or restarts and announces all 1500 at once. I think it just comes down to heavy MySql requests. Jobs/Queues might come in handy here since its one in one out. |
I am merging this for now with caching additions. Will revisit after some more testing/logging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rationale behind removing the retrieved()
methods from the observers?
I ask because, without those methods, I fail to see how the cache will be populated initially (or after it is cleared).
There is no need to re-issue the cache every time someone retrieves the model in question. Its a problem on high traffic sites and causes load issues. I saw a 3-4 second increase in page load times for users and torrents when there 500+ ppl browsing the site. We already cover However you are right about when someones Redis gets cleared. I think if anything |
My point is that the model in question should be retrieved only once, by the very first person to request it on a clean cache. After that, the model should be cached and then all subsequent attempts to retrieve it should receive it from the cache. That said, I think I understand your point and see the problem, which is that the Announce controller is not the only place in which the That's why all of these models should have repositories that provide a level of abstraction; then, the repository could handle the caching completely transparently, so that the caller doesn't have to know or care how the caching is implemented; it just requests the object from the repository and the repository itself decides whether to return a cached version or a live version, depending on the context. |
It looks like you restored the That said, let's keep the repository pattern implementation on the radar. |
Agreed. |
No description provided.