0
0
GCPcloud~10 mins

HTTP(S) Load Balancer (Layer 7) in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - HTTP(S) Load Balancer (Layer 7)
Client sends HTTP(S) request
Load Balancer receives request
Inspect HTTP headers & URL path
Apply routing rules
Backend Service 1
Forward request to selected backend
Backend processes request and sends response
Load Balancer forwards response to client
The HTTP(S) Load Balancer receives client requests, inspects them at Layer 7 (HTTP level), applies routing rules based on headers or URL paths, forwards the request to the right backend, and returns the backend's response to the client.
Execution Sample
GCP
client -> Load Balancer -> Inspect HTTP headers
Load Balancer -> Route to backend based on URL path
Backend -> Process request -> Send response
Load Balancer -> Forward response to client
This flow shows how a client request is handled by the HTTP(S) Load Balancer, routed to the correct backend, and the response is sent back.
Process Table
StepActionInputDecision/ResultOutput
1Client sends HTTP requestGET /images/cat.jpgRequest received by Load BalancerRequest with URL /images/cat.jpg
2Load Balancer inspects URL path/images/cat.jpgMatches path rule /images/*Route to Backend Service 1
3Forward request to Backend Service 1Request with /images/cat.jpgBackend Service 1 processes requestResponse with image data
4Load Balancer receives backend responseImage dataPrepare response for clientResponse ready
5Load Balancer sends response to clientResponse readyClient receives imageClient displays image
6Client sends HTTP requestGET /api/dataRequest received by Load BalancerRequest with URL /api/data
7Load Balancer inspects URL path/api/dataMatches path rule /api/*Route to Backend Service 2
8Forward request to Backend Service 2Request with /api/dataBackend Service 2 processes requestResponse with JSON data
9Load Balancer receives backend responseJSON dataPrepare response for clientResponse ready
10Load Balancer sends response to clientResponse readyClient receives JSONClient processes data
11Client sends HTTP requestGET /unknownRequest received by Load BalancerRequest with URL /unknown
12Load Balancer inspects URL path/unknownNo matching path ruleRoute to default backend
13Forward request to default backendRequest with /unknownDefault backend processes requestResponse with 404 Not Found
14Load Balancer receives backend response404 Not FoundPrepare response for clientResponse ready
15Load Balancer sends response to clientResponse readyClient receives 404Client shows error
16No more requestsN/AEnd of executionLoad Balancer idle
💡 Execution stops when no more client requests are sent.
Status Tracker
VariableStartAfter Step 2After Step 7After Step 12Final
Request URLN/A/images/cat.jpg/api/data/unknownN/A
Selected BackendN/ABackend Service 1Backend Service 2Default BackendN/A
Response StatusN/A200 OK200 OK404 Not FoundN/A
Key Moments - 3 Insights
Why does the Load Balancer choose Backend Service 1 for the URL /images/cat.jpg?
Because at step 2 in the execution table, the Load Balancer inspects the URL path and finds it matches the path rule /images/*, which routes to Backend Service 1.
What happens if the URL path does not match any routing rule?
As shown at step 12, if no path rule matches, the Load Balancer routes the request to the default backend, which may return a 404 Not Found response.
How does the Load Balancer handle the backend response before sending it to the client?
At steps 4, 9, and 14, the Load Balancer prepares the backend response and then forwards it to the client without modifying the content.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, which backend service handles the request for /api/data?
ABackend Service 1
BBackend Service 2
CDefault Backend
DLoad Balancer itself
💡 Hint
Check step 7 and 8 in the execution table where the URL /api/data is routed.
At which step does the Load Balancer decide to route to the default backend?
AStep 2
BStep 7
CStep 12
DStep 15
💡 Hint
Look for the step where the URL path /unknown is inspected and no matching rule is found.
If the client sends a request to /images/dog.jpg, which backend will the Load Balancer route to?
ABackend Service 1
BBackend Service 2
CDefault Backend
DNo backend, request is dropped
💡 Hint
Refer to the routing rule for /images/* shown in the execution table at step 2.
Concept Snapshot
HTTP(S) Load Balancer (Layer 7):
- Receives client HTTP(S) requests
- Inspects HTTP headers and URL paths
- Routes requests based on rules (e.g., URL path)
- Forwards requests to appropriate backend services
- Returns backend responses to clients
- Supports default backend if no rule matches
Full Transcript
The HTTP(S) Load Balancer works by receiving client requests and inspecting them at the HTTP level. It looks at the URL path or headers to decide which backend service should handle the request. For example, requests to /images/* go to Backend Service 1, while /api/* go to Backend Service 2. If no rule matches, the request goes to a default backend which may return a 404 error. The Load Balancer forwards the backend's response back to the client. This process repeats for each client request, ensuring efficient routing and response delivery.