I'm trying to build a prototype using DDD/CQRS and do some bench marking. Here are the details of the scenario (flash sale capability) I want to model.
1. The primary constraint is that there are "limited" quantity of each item (only 1000) 2. Invitation for the flash sale is sent to 100K users 3. 20K invited users log in at the "same" time to buy the item at a given time say 10 AM. 4. Only 1000 of these 20K users should be able to buy the item. 5. To keep it simple I want to start with only one item. 6. All this can happen in the* order of few seconds.* I'm creating an AggregateRoot (an PersistentActor) called ItemInventoryAggregate. This Actor *enforces* the check that *an item can only be added to cart as long as there is available quantities left*. My concern is that this check is there in only a *single* actor thereby making it a bottleneck (?). I want to verify if I'm on the correct track. Will this approach scale or do I need to rethink my design? One the view side I want to make sure that as soon as item is unavailable I want to "show a soldout button" on the UI. As you can see all 1000 items can be sold out in 1-2 seconds. Will the view side be consistent (i.e., it will be see all items are sold out) in this window of time ? object ItemInventoryAggregate { //state case class ItemQuantity(quantity: Int = 0) extends State //commands case class AddToInventory(quantity: Int) extends Command case object AddItemToCart extends Command case object RemoveItemFromCart extends Command //events case class ItemsAddedToInventory(quantity: Int) extends Event case object ItemAddedToCart extends Event case object ItemRemovedFromCart extends Event def props(id: String, name: String): Props = Props[ItemInventoryAggregate](new ItemInventoryAggregate(id, name)) } ... override def updateState(evt: AggregateRoot.Event): Unit = evt match { case ItemsAddedToInventory(newItemsQty: Int) => if (newItemsQty > 0) { state = ItemQuantity(newItemsQty) context.become(created) state match { case s: ItemQuantity => state = s.copy(quantity = s.quantity + newItemsQty) case _ => //nothing } } case ItemAddedToCart => state match { case s: ItemQuantity => if (s.quantity > 0) state = s.copy(quantity = s.quantity - 1) case _ => //nothing } case ItemRemovedFromCart => state match { case s: ItemQuantity => state = s.copy(quantity = s.quantity + 1) case _ => //nothing } } ... I'm planning to use akka, spray/akka-http, akka-persistence, play2, cassandra-journal for implementing this. My understanding is that each of these components is quite performant and can be used to achieve the requirements I've outlined above. -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.