lambda-warmer
Advanced tools
Comparing version
{ | ||
"name": "lambda-warmer", | ||
"version": "1.0.0-alpha", | ||
"version": "1.0.0-beta", | ||
"description": "Keep your Lambda functions warm", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -109,3 +109,3 @@ # Lambda Warmer | ||
Lambda Warmer facilitates the warming of your functions by analyzing invocation events and appropriately managing handler processing. It **does not** manage the periodic invocation of your functions. In order to keep your functions warm, you must create a CloudWatch Rule that invokes your functions on a predetermined schedule. | ||
Lambda Warmer facilitates the warming of your functions by analyzing invocation events and appropriately managing handler processing. It **DOES NOT** manage the periodic invocation of your functions. In order to keep your functions warm, you must create a CloudWatch Rule that invokes your functions on a predetermined schedule. | ||
@@ -125,2 +125,42 @@ A rule that invokes your function should contain a `Constant (JSON text)` under the "Configure input" setting. The following is a sample event (using the default configuration and a concurrency of `3`): | ||
### Using a SAM Template | ||
To add a schedule event to your Lambda functions, you can add a `Type: Schedule` to the `Events` section of your function in a SAM template: | ||
```yaml | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: 'AWS::Serverless-2016-10-31' | ||
Resources: | ||
MyFunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
Handler: index.handler | ||
Runtime: nodejs8.10 | ||
CodeUri: 's3://my-bucket/function.zip' | ||
Events: | ||
WarmingSchedule: | ||
Type: Schedule | ||
Properties: | ||
Schedule: rate(5 minutes) | ||
Input: '{ "warmer":true,"concurrency":3 }' | ||
``` | ||
### Using the Serverless Framework | ||
If you are using the [Serverless Framework](https://serverless.com), you can include a `schedule` event for your functions using the folowing format: | ||
```yaml | ||
myFunction: | ||
name: myFunction | ||
handler: myFunction.handler | ||
events: | ||
- schedule: | ||
name: warmer-schedule-name | ||
rate: rate(5 minutes) | ||
enabled: true | ||
input: | ||
warmer: true | ||
concurrency: 1 | ||
``` | ||
## Logs | ||
@@ -138,3 +178,3 @@ | ||
correlationId: '1531413096993-0568', // correlation id | ||
count: 1, // | ||
count: 1, // function number of total concurrent e.g. 3 of 10 | ||
concurrency: 2, // number of concurrent functions being invoked | ||
@@ -141,0 +181,0 @@ warm: true, // was this function already warm |
12482
9.58%189
26.85%