Lambda@Edge for A/B Testing Strategy in CloudFront | DevOps Exam Prep

Lambda@Edge for A/B Testing

Prev Question Next Question

Question

The DevOps team is using Lambda@Edge to perform the A/B testing strategy for a Web application.

By Lambda@Edge, logic can be added in the CloudFront CDN in order to choose which content to deliver without the need to touch the application code.

Two versions of application contents can be easily tested and analyzed.

Lambda functions can change CloudFront contents at below points:

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answer - B, C and D.

Refer to.

https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html https://medium.com/buildit/a-b-testing-on-aws-cloudfront-with-lambda-edge-a22dd82e9d12

for how Lambda works with CloudFront Lambda@Edge:

Option A is incorrect: Because CloudFront cache cannot be configured with a Lambda.

Option B, C and D are CORRECT: In this case, Lambda should be configured in Viewer request or Origin request or Origin Response to choose which version of application to route to.

Viewer Request : The function executes when CloudFront receives a request from a viewer, before it checks to see whether the requested object is in the edge cache.

Origin Request: The function executes only when CloudFront forwards a request to your origin.

When the requested object is in the edge cache, the function doesn't execute.

Origin Response : The function executes after CloudFront receives a response from the origin and before it caches the object in the response.

Note that the function executes even if an error is returned from the origin.

The function doesn't execute in the following cases:

• When the requested file is in the edge cache.

• When the response is generated from a function that was triggered by an origin request event.

Refer page 298 on the below link.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AmazonCloudFront_DevGuide.pdf

Option E is incorrect: Viewer response is the response which CloudFront forwards to the viewer.

They are not the points to decide which version to send the request to.

Lambda@Edge is a serverless compute service offered by AWS that allows running Lambda functions in response to CloudFront CDN events. This service helps to improve the performance and security of web applications by adding logic to the CDN edge locations.

A/B testing is a common technique used in DevOps to compare two versions of an application to determine which one performs better. By using Lambda@Edge, DevOps teams can perform A/B testing without touching the application code.

CloudFront CDN is a content delivery network that caches and delivers content to users from the edge locations closest to them. Lambda@Edge can change the content delivered by CloudFront at different points in the content delivery process:

A. CloudFront cache: Lambda@Edge can modify the content in the CloudFront cache before it's delivered to the viewer.

B. Viewer request: Lambda@Edge can modify the viewer's request before it's forwarded to the origin server.

C. Origin request: Lambda@Edge can modify the request sent to the origin server before it's processed.

D. Origin response: Lambda@Edge can modify the response received from the origin server before it's delivered to the viewer.

E. Viewer response: Lambda@Edge can modify the response delivered to the viewer after it's received from the origin server.

In the context of A/B testing, Lambda@Edge can be used to modify the content delivered to the viewer based on specific criteria, such as the user's geographic location or the device they're using. DevOps teams can use Lambda@Edge to compare two versions of an application and analyze the performance of each version to determine which one performs better.

In summary, Lambda@Edge can be used to perform A/B testing in a web application by modifying the content delivered by CloudFront at different points in the content delivery process, including the CloudFront cache, viewer request, origin request, origin response, and viewer response.