An AWS Lambda@Edge function, i.e. a function that runs on CloudFront edge servers to route new visitors of Hollowverse.com to different versions of the website for testing purposes.
This function works in conjunction with Release Manager. Release Manager implements all the logic for traffic splitting, and can work completely independently from this function.
However, putting CloudFront in front of Release Manager means that we can no longer do traffic splitting because Release Manger does not see new visitors, as CloudFront serves a cached version of the website to all users.
This function puts the environment assignment logic from Release Manager back on top of CloudFront. It picks one of the environments and sets the env
cookie accordingly at the "viewer request" stage of request processing (see the image below), before CloudFront checks the cache.
For the first time a specific page is requested, and provided that CloudFront is configured to cache different versions of a page based on the env
cookie, CloudFront will forward the request to Release Manager with the assigned env
cookie and Release Manager will read that cookie and respond with the correct version. CloudFront gets the response and caches it at the edge location.
If later requests get assigned to the same environment, CloudFront will find the requested page in the cache, and serve it without hitting the live Release Manager server.