We have an issue in our production environment, maybe someone else has ran into this problem and has a smart solution.
Prerequisites:
- We use a load balancer in front of two front end servers.
- We use a CDN for delivering static assets such as CSS/JS/images.
- We fingerprint our JS/CSS files with checksum using SquishIt to provide cache busting
- We prepend asset path with CDN path on application start. This is also a SquishIt feature (.WithOutputBaseHref). Example:
/ui/main_465987ecb75.css
will be rendered like//cdn.host.com/ui/main_465987ecb75.css
Deployment routine:
- Take server1 off the load balancer.
- Make deploy to server1.
- Warm it up.
- Include server 1 in the load balancer.
- Take server2 off the load balancer (...and repeat steps 2-4)
And here's where it fails:
Between step 4 and 5 above, we have both servers online for a short period of time. During this time server1 could be referencing to main_46eb48ac968.css and server2 could be referencing the main_987eba4687.css. This will cause troubles in the following scenario...
Use case:
- User visits the site and end up on newly deployed server 1.
- Browser will request the main_46eb48ac968.css from the CDN.
- The CDN requests that file from the loadbalancer since it's not in its cache.
- The load balancer sends the CDNs request to server2.
- Server2 returs a 404 page not found error since the new file is only on server 1.
- Site looks like crap!
An easy fix would of course be to run without the CDN during deploy, but since CDN url is prepended to the paths during startup of the application we would have to restart the application in production... :/
Ideas?