FluffyBoba
FluffyBoba

Flash sale | System Design

Just curious if we have to design some sort of flash sale. For example: let's say 100 iPhones at discounted price for window or may be booking tatkal on irctc.

Will it be good Design to serve the read from the replicas and during the payments may be queue the requests, throttle and add let the db process sequential?

26mo ago
Talking product sense with Ridhi
9 min AI interview5 questions
Round 1 by Grapevine
SwirlyHamster
SwirlyHamster

The replicas won’t be good as they have an eventual consistency. So what we can do is use Cache prolly Redis or Aerospike with Optimistic or Pessimistic Locking so it can power the transactions and Locking would make sure only one checkout happens successfully at a time.

FluffyBoba
FluffyBoba

Too much contention. Locking is not the right approach. Replicas cause no one cares what is shown. The real stuff is your checkout. That should throttle request. Probably that's why irctc gets stuck everytime while we move to the next step.

FluffyBoba
FluffyBoba

Also we just need to ensure the eventual of consistency is not uncertain. So yes may be an asynchronous update on the cache too. Or may be quorum based reads.

Discover more
Curated from across