3
votes

Is AWS Lambda CloudWatch logging synchronous?

AWS recommends that AWS Lambda should log to CloudWatch from where it can be streamed to multiple places if need be.

I couldn't think of a good way to test this, hence the question.

If it is synchronous:

1) What's the latency / KB?

If its asynchronous:

1) When the Lambda function has done its job (returned response to caller) AWS documentation says it can be destroyed anytime to scale down or to simply get replaced by another instance for whatever reason, if its indeed asynchronous, then how does AWS gurantee that the logs will not be lost?

UPDATE: I found that no matter what language we are talking about, Lambda is ultimately writing to the console (console.log in node.js, Console.Writeline in C#), I imagine AWS takes it from the console and puts it in Cloudwatch. This just makes me more confused, if anybody can point me to data flow diagram, it would be awesome.

1

1 Answers

4
votes

Answer from AWS forum at which I posted when I didn't recieve an answer from here:

At present, Lambda writes asynchronously to Cloudwatch logs for console.log type calls, and in the unlikely event, logs can be lost.

For example if there is a service event in Cloudwatch logs, logs may fail silently.

However, under normal operation, even after the lambda container has been destroyed or replaced, the lambda service would still have a chance to complete writing logs, thus it would be very unlikely logs would be lost.

If you need guarantees, then I would suggest create blocking code, using the respective SDK's to write directly to CloudWatch logs (i.e. not console.log ) to fail the lambda function when required.

If you are seeing this issue often please do open a ticket with the AWS support team and we will certainly investigate further.

AWS forum question @ https://forums.aws.amazon.com/thread.jspa?messageID=768836