D
D
Danya Kozlovskiy2022-01-23 04:32:27
go
Danya Kozlovskiy, 2022-01-23 04:32:27

How to organize the work of microservices in kafka?

Hello. There are three services that roughly speaking implement an online store:
1. Accepts a request and sends it to kafka.
2. Reads from kafka and is responsible for the goods.
3. Reads from kafka and is responsible for the user's wallet.
That is, when a request with the number and name of the goods the user needs arrives at service 1, then we go to service 3, take information about the goods, send them to service 2 and withdraw money from the user, and in conclusion we answer service 1 about the result.
There were questions about the organization of the work of services:
1. Is it necessary to synchronize the work of services here (i.e., execute requests one by one), because it is possible that users buy goods at the same time, and there is only enough of it in the warehouse for one user? And if so, how to implement it?
2. Have I built the communication algorithm between services described above correctly?
PS: Little is known about microservice architecture and Kafka.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2022-01-24
@morto

Why Kafka? Why microservices?

1. Accepts a request and sends it to kafka.
From whom does he receive and how? What is the response and how?
It is necessary to divide the online store into logical parts. Check which requests can be served synchronously and which can be served deferred (asynchronously).
When a product is low in stock, the user should be aware of it. You can also show product availability only if there are more than X units. And from the point of view of the DBMS, you can apply an optimistic write lock.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question