0%
April 4, 2024

More About Lambda Functions, Thottling, Concurrency, RDS-Proxy and Integration with CloudWatch Events

aws

Concurrency

Unreserved Concurrency
  • Free for all functions in .

  • If one function concumes all concurrency, the others will get throttled.

Reserved Concurrency
  • This is the number of containers allowed to run concurrently for a specific lambda function.

  • This number is taken away from the unreserved concurrency pool.

  • You can use reserved concurrency to minimize or maximize the processing rate.

  • By default, the maximum number of concurrency is set to 1000, but that doesn't mean you are allowed to spawn 1000 containers by default.

  • By default my applied account-level quota value is just 10.

  • To get the maximum number of concurrency we need to request it from:

  • Go to Monitor > Throttles, which counts the number of function invokation that is beyond the concurrency limit. If it is not intentionally done to rate limit an api endpoint, then any positive value is an alarm.

    For experiment, in this picture we have 3 counts beyond the concurrency limit (which is set to be 0).

  • We can also monitor the number of concurrent execution to adjust the configuration of max number of concurrency:

Provisioned Concurrency
  • As with reserved concurrency, it also subtracts from unreserved concurrency pool.

  • It is a pool of concurrency that is always on (for optimal latency).

  • Very Expensive.

  • It supports autoscaling group policies.

Database Proxies for RDS

  • Lambda functions are executed inside a container, and when concurrency reaches to some level, the database is unable to handle large amount of concurrent requests for new connections

  • RDS-Proxy helps minimize the number of requests for new connections unless it is necessary:

CloudWatch Events with Lambda

  • Choose CloudWatch and then choose Rules:

  • Give it a name and choose Schedule, we will be redirected to EventBridge Scheduler page:

  • Choose Recurring schedule and we are led to define a cron expression:

  • A list of templates and experiments on the cron expression:

  • Choose Lambda Invokation as a target and complete the invokation payload: