Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create nowplaying/albumart rate limiter based on current song #249

Merged
merged 3 commits into from
Mar 28, 2023

Conversation

kenellorando
Copy link
Owner

PR creates a new rate limiter that will slow down requests on the /api/nowplaying/albumart API. This API serves relatively large file image, so it's necessary to have a rate limiter mostly for the sake of data transfer volume.

This works based on current song playing. When a new song starts, a client under a single IP can request the song's album art up to 16 times over the duration of the entire song. 16 was arbitrarily selected as an amount I expect most people to be able to comfortably pull album art under normal radio usage. We'll adjust or consider parameterizing this if necessary. If the client hits the limit before the current song ends they will receive a 304 error to indicate that Cadence will not be re-transmitting the art anymore, though the album art is still the same and it is safe to use whatever it last sent.

When the current song ends, the database tracking the artwork request count is flushed and all clients reset their allowed usage of the API.

@kenellorando kenellorando added domain: cadence-api Relates to cadence API domain: cadence-db Relates to cadence database labels Mar 27, 2023
@kenellorando kenellorando self-assigned this Mar 27, 2023
@kenellorando kenellorando merged commit 1396ca0 into master Mar 28, 2023
@kenellorando kenellorando deleted the art-limiter branch March 28, 2023 03:55
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
domain: cadence-api Relates to cadence API domain: cadence-db Relates to cadence database
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants