0
0
GCPcloud~10 mins

Cloud CDN integration in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Cloud CDN integration
Create Backend Service
Enable Cloud CDN on Backend
Create URL Map
Create Target HTTP(S) Proxy
Create Global Forwarding Rule
Client Requests -> CDN Cache
Cache Hit?
YesServe from Cache
No
Fetch from Backend
Cache Response
Serve to Client
This flow shows how to set up Cloud CDN with a backend service and how client requests are served from cache or backend.
Execution Sample
GCP
gcloud compute backend-services create my-backend \
  --protocol HTTP --port-name http --global

gcloud compute backend-services update my-backend \
  --enable-cdn --global

gcloud compute url-maps create my-map \
  --default-service my-backend

gcloud compute target-http-proxies create my-proxy \
  --url-map my-map

gcloud compute forwarding-rules create my-rule \
  --global --target-http-proxy my-proxy --ports 80
This code creates a backend service, enables Cloud CDN, sets up URL map, proxy, and forwarding rule to serve cached content globally.
Process Table
StepActionResource Created/UpdatedEffectNext Step
1Create backend serviceBackend Service 'my-backend'Backend ready to serve HTTPEnable CDN on backend
2Enable CDNBackend Service 'my-backend'CDN caching enabledCreate URL map
3Create URL mapURL Map 'my-map'Routes requests to backendCreate target HTTP proxy
4Create target HTTP proxyTarget HTTP Proxy 'my-proxy'Handles HTTP requestsCreate forwarding rule
5Create global forwarding ruleForwarding Rule 'my-rule'Listens on port 80 globallyReady to serve requests
6Client sends requestRequest receivedCheck cache for contentCache hit?
7Cache hitServe cached contentFast response from CDNEnd
8Cache missFetch from backendBackend serves contentCache response and serve
9Cache responseContent cachedFuture requests fasterServe to client
10Serve to clientResponse sentClient receives contentEnd
💡 Execution stops after serving client content either from cache or backend.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7/8After Step 9Final
Backend ServiceNoneCreatedCDN EnabledCDN EnabledCDN EnabledCDN EnabledCDN EnabledCDN EnabledCDN EnabledCDN Enabled
URL MapNoneNoneNoneCreatedCreatedCreatedCreatedCreatedCreatedCreated
Target HTTP ProxyNoneNoneNoneNoneCreatedCreatedCreatedCreatedCreatedCreated
Forwarding RuleNoneNoneNoneNoneNoneCreatedCreatedCreatedCreatedCreated
Cache StatusEmptyEmptyEmptyEmptyEmptyEmptyCheck CacheHit or MissUpdated if MissHit or Miss
Client ResponseNoneNoneNoneNoneNoneNoneWaitingFrom Cache or BackendFrom Cache or BackendSent
Key Moments - 3 Insights
Why do we enable CDN after creating the backend service and not before?
Because the backend service must exist first to enable CDN on it. See execution_table rows 1 and 2 where backend is created first, then CDN is enabled.
What happens when a client request results in a cache miss?
The request goes to the backend service to fetch content, which is then cached for future requests. This is shown in execution_table rows 8 and 9.
Why do we need a URL map and target HTTP proxy in this setup?
The URL map directs requests to the backend service, and the target HTTP proxy handles incoming HTTP requests globally. This routing setup is essential before creating the forwarding rule (rows 3 and 4).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step is Cloud CDN enabled on the backend service?
AStep 1
BStep 2
CStep 3
DStep 5
💡 Hint
Check the 'Action' and 'Effect' columns in execution_table row 2.
According to variable_tracker, what is the cache status after step 7?
AEmpty
BCheck Cache
CHit or Miss
DUpdated if Miss
💡 Hint
Look at the 'Cache Status' row and the column 'After Step 7/8' in variable_tracker.
If the forwarding rule was not created, what would be the impact on serving client requests?
ARequests would still be served from cache
BRequests would be routed directly to backend without caching
CRequests would not reach the proxy and fail
DRequests would be served from a different region
💡 Hint
Refer to execution_table row 5 and the role of forwarding rules in routing.
Concept Snapshot
Cloud CDN integration steps:
1. Create backend service.
2. Enable CDN on backend.
3. Create URL map to route requests.
4. Create target HTTP proxy.
5. Create global forwarding rule.
Client requests hit CDN cache first; cache miss fetches from backend.
Full Transcript
This visual execution trace shows how to integrate Cloud CDN with a backend service on Google Cloud Platform. First, a backend service is created to serve HTTP traffic. Then, Cloud CDN is enabled on this backend to cache content globally. A URL map is created to route incoming requests to the backend service. Next, a target HTTP proxy is set up to handle HTTP requests using the URL map. A global forwarding rule listens on port 80 and directs client requests to the proxy. When a client sends a request, the CDN cache is checked. If the content is cached (cache hit), it is served immediately, providing fast response. If not cached (cache miss), the request goes to the backend service, which serves the content and caches it for future requests. This setup improves performance by serving content closer to users worldwide. Variables like backend service status, URL map, proxy, forwarding rule, cache status, and client response change step-by-step as the setup progresses and requests are handled.