Skip to content

How to create a 30min timer for each session under serverless

0

Hi all, I am a beginner in serverless. My project requires creating a 30-minute timer for each user's session. How should I implement this in a serverless architecture? Thank you.

I have tried chaining lambda functions, but there is a large margin of error and it's very troublesome. Step functions also require chaining.

asked 2 years ago328 views
2 Answers
0

Use EventBridge Scheduler. When you have a new user session create a schedule for 30 minutes from now. When it fires, invoke a Lambda that clears the session.

AWS
EXPERT
answered 2 years ago
AWS
EXPERT
reviewed 2 years ago
0

I second the solution provided by Uri of using EventBridge Scheduler. I would like to add in addition you can maintain user session in DynamoDB. When the user starts a new session, create a record in DynamoDB table with appropriate startTime, expirationTime , userId, sessionId values. When the user ends the session or when the session expires, you can delete the corresponding record from the table.

AWS
EXPERT
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.