Problem Definition
Design an inventory management service that exposes only one method called ReserveInventory. Additional requirements and constraints are the following:
- When the service starts working, each product has a certain inventory count associated with it. Reservation is successful when all products in the order have available (non-zero) inventory. If reservation is successful, inventory count for all products in the order should be decreased. If reservation is unsuccessful, inventory count for all products in the order should remain unchanged. Under no circumstances inventory count should become negative. Under no circumstances the service should allow to reserve more products than available.
- Assume that each customer buys only 1 item of each product in the order list. Don’t worry about refreshing inventory count.
- The system has 100M of products. Each product may have 0-100K items available in inventory. Customers may buy 1 - 100 products in a single order.
- Implement the service on top of an existing key-value NoSQL database that doesn’t support transactions and locking
- The system needs to be running in the cloud.
This document discusses/proposes the solution addressing the above problem. The Inventory management system includes 2 key process in the solution i.e., Order Intake Service and Inventory Update Service. The below pictures illustrate the solution for the problem and all pictures used in this document are self-explanatory.
1.DATA MODEL AND FLOW

2. SERVICE DESIGN
Order Intake Process
Customer initiates the order and OrderIntake process ensures the smooth transaction of creating order for the customer and also validates the criteria of no more than 100 products
in an order.
Inventory Update Service Inventory update service ensures the products availability and updating the Product Catalog Quantity
(PCQ) on successful transaction.

3. SERVICE DESIGN FLOW CHARTS
3.1

3.2

Note: This business logic is executed in AWS SWF Decider. Decider decides whether it can continue for order fulfilment or to cancel the order depending on product availability.
4. CLOUD DESIGN

- EC2-C4 HPC cluster is appropriate infrastructure for the given throughput/availability/concurrency requirements.
- ElasticCache with Redis is considered for faster and MVCC transactions on NoSQL. And it provides Optimistic Locking which allows multiple users to access the product catalog and order.
- Elastic Search provides indexing for smoother and faster accessibility of product catalog
- Assumed mongoDB as noSQL db. It does not have to be the same.
- AWS SWF (Simple Workflow) is considered for running product availability checking task for consistency and high performance
- Elasticbeans with Tomcat hosts the application services
5. DEVOPS

- Github, Jenkins and AWS ECS with Docker Hub are considered towards automated DevOps CI and CD.
- This picture shows the flow up to Test Environment. However, this will be replicated for PROD upon successful testing.
- Jmeter is considered for performance testing on the services.
- JIRA is considered for issue and task tracking purpose.