1
votes

We are running the C# asp.net core application using AWS Lambda service.

To run some calculation we used to call an API method of our app. However, now we need to do it automatically. It means that we need to run a scheduled task (or several separate tasks in the future) each minute. There is a mandatory condition that only one instance of the task should be running simultaneously. In case of a standard service or container, we could use a 3rd party library such as Hangfire or Quartz. However, in the case of Lambda, they can be run stable because of two reasons:

  1. Several Lambdas can start the same task at once.
  2. Lambdas can be in sleep mode when we need to run the task.

Is there any way to solve my issue with AWS services?

Probably we can schedule a job which will call one of our method which will run the task (but in this case, how can we prevent to call this method out of our infrastructure?)

Or can we configure LambdaEntryPoint in our code in some way to solve it?

2

2 Answers

2
votes

If I understand your task, you need two things.

  1. Schedule a Lambda to be run every minute: we can schedule this in cloudwatch event rule

  2. Avoid more than 1 instance of Lambda to be run at the same time. we can set concurrency limit , not the provisioned concurrency but the reserved concurrency on Lambda as 1.

enter image description here

0
votes

After a lot of research, I've come to a solution to run the scheduled tasks in a separate stable server which is EC2 in my case. Lambda's purpose is different: it should be used as a trigger to some external event, handle this event, and go to hibernate again. Background tasks are outside of this area