Client-Server in Real Projects
What the system looks like when there are many clients: a load balancer, several backends and databases, a monolith and microservices.
About the product
Hi! You already know how the client, the server and the database exchange requests. Today let’s see what this setup looks like in big projects.
In the trainers there was one client and one server. Is it the same in real projects?
Good question! In the trainers we looked at the simplest setup: one client, one server and one database. That makes it easier to see how requests travel.
In reality there are far more clients: hundreds of shoppers visit BB Food at the same time, from laptops, phones and tablets. And they all send requests to the same server.
And what if there are lots of shoppers? Will the server cope?
A single one won’t. Every server has a limit: when there are too many requests, it slows down and then starts answering 503 Service Unavailable. Remember that code?
That’s why the backend runs as several copies on different servers. So that clients don’t have to choose where to knock, a load balancer is put in front of the servers. It receives all the requests and hands them out to the servers in turn, so none of them gets overloaded.
This is called horizontal scaling. Usually the first try is vertical scaling — simply putting in a more powerful server. But power has a ceiling, and when that is no longer enough, more servers are added alongside.
When the data and requests grow even further, one database isn’t enough either. Then there are several: for example, the primary one takes writes, and its copies (replicas) answer reads.
This matters for a tester: the same request can land on different servers. If a bug shows up only “every other time”, maybe one of the servers runs an old version of the code, or a replica hasn’t received the fresh data yet.
Let’s check. Why have several backends at all?
Why is a load balancer put in front of the backends?
The server stopped coping, so it was given more memory and processors. What is this called?
Do the frontend and backend always live separately?
Not always. There’s the monolith: the frontend and backend are built as one application. All the code lives in one project and is released as a whole — the catalogue, cart and payment live together.
Projects often start as a monolith: while the team is small, it’s quicker and simpler. But as the project grows, the monolith gets awkward: a small fix in payment means releasing the whole application, and one error can bring the whole shop down. Then it gets gradually split up into parts.
That’s how you get a microservice architecture: the frontend is separate, and the backend is split into small services — catalogue, cart, payment, delivery. Each has its own job and often its own database, and they talk to each other through APIs too. This is what you’ll meet most often today: services can be changed, released and scaled independently, and different teams work in parallel.
Let’s check. A bug was found in payment, and the developer fixed one line. In which architecture does this mean releasing the whole application?
In a microservice shop, the delivery service went down. What will a shopper most likely see?
Great! All that’s left is the final check on the whole Client-Server series.
Quick reference
Scaling
When there are many clients, the backend runs as several copies, and a load balancer hands requests to them in turn. There can be several databases too: the primary takes writes, replicas answer reads.
Monolith and microservices
A monolith is the frontend and backend in one application released as a whole; projects often start with one. Microservices split the backend into small independent services that talk through APIs. This is what you’ll meet most often today.