Hello,
I'm in the process of developing a real-time voting system, where users can vote daily for their preferred games and receive in-game rewards. The system revolves around two primary use cases:
User Voting: Users vote for games daily through a REST API (User can vote every 24 hours). Each game is identified by a unique Snowflake ID (Time-sorted id), and users are identified by their pseudonyms.
Game Polling for Rewards: Games poll the system approximately every 5-10 seconds to retrieve all recent votes cast for them (Max 1000 votes per poll). Once polled, these votes should be immediately removed from the database to ensure they're counted and rewarded exactly once.
Given the high frequency of polling by games and the ephemeral nature of votes, I'm considering using Redis to efficiently handle these operations. I plan to utilize Redis' data structures and TTL capabilities but am seeking advice on the best way to model this system. Specifically:
What Redis data structures would best fit this use case, considering the need for high-performance reads and writes, and the automatic expiration of votes?
How can I ensure atomicity when retrieving and deleting votes to prevent double counting or missing a vote during polling?
Any recommended practices for handling the TTL of votes to optimize performance and resource usage?
I'm looking for insights on how to structure this in Redis to ensure scalability, performance, and reliability, given the real-time nature of the system and the need for immediate processing of votes and rewards.
Thank you in advance for your guidance and suggestions!