Storage
Network
// Customer order management
POST /orders -> Order
GET /orders/
GET /orders&q={filters}&pageSize={}&pageToken={}
// Business order management
GET /orders/
GET /orders&q={filters}&pageSize{}&pageToken={}
PATCH /orders/
Customer table
Business table
Order table
Item table
OrderUpdate table
ClientCustomer and ClientBusiness
APIGateway
OrderService
UpdateService
NotificationQueue and NotificationService
OrderDB
Customer flows
Create
Search/view
Business flows
NotificationService
NotificationQueue
OrderService, UpdateService and DB
ElasticSearch
Separation of OrderService and UpdateService
OrderService, UpdateService and NotificationService (w/o webhook) are stateless, and can be scaled horizontally.
With 200TB and 800 read and write qps separately, we can shard the database, based on order id. Say we create 4 shards of 50TB each.
We should also have a background process that moves older orders to cold storage so data doesn't accumulate indefinitely, if we don't want to add more data storage for DB.
The the update queue, we are looking at ~800 message/sec, with each message ~200B (or 160KB / sec). This is well within the limit of 1 kafka queue and there is no need to partition the queues.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?