0

I am trying to design a system where a Product can only be sold while inventory is available. This is an e-commerce platform where users can buy specific products with designated inventory. A similar example would be someone purchasing a seat in a movie theater. No two people could ever get access to the same seat at the same time.

Given the fact that we have multiple API servers accessing this inventory, we need to limit the access to inventory in a turn-by-turn based approach where every request can check if inventory is available, if so, claim the inventory, deduct the available inventory count, and then proceed.

I have currently built this using an Actor model using Service Fabric which allows creating actors for each inventory object and allows a turn-by-turn access. However, I'm wondering if there are better solutions to do this w/o the overheads?

My issues with Service Fabric are:

  1. Requires at least 5 servers with a minimum of 3 replicas. Crazy high costs due to hardware requirements imposed by Service Fabric

  2. You are married to the infrastructure and the architecture dictated by Service Fabric. Service Fabric is very prescriptive about how things are done and frankly, the local development experience is terrible.

I have also played around with Akka.

Are there any known ways to solve this problem using Lambda or Azure Functions w/ a database such as CosmosDB or Dynamo DB? Would locking be an option? I'm worried about deadlocks and the scalability aspect.

I have also thought through RabbitMQ but that quickly falls apart as more products get added requiring potentially new queues and new consumers (?) the great thing about the actor model is that it at least allows creating actors dynamically and is infinitely scalable.

I've been playing with these for a long time and am finally of the opinion that I could use some outside guidance for people who have thoughts about such systems. Similar systems are used in Event Ticketing (think TicketMaster seat selection) or E-commerce Inventory management systems etc.

Would love to see if someone can share their thoughts and ideas.

  • You're right. Changed. – Anup Marwadi Aug 17 '19 at 6:46
  • Just a typo, so I've deleted my comment. – aerohammer Aug 17 '19 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.