~

Backend Thinking

Backend Role

Transform business requirements to action, which usually involves:

After successfully do all of that, next step is:

In ZaloPay, each team has its own responsibilites/domains, aka many different services.

Ideally each team can choose custom backend techstack if they want, but mostly boils down to Java or Go. Some teams use Python for scripting, data processing, ...

Example: UM (Team User Management Core) has 10+ Java services and 30+ Go services.

The question is for each new business requirements, what should we do:

Example: Business requirements says: Must match/compare user EKYC data with Bank data (name, dob, id, ...). TODO

TODO: How to split services?

Technical side

How do services communicate with each other?

API

First is through API, this is the direct way, you send a request then you wait for response.

HTTP: GET/POST/...

Example: TODO use curl

GRPC: use proto file as constract.

Example: TODO: show sample proto file

There are no hard rules on how to design APIs, only some best practices, like REST API, ...

Correct answer will always be: "It depends". Depends on:

Why do we use HTTP for Client-Server and GRPC for Server-Server?

References

Message Broker

Second way is by Message Broker, the most well known is Kafka.

Main idea is decoupling.

Imaging service A need to call services B, C, D, E after doing some action, but B just died. We must handle B errors gracefully if B is not that important (not affect main flow of A). Imaging not only B, but multi B, like B1, B2, B3, ... Bn, this is so depressed to continue.

Message Broker is a way to detach B from A.

Dumb exaplain be like: each time A do something, A produces message to Message Broker, than A forgets about it. Then all B1, B2 can consume A's message if they want and do something with it, A does not know and does not need to know about it.

References

My own experiences:

Pro tip: Use proto to define models (if you can) to take advantage of detecting breaking changes.

Coding principle

Known concept

TODO:

Challenge

TODO: Scale problem

Damage control

TODO: Take care incident

Bonus

TODO

Draft

single point of failure ownership, debugging

Feel free to ask me via email or Mastodon.
Source code is available on GitHub Codeberg sourcehut Treehouse GitLab