Home > Blockchain >  How does AWS Lambda AWS Websocket API work under the hood?
How does AWS Lambda AWS Websocket API work under the hood?

Time:02-16

I know it invokes different Lambda instances for different routes (like connect, disconnect, default, etc) on the Websocket API. But what happens for different messages on the same route, does it keep the Lambda instance running for new messages until disconnect?

Let's say, I am building a login form with 2FA. I take username, password and process it, and then I want the 2FA code from client. Can I do this with a single Lambda instance?

CodePudding user response:

As commenter deceze wrote:

You can never assume that a single Lambda instance will process a request.

The point of serverless is that you don not manage the servers. Amazon does. And they can and will start new instances of your Lambda, terminate existing instances etc.

So if you need "cross invocation persistence", you need to solve this in a different way. One common way is to use DynamoDB or depending on the use cases ElastiCache, S3, EFS etc.

  • Related