AWS Lambda - Traffic Shift
We all know what is AWS Lambda which is a serverless architecture. In this blog, we will discuss on what is lambda alias and how it can be used shift traffic between 2 version of AWS lambda.
What is lambda versioning?
AWS Lambda versions
are immutable snapshots of your function’s code and configuration at a
specific point in time.
An immutable snapshot
is a frozen, unchangeable copy of something at a specific point in time.
Immutable = cannot be
changed
Snapshot = point-in-time copy
Lets start by creating a simple lambda function with nodejs as runtime environment.
I updated the code as below:
Let's publish this version of lambda function as "Version-1".
Now, we have our function looks like:
demo-function -> Version-1
Let's update the demo-function with the below content.
Publishing this version as "Version-2".
Now, our lambda "demo-function" has 2 versions.
demo-function -> Version-1
-> Version-2
Let see how to route traffic between 2 different lambda version using lambda alias.
An alias is a pointer to
one or two versions. Choose each version that you want the alias to point to.
Once we create alias, it creates alias function which routes 50%-50% traffic between Version-1 and Version-2.
Let’s invoke the lambda
functions and see the result.
We could see the traffic split between 2 versions of lambda functions.
Comments
Post a Comment