Architecture / 1 / 4
Microservices
An online bookshop starts as one app and one database. When does splitting it into services help, what does each split cost, and where does an API gateway fit.
- 13 min
- Intermediate
- 10 steps
- Deploys
- 0.1 /day
- Request p95
- 140 ms
- Services per order
- 1
- Failed requests
- 0.3 %
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
Shop app → Shop DBRequest
BEGIN;1
UPDATE books SET stock = stock - 1
WHERE id = 'b_77';
INSERT INTO orders (id, user_id, book_id)
VALUES (9001, 'u_42', 'b_77');
INSERT INTO payments (order_id, amount)2
VALUES (9001, 89000);
COMMIT;3
BEGIN— Start of one local transaction. The database guarantees all-or-nothing for free.payments— Payments are just another table in the same database. Remember this; it will not stay that way.COMMIT— Stock, order and payment become visible together, at one moment.
Course: 42 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes