2

I am trying to add the lambda in the Auto-scaling target, and getting the error "No scalable resources found" while trying to fetch by tag.

Is it possible or allowed to add lambda to the auto-scaling target?

UPDATE: I am trying to figure out how to change the provisional concurrency during non-peak hours on the application that will help to save some cost so I was exploring the option of auto-scaling

Arpit
  • 521
  • 2
  • 8
  • 22

1 Answers1

7

Lambda automatically scales out for incoming requests, if all existing execution contexts (lambda instances) are busy. There is basically nothing you need to do here, except maybe set the maximum allowed concurrency if you want to throttle.

As a result of that, there is no integration with AutoScaling, but you can still use an Application Load Balancer to trigger your Lambda Function if that's what you're after.

If you're building a purely serverless application, you might want to look into the API Gateway instead of the ALB integration.


Update

Since you've clarified what you want to use auto scaling for, namely changing the provisioned concurrency of the function, there are ways to build something like that. Clément Duveau has mentioned a solution in the comments that I can get behind.

You can create a Lambda Function with two CloudWatch events triggers with Cron-Expressions. One for when you want to scale out and another one for when you want to scale in.

Inside the lambda function you can use the name of the rule that triggered the function to determine if you need to do a scale out or scale in. You can then use the PutFunctionConcurrency API-call through one of the SDKs mentioned at the bottom of the documentation to adjust the concurrency as you see fit.


Update 2

spmdc has mentioned an interesting blog post using application auto scaling to achieve this, I had missed that one - you might want to check it out, looks promising.

Maurice
  • 11,482
  • 2
  • 25
  • 45
  • I am trying to figure out how to change the provisional concurrency during non-peak hours on the application that will help to save some cost so I was exploring the option of auto-scaling – Arpit Jan 14 '21 at 07:47
  • 2
    Then you should use another lambda function, triggered on specific times, to interact with the API. – Clément Duveau Jan 14 '21 at 07:48
  • thanks, @ClémentDuveau can you please help with some example that shows the API to change the configuration of lambda or maybe the part in the documentation – Arpit Jan 14 '21 at 10:55
  • 1
    What you're going to want to use is the `PutFunctionConcurrency` [API-Call](https://docs.aws.amazon.com/de_de/lambda/latest/dg/API_PutFunctionConcurrency.html) - I'll update the answer to reflect the information you've added in the comments. – Maurice Jan 14 '21 at 11:00
  • @Arpit Is the function currently using Provisioned Concurrency during peak hours? Is there a particular requirement for using it? – John Rotenstein Jan 15 '21 at 01:39
  • Yes @JohnRotenstein, there is a requirement to add provisional concurrency in the function as it is written in java and it has a cold start time in 5ish secs which is slowing response during simulation of peak hours – Arpit Jan 15 '21 at 04:13
  • I think this blog post describes what you're after https://aws.amazon.com/blogs/compute/scheduling-aws-lambda-provisioned-concurrency-for-recurring-peak-usage/ – spmdc Feb 16 '21 at 14:42
  • @spmdc I complety missed that one, pretty cool - thanks for the link, I'll add it to the answer for reference :) – Maurice Feb 16 '21 at 20:23