Skip to content
Cloud Efficiency Hub

Recursive Lambda Function Invocation

Explanation

Recursive invocation occurs when a Lambda function triggers itself directly or indirectly, often through an event source like SQS, SNS, or another Lambda. This loop can be unintentional - for example, when the function writes output to a queue it also consumes. Without controls, this can lead to runaway invocations, dramatically increasing cost with no business value.

Relevant Billing Model

* Billed per request and per millisecond of execution time * Recursive invocations amplify both request count and total execution duration

Detection

  • Review Lambda functions for high and sustained invocation rates with no matching business activity
  • Review event source and destination configurations for circular references (e.g., writing back to a triggering SQS queue)
  • Check CloudWatch Logs for repetitive invocation patterns with identical payloads
  • Correlate Lambda cost spikes with recent deployments or configuration changes
  • Assess if DLQs or concurrency limits are missing from functions with self-trigger patterns

Remediation

  • Refactor logic to prevent self-invocation or recursive event loops
  • Avoid writing to the same queue or stream that triggers the function
  • Implement Dead Letter Queues to prevent retry loops
  • Set concurrency limits using `ReservedConcurrency` or `MaximumRetryAttempts`
  • Utilize anomaly detection software to flag unusual invocation or cost patterns
  • Monitor function triggers and outputs as part of deployment validation