Backend

On this page 7

The backend is the server-side part of a web application: the code, services and data stores that run outside the user’s browser and decide what the application actually does. In web architecture, the backend receives requests, applies business rules, reads and writes data, and returns responses, either as finished HTML pages or as structured data for the frontend.

The boundary between backend and frontend is a trust boundary. Anything running in the browser can be inspected and modified by the user, so authoritative decisions about identity, permissions, prices and stored data belong on the backend. The term covers a single server process as well as a fleet of services, queues and databases.

What the backend does in a web application

A backend turns an incoming HTTP request into a trustworthy result. It authenticates the caller, checks what that caller may do, validates input, runs domain logic and persists the outcome. The response is then rendered as HTML or serialized as JSON and sent back through the network.

The table below lists the core responsibilities that almost every backend carries, regardless of language or framework.

ResponsibilityWhat it coversTypical building blocks
Routing and APIMapping URLs and methods to handlersREST endpoints, GraphQL resolvers, RPC services
AuthenticationProving who the caller isSessions, OAuth 2.0, OpenID Connect, tokens
AuthorizationDeciding what the caller may doRoles, policies, ownership checks
Business logicRules of the domainPricing, workflows, calculations
PersistenceStoring and querying dataRelational databases, document stores, object storage
IntegrationTalking to other systemsPayment gateways, email services, message queues
Background workTasks outside the request cycleJob queues, schedulers, workers
Core responsibilities of a backend

Layers and components of a backend

Behind a single domain name, a production backend is usually a chain of layers, each with a narrow role. Requests pass through edge services before reaching application code, and the application relies on storage and caching below it.

  1. Edge layer: DNS, CDN, TLS termination and a reverse proxy or load balancer distribute traffic and filter abuse.
  2. Application layer: stateless processes run the framework code, ideally so that any instance can serve any request.
  3. Cache layer: in-memory stores keep frequently read data close to the application and cut database load.
  4. Data layer: databases provide durability and transactions; their consistency guarantees shape what the application can promise.
  5. Asynchronous layer: queues and workers handle slow tasks such as image processing or sending email.

Keeping the application layer stateless is the key to horizontal scaling. Session data, uploads and locks move to shared stores, so new instances can be added or removed without losing user state.

Backend compared with frontend and full stack

Backend, frontend and full stack describe where code runs and who owns it, not a quality level. The comparison clarifies how responsibilities split in a typical web project.

AspectBackendFrontendFull stack
Runs onServers, containers, serverless platformsThe user’s browserBoth
Trust levelTrusted environmentUntrusted, user-controlledMust respect both
Main concernsData integrity, security, scalabilityUsability, rendering, accessibilityEnd-to-end feature delivery
Typical languagesJava, C#, Go, Python, PHP, JavaScriptHTML, CSS, JavaScript, TypeScriptA combination
Failure impactAffects all users and stored dataUsually affects one sessionVaries
Backend, frontend and full stack roles

In a headless architecture, the backend exposes content or commerce data only through APIs, and one or more frontends consume it. The backend-for-frontend (BFF) pattern adds a thin server layer per client type, shaping API responses for the web or a mobile app without bloating the core services.

Architectural styles and how to choose

There is no universally best backend style; the right choice follows team size, traffic profile and the rate of change. Splitting a system too early often creates more coordination cost than it removes.

StyleStrengthMain costGood fit
MonolithSimple deployment and debuggingCoupling grows with sizeSmall to mid-size teams and products
Modular monolithClear boundaries in one deployableRequires disciplineGrowing products not ready to split
MicroservicesIndependent scaling and releasesNetwork failures, distributed dataMany teams with separate domains
Serverless functionsNo server management, pay per useCold starts, execution time limitsEvent-driven or spiky workloads
Common backend architectural styles

Latency targets also guide design. Many teams aim for server response times under about 200 ms for interactive requests, because Time to First Byte feeds directly into page load metrics. Slow operations should move to background jobs with status updates rather than blocking the request.

Common backend risks and mistakes

Most serious backend incidents come from a small set of recurring mistakes. Security issues dominate because the backend guards the data of every user at once.

MistakeConsequenceRemedy
Trusting client-side validationManipulated requests change dataValidate and authorize every request on the server
Building SQL from stringsSQL injectionParameterized queries or a safe query builder
N+1 database queriesSlow pages under loadBatch loading and query review
Secrets in source codeCredential leaksSecret managers and environment injection
No timeouts on external callsCascading outagesTimeouts, retries with backoff, circuit breakers
Frequent backend mistakes and remedies

In plain words

Think of a restaurant. The dining room, the menu and the waiter are the frontend: what guests see and touch. The kitchen, the pantry and the cash register in the back office are the backend: where the real work happens and where the records are kept.

Guests never walk into the kitchen, and they cannot change the bill themselves. In the same way, the backend makes the decisions that users must not control, such as who is logged in, what something costs and what is saved.

A real-world example

A mid-sized online bookstore runs its backend as a modular monolith behind a load balancer, with a relational database for orders and an in-memory cache for the catalog. During a seasonal sale, traffic rises to about ten times the normal level.

Because the application instances are stateless, the operations team adds instances within minutes. Catalog reads are served mostly from the cache, and order confirmation emails move to a background job queue, so checkout requests stay fast. The payment provider is called with a strict timeout and a retry policy. The sale completes without downtime, and no order is lost even when the email service briefly fails.