简体   繁体   中英

When log streams of aws lambda are created?

I have a API Gateway integrated with lambda. When I hit rest API, I notice the logs sometimes goes to existing log stream of lambda and sometimes it creates separate log streams. SO how aws decides when to create new log stream? My assumption is for each API request, a separate lambda container will be launched to execute lambda function,hence the logs will also go to new log stream. But this is not the case.

TL;DR, when the lambda function reuses the execution environment, logs go to an existing log stream. Cold start always creates a new execution environment and logs will go to a new log stream.

Each instance of a Lambda function has a dedicated log stream. If a function scales up, each concurrent instance has its own log stream. Each time an execution environment is reaped and a new environment is created in response to an invocation, this generates a new log stream.

Ref: https://docs.aws.amazon.com/lambda/latest/operatorguide/log-structure.html

Occasionally lambda may reuse the same container if requests are coming in short span and in such cases, it is possible to have logs in same log stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM