1
votes

I have a load balancer setup with two backend services. URL mapping on LB looks like:

site.com -> backend-blue
test.site.com -> backend-green

Both backend services have CDN enabled. I could see cache hit ratio around 96% on the backend-blue service. Then I switched backend services on LB:

site.com -> backend-green
test.site.com -> backend.blue

Cache hit on backend-green became 60% and I started getting 502 errors.

Cache keys remained the same, so I expected to see the same cache hit ratio around 95%.

Why cache entries have been evicted and requests went through LB instead of being served by CDN?

1

1 Answers

1
votes

The CDN cache is applied at the backendService level. https://cloud.google.com/compute/docs/reference/rest/v1/backendServices#BackendService.FIELDS.enable_cdn

The cache of the the green backend was empty when you switched the traffic to it.

To keep the cache, don't modify the URL map, but change the main backendService to use the green instanceGroup. https://cloud.google.com/compute/docs/reference/rest/v1/backendServices#BackendService.FIELDS.backend