Skip to content

Commit b4b759d

Browse files
authored
Merge pull request #83 from ksami/nodejs-programming-model
Nodejs programming model
2 parents e03ecbe + 8a288fd commit b4b759d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

doc_source/nodejs-prog-model-handler.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The following example function logs the contents of the event object and returns
77
**Example index\.js**
88

99
```
10+
1011
exports.handler = async function(event, context) {
1112
console.log("EVENT: \n" + JSON.stringify(event, null, 2))
1213
return context.logStreamName
@@ -96,4 +97,4 @@ exports.handler = function(event, context, callback) {
9697
console.log('Timeout complete.')
9798
}, 5000)
9899
}
99-
```
100+
```

doc_source/programming-model-v2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ You write code for your Lambda function in one of the languages AWS Lambda suppo
99

1010
Logging is subject to [CloudWatch Logs limits](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/cloudwatch_limits_cwl.html)\. Log data can be lost due to throttling or, in some cases, when the [execution context](running-lambda-code.md) is terminated\.
1111
+ **Exceptions** – Your Lambda function needs to communicate the result of the function execution to AWS Lambda\. Depending on the language you author your Lambda function code, there are different ways to end a request successfully or to notify AWS Lambda an error occurred during execution\. If you invoke the function synchronously, then AWS Lambda forwards the result back to the client\.
12+
1213
+ **Concurrency** – When your function is invoked more quickly than a single instance of your function can process events, Lambda scales by running additional instances\. Each instance of your function handles only one request at a time, so you don't need to worry about synchronizing threads or processes\. You can, however, use asynchronous language features to process batches of events in parallel, and save data to the `/tmp` directory for use in future invocations on the same instance\.
1314

1415
Your Lambda function code must be written in a stateless style, and have no affinity with the underlying compute infrastructure\. Your code should expect local file system access, child processes, and similar artifacts to be limited to the lifetime of the request\. Persistent state should be stored in Amazon S3, Amazon DynamoDB, or another cloud storage service\. Requiring functions to be stateless enables AWS Lambda to launch as many copies of a function as needed to scale to the incoming rate of events and requests\. These functions may not always run on the same compute instance from request to request, and a given instance of your Lambda function may be used more than once by AWS Lambda\. For more information, see [Best Practices for Working with AWS Lambda Functions](best-practices.md)\.

0 commit comments

Comments
 (0)