Skip to content
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

Cost mitigation idea #30

Open
laurentS opened this issue Apr 20, 2021 · 1 comment
Open

Cost mitigation idea #30

laurentS opened this issue Apr 20, 2021 · 1 comment

Comments

@laurentS
Copy link
Member

With the current mapathon ongoing, we've seen the firebase bill go through the roof, even with @Hagellach37 's fix 2-3 days ago on this code (which limits loading to the mappers who've opened the app in the last 24h, instead of all users ever).

There is still a lot of download happening, apparently because users keep refreshing the leaderboard a lot more than we expected.
An option to mitigate this cost in downloads could be to run a function server-side (within firebase) that prepares and caches values to show. For instance, we could imagine running a function every 5 minutes, which would simply run the current query, and copy the result onto some cloud storage (or VPN), and modify the frontend to load that file from bulk storage instead of firebase (and we put some caching logic there so that browsers don't reload more often than once/5 minutes for instance).

This would give us both lower transfer costs (we would effectively only have 1 load/5 minutes), and possibly faster loading for the leaderboard.

@Hagellach37
Copy link
Member

We could try to provide files through the back end workers, e.g. as we do here already: https://apps.mapswipe.org/api/users/

This is currently based per project, but we could adjust this and provide a file for all users and use some compression as well. So basically by merging all the existing files.

Currently these things are updated once every hour. Not sure if this is enough? From the backend side updates more frequent than every 15 minutes will be a bit harder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants