python - Costs related to AWS Lambda retrying failing function? -
i'm looking serverless technology (specifically, python, django , zappa on aws lambda) , 1 thing error handling struck me. in zappa docs says
by default, aws lambda attempt retry event based (non-api gateway, e.g. cloudwatch) invocation if exception has been thrown.
in aws lambda documentation, read:
depending on event source, aws lambda may retry failed lambda function. example, if kinesis event source, aws lambda retry failed invocation until lambda function succeeds or records in stream expire.
does mean function called infinite number of times when raises unhandled exception? if goes on unchecked, costs must go through roof.
related that; meant "until records in stream expire"? records, , stream?
according aws docs:
event sources aren't stream-based: s3, api gateway, etc.
synchronous invocation: if have invoked lambda using sdk or api gateway, if exception occurs, responsible decide if/when/how request should retried.
asynchronous invocation: if lambda triggered through async invocation (like s3), automatically retry invocation twice, delays between retries. if have specified dead letter queue, failed event sent sqs/sns. if dlq not specified, event discarded.
stream-based event sources: dynamodb , kinesis.
- if lambda function fails, continue try until data expires (max of 7 days kinesis). retries following exponential backoff ceiling of 1 minute between 2 retries. pay retries, can create alert trigger , stop stream when source offline.
the documentation regarding stream-based event source not accurated, can read this thread in aws forums aws employee has answered question this:
question:
specifically, when lambda getting kinesis events , writing data service... other service goes down period of time (e.g., few hours)... lambda going keep getting called (and throwing errors) @ constant rate?
lambda retry because want guaranteed delivery of events, ideally in situation, don't want billed @ high rate when lambda becomes consistently unsuccessful time
answer:
if function starts executing fails because of downstream dependency, billed duration function ran. lambda exponentially backs off in case function fails, 1 minute. can monitor sharditeratorage increases, , take action pause stream processing if needed till resolve downstream dependency
Comments
Post a Comment