Working on a new prototype for an app that should be able to handle 20.000+ incoming requests per minute for a short period of time ( like 20-30 minutes ) and give realtime results back to the user.
Example: I show a yes/no question and you should be able to post a vote with YES / NO to our API, and our API should process that and give realtime information back on how many have voted yes and how many have voted no.
All of those requests need to be saved to our MySQL database.
I don't think that it's a wise idea to directly save those 20K requests realtime to the database, as that will create a huge load to the database, especially considering we need realtime data.
So my idea was to put Redis as middle layer. The API writes to Redis, Redis returns the realtime count.
But I still need to be able to persist the data. Is it possible to tell Redis to write all rows to MySQL when there are resources free?
Or would you suggest a completely different approach?
I have looked into RabbitMQ as well, to queue all inserts and process them when possible, but as far as I know this can't return realtime data
I have no code yet, as I am first considering the tools needed to implement this.