'How to prepare and execute atomic operations with cache

Design campaign management system to distribute 6 M items to users who wants to get free item. The campaign lasts for 10 mins. Each user must get only 1 item.

My approach:

I am more interested to discuss the implementation /algorithm part Basically decrementing a counter and flag a user ID atomically . Since we are looking at peak req of 100k per sec. I think distributed caches would be better suited here may be Redis.

So we are looking at transactions to do a decrement and flagging the userid.

Any suggestions on if this seems the correct approach or your thoughts on better approaches



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source