I have Lambda subscribed to SNS topic and having concurrency limit set to 5.
Once 20 SNS messages are pushed, Lambda will run 5 instances and process first 5 SNS messages, that is totally ok. According to docs, other messages will be considered throttled and sent to retry. Again seems like expected behavior.
At this stage I have CloudWatch logs for 5 lambda instances with 1 message processed by each one. Still ok.
Once retry time comes I see those 5 instances further processing another messages, however now each of 5 lambda instances has about 8 processed messages (should have about 4 to result in total 20 messages processed by 5 instances). Instances processed some retried messages twice, both time successfully and under different request ID's.
It seems like sometimes SNS messages can be delivered twice, but given numbers above, it looks like nearly every message is delivered and processed twice.
Can these somehow be avoided?
Lambda concurrency is limited to 5 just because if I push 500 messages it will fire 500 instances and bring my RDS down as lambda creates connection.
So question again - why are retried messages processed twice if first processing ended successfully. Also detecting duplicates is hard because they are processed by different instances each time