What a server does all day
After today, you can walk through what the backend does with every request and explain the trade between one big program and many small services.
Dip your toes 1 min
The backend is the part of a product that runs on computers the company rents or runs, called servers, rather than on your phone. When you set a destination in Uber, your phone sends a request, and a server runs the same short routine it runs for every request. It checks who’s asking and whether the request makes sense, then applies Uber’s rules, like how surge pricing sets your fare. It saves what changed and sends back an answer. Big companies often split this work into many small programs, each run by its own team. That split shows up on your screens: if the program that estimates arrival times is slow, the trip card needs a state without one.
The full lesson 10 min
Why this exists
Open Uber, set a destination, and the app shows you a price before you confirm. In that second, your phone sent a request to Uber’s servers, and something there decided what your ride costs. The same thing happens when a driver accepts the trip, when you rate them, and when the receipt lands in your inbox. Each of those is a request, and each one gets its answer from the backend.
A server’s day is millions of those small jobs, one after another and many at once. Nobody writes a separate program for each one. The backend runs the same short routine on every request, with different rules plugged in. Once you can see that routine, the backend stops being a black box. You can point at the step where a bug lives, the step a feature changes, and the step that makes the product what it is.
Size is the other problem. A backend starts with a few engineers who all know every file. A company like Uber has thousands of engineers changing the backend at the same time. How a company divides that code decides who can ship without waiting on whom. It also decides what breaks when one piece goes wrong, and both of those end up on your screens.
What it is
Every request that reaches a server goes through roughly the same steps. Teams name them differently, but the order rarely changes. Here’s a simplified version of what Uber’s backend does when you ask for a price.
- Receive. The server takes in the request and works out which piece of code should handle it, by its endpoint.
- Who’s asking. It confirms the request comes from a signed-in rider and not a stranger. Day 17 covers how that works.
- Validate. Validation is checking that a request is complete and makes sense before acting on it. The pickup point has to be a real place, and the destination can’t be blank.
- Apply rules. The server runs the business logic, the rules that make the product behave the way it does. This is where the fare gets calculated and surge pricing kicks in.
- Read or write. It queries the database for what it needs and saves what changed, like the new trip.
- Respond. It sends back a response the app can show: a fare, a pickup time, or an error.
Business logic deserves a second look, because it’s the part your design work changes most. “Riders can cancel for free within two minutes” is business logic. Two more examples: a driver can’t accept two trips at once, and promotions don’t stack. When a product manager writes a new rule into a spec, it lands in step 4. Engineers sometimes call it domain logic.
Validation and business logic are easy to mix up. Validation asks whether a request is well formed: is the address real, is the pickup inside a service area. Business logic asks what should happen, given a valid request: what this trip costs at six on a rainy Friday. A request can pass validation and still be turned down by the rules. A perfectly valid ride request from a suspended account is one example.
The order of the steps is deliberate. The cheap checks come first, so a bad request gets turned away before it costs anything. Checking identity before validation means a stranger learns little about what a valid request looks like. And nothing touches the database until the rules have said yes. A bug report that says which step failed is already half diagnosed.
Now the bigger question: where does all this code live? A monolith is a backend built as one program, from one codebase, and deployed as a single unit. Every feature’s business logic sits side by side inside it. When the pricing code needs something from the trip code, it calls it directly, inside the same program, in far less than a millisecond.
Microservices split the backend into many small programs, called services, that each own one job and usually their own data. A pricing service calculates fares. A payments service charges cards. Services talk to each other over the network, with requests and responses like the ones your phone sends. Each one has its own team, its own code, and its own deploys.
In a 2020 engineering post, Uber said that around 2012 to 2013 its backend was mostly two monolithic services. By 2020 it ran around 2,200 critical microservices. The reasons it gave were mostly about people. One mistake in the shared code could take all of Uber down, and deploys were slow and painful. Teams couldn’t ship without waiting on each other.
Engineers have a name for this pattern, Conway’s law: a system’s structure ends up mirroring the teams that build it. When you look at a company’s list of services, you’re often looking at its org chart. A monolith is simpler to build, test, and understand as a whole. Microservices let big teams move in parallel and scale busy parts alone, at the cost of a system nobody can see whole.
Requests aren’t the whole day, either. A backend also runs scheduled work, like totaling each driver’s earnings at the end of the week. It also handles work that gets handed off to finish later, like sending the receipt after the trip ends. Day 18 covers that second kind. Both run the same business logic as the requests do, so a rule change reaches them too.
How it shows up in your work
Error messages come first, because every validation rule on the server is a state you might need to design. The frontend usually checks a form first, so the user gets instant feedback. The server checks again, because only the server’s check can be trusted. If the two sets of rules drift apart, users see a form that looks fine and then fails on submit. Ask for the server’s validation rules before you design a form’s errors, not after.
Scope shows up in planning. When an engineer says a change “touches three services,” hear three teams, three code reviews, and often three deploys that have to land in order. A small-looking change to the trip screen might need a new field from pricing, a change to the trip service, and an update to receipts. In a monolith, the same change might be one pull request. The architecture decides how many people need to be in the room.
Then there’s consistency across surfaces. Business logic on the backend is shared by every client: the rider app, the driver app, the website, and the tools support agents use. Change the cancellation rule once on the server, and every surface follows. That’s why engineers push to keep rules out of the apps, since a rule copied into the iPhone app is a bug waiting to happen. When you design a new surface, ask which existing rules it inherits for free.
The one thing people get wrong
A new engineer joins, opens the codebase, and sighs: “It’s a monolith.” The sigh assumes microservices are the modern way and a monolith is old code nobody has cleaned up yet. Neither part is true.
Splitting a program into services turns a call inside one program into a trip across the network. That trip can be slow, it can time out, and the service on the other end can be down. Inside a monolith, the parts can’t fail to reach each other in those ways.
Here the trip service needs a fare from pricing, an arrival time from maps, a check from payments, and a driver from matching. That’s a fan-out of four network hops, on top of the one from the phone. Each hop adds a little latency, and each one can fail on its own. If maps is slow, the trip service has to choose: wait, show the trip without an arrival time, or give up. Those choices reach the rider as loading, partial, and error states.
Uber’s own post describes the downside. Simple features came to need coordination across services owned by different teams. Tracking down the cause of one problem took engineers through about 50 services across 12 teams. Uber’s answer was to sort its services into about 70 domains, each with a single front door.
Shopify went the other way. In a 2019 post, it described its code as one of the largest Ruby on Rails codebases. It was turning that code into a modular monolith: one program with firm walls between its parts.
So the useful question isn’t which style is better. It’s how many teams need to change this code at once, and how much failure handling the product can afford. A ten-person startup and a company with thousands of engineers get different answers, and both can be right. There’s more here about how services find and call each other; you don’t need it yet.
Ask an engineer this
“If one of the services behind this screen went down, what would the user see, and which parts would keep working?”
Ask this about a screen you’re designing now, ideally one that pulls together several kinds of data. Expect the engineer to name the services behind the screen, or to say it’s all one backend. The next question is whether any piece is optional, meaning the screen can still show something useful without it. Each optional piece is a partial state to design, like a trip card with no arrival time yet. If the whole screen fails when one piece does, ask whether it should.
Terms from today
- Monolith
- A backend built as one program, from one codebase, and deployed as a single unit.
- Microservices
- A way of building a backend as many small programs, each owning one job and talking to the others over the network.
- Business logic
- The rules that make a product behave the way it does, like how a price is calculated or who can cancel for free.
- Validation
- Checking that a request is complete and makes sense before the server acts on it.