Request Lifecycle
Lesson 6Beginner1h 12mAssessment-backed

Request Lifecycle

Follow a request from client to edge, gateway, service, cache, database, queue, observability, and response.

What you will be able to do

Trace the full lifecycle of a production request.
Identify where authentication, authorization, validation, routing, caching, and persistence happen.
Separate synchronous request work from background work.
Understand timeout, retry, correlation ID, and observability basics.
Map request lifecycle pieces to AWS, GCP, and Azure services.

A request is not just a function call. In production it crosses clients, networks, edge layers, gateways, services, caches, databases, queues, and monitoring systems.

Request Path Overview

When a user taps a button, the system must authenticate the caller, validate the request, route it to the right service, perform the needed work, record observability data, and return a response quickly enough for the product experience.

Production request lifecycle from client through edge gateway service cache database and queue
A single user action can touch many system layers before the client receives a response.
StageWhat happensCommon risk
ClientBuilds request and handles loading/error statesRetries can create duplicates if write API is not idempotent.
Edge/CDNTerminates TLS, caches static or cacheable responsesIncorrect caching can expose stale or private data.
Gateway/load balancerRoutes traffic and applies policiesNo rate limit or weak auth can overload services.
ServiceValidates, authorizes, executes business logicToo much work in the synchronous path increases latency.
Data layerReads/writes durable stateBad indexes or locks slow the request.
QueueDefers background workMissing retry/DLQ causes silent data loss.
ObservabilityRecords metrics, logs, tracesNo correlation ID makes incidents hard to debug.

Scenario: User Uploads a Profile Photo

A profile photo upload appears simple. But a production request may validate file type, authorize the user, store the original image, enqueue thumbnail generation, update the user profile, and return a URL.

StepSynchronous or async?Reason
Authenticate userSynchronousNeed to know who is uploading.
Validate file metadataSynchronousReject unsafe or oversized files early.
Store original imageSynchronous or direct-to-object-storageNeed durable object before success.
Generate thumbnailsAsyncCPU work should not block the user.
Update profile recordSynchronousUser should see new avatar state.
Scan image for policy/securityAsync or gated depending on productTrade-off between speed and safety.

Timeouts, Retries, and Idempotency

Networks fail. Services slow down. Clients retry. A production request lifecycle must define timeouts and retry behavior so the system does not accidentally duplicate writes or overload itself.

ConceptBeginner meaningExample
TimeoutMaximum time caller waitsGateway times out after 10 seconds.
RetryTry again after failureClient retries a safe read after network failure.
IdempotencySame request can be repeated safelySame upload session ID should not create many profile records.
Correlation IDID carried through logs/tracesDebug one failed checkout across gateway, service, and database.
BackoffWait longer between retriesAvoids retry storms when a service is already overloaded.

Design principle

Keep the synchronous request path as small as the product allows. Move slow, retryable, or fanout work into background processing.

Cloud Request Lifecycle

LayerAWSGCPAzure
Edge/CDNCloudFrontCloud CDNAzure Front Door/CDN
API entryAPI Gateway/ALBAPI Gateway/Cloud Load BalancingAPI Management/Application Gateway
ComputeLambda/ECS/EKSCloud Run/Cloud Functions/GKEFunctions/Container Apps/AKS
Object storageS3Cloud StorageBlob Storage
QueueSQS/EventBridgePub/Sub/Cloud TasksService Bus/Event Grid
TracingX-Ray/CloudWatchCloud Trace/Cloud MonitoringApplication Insights/Azure Monitor

What to Observe

A request lifecycle is only production-ready if engineers can understand it during normal operation and during incidents.

SignalWhat it tells you
Request rateHow much traffic is entering the system.
Error rateWhich flows are failing and how often.
Latency percentilesWhether users are seeing slow responses.
Dependency latencyWhether database, cache, or external provider is slowing the request.
Queue depthWhether async workers are keeping up.
Trace spansWhere time is spent across services.

Beginner Mistakes

  • Putting image processing, email delivery, and analytics inside the user-facing request path.
  • Retrying write requests without idempotency.
  • Ignoring correlation IDs and then being unable to debug production failures.
  • Caching private or user-specific responses incorrectly.
  • Assuming the database is the only place a request can fail.

Guided Practice

Practice task

Trace the request lifecycle for submitting a comment on a blog post. Identify what must happen before response and what can happen after response.

Sample Answer

Before responseAfter response
Authenticate userSend notification to post author
Validate comment textUpdate search index
Authorize access to postUpdate analytics counters
Store comment durablyRun moderation enrichment if not blocking
Return commentId and createdAtFan out feed/inbox updates if needed

Before You Continue

  • You should be able to trace a request across system layers.
  • You should know why sync paths should stay small.
  • You should understand timeout, retry, idempotency, and correlation ID basics.
  • You should be ready to decide where service boundaries belong.