Remove visit in-memory cache, but add rate limiting #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make the API more robust to restarts and to memory caps.
The previous solution - which consists of an in-memory cache that regularly persisted into a CSV file which is regularly summarized into a database - was designed to avoid usage spikes hanging the server.
Here I'm suggesting a simpler solution: we write every visit directly to the DB, but to avoid the spike problem, we drop repeated requests coming from the same IP. Specifically, we cap to 1000 in 1 second from the same IP.
Of course, there is a chance that users might be running very large workflows behind the same IP (e.g. on the same machine), and multiple legit MultiQC runs might start on the same second. I'm not sure how probably that is. Haven't happened so far (the max number of requests from the same IP per minute was 22). But maybe having some separately running cache layer might work better.