🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

lambda-warmer

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-warmer - npm Package Compare versions

Comparing version

to
1.1.0

8

index.js

@@ -6,8 +6,6 @@ 'use strict'

* @author Jeremy Daly <jeremy@jeremydaly.com>
* @version 1.0.0
* @version 1.1.0
* @license MIT
*/
const Promise = require('bluebird')
const id = Date.now().toString() + '-' + ('0000' + Math.floor(Math.random()*1000).toString()).substr(-4)

@@ -20,2 +18,4 @@

const delay = ms => new Promise(res => setTimeout(res, ms))
module.exports = (event,cfg = {}) => {

@@ -105,3 +105,3 @@

} else if (invokeCount > 1) {
return Promise.delay(config.delay).then(() => true)
return delay(config.delay).then(() => true)
}

@@ -108,0 +108,0 @@

{
"name": "lambda-warmer",
"version": "1.0.1",
"version": "1.1.0",
"description": "Keep your Lambda functions warm",

@@ -30,3 +30,2 @@ "main": "index.js",

"dependencies": {
"bluebird": "^3.5.1"
},

@@ -43,3 +42,9 @@ "devDependencies": {

"sinon": "^6.1.3"
}
},
"files": [
"lib/",
"index.js",
"LICENSE",
"README.md"
]
}

@@ -10,3 +10,3 @@ # Lambda Warmer

At a recent AWS Startup Day event in Boston, MA, Chris Munns, the Senior Developer Advocate for Serverless at AWS, discussed **Cold Starts** and how to mitigate them. According to Chris, although he acknowledge that it is a "hack", using the **CloudWatch Events "ping"** method is really the only way to do it right now. He gave a number of good tips do this "correctly":
At a recent AWS Startup Day event in Boston, MA, Chris Munns, the Senior Developer Advocate for Serverless at AWS, discussed **Cold Starts** and how to mitigate them. According to Chris (although he acknowledged that it is a "hack") using the **CloudWatch Events "ping"** method is really the only way to do it right now. He gave a number of good tips on how to do this "correctly":

@@ -18,7 +18,7 @@ - Don’t ping more often than every 5 minutes

He also mentioned that if you want to keep several concurrent functions warm, that you need to invoke the same function multiple times with delayed executions. This prevents the system from reusing the same container.
He also mentioned that if you want to keep several **concurrent** functions warm, that you need to invoke the same function multiple times with delayed executions. This prevents the system from reusing the same container.
You can read the key takeaways from his talk [here](https://www.jeremydaly.com/15-key-takeaways-from-the-serverless-talk-at-aws-startup-day/).
Following these "best practices", I created **Lambda Warmer**. It is a lightweight module that can be added to your Lambda functions to manage "warming" events as well as handling automatic fan-out for initializing *concurrent functions*. Just instrument your code and schedule your CloudWatch Events.
Following these "best practices", I created **Lambda Warmer**. It is a lightweight module (with no dependencies) that can be added to your Lambda functions to manage "warming" events as well as handling automatic fan-out for initializing *concurrent functions*. Just instrument your code and schedule a "ping".

@@ -34,5 +34,7 @@ **NOTE:** Lambda Warmer will invoke the function multiple times using the AWS-SDK in order to scale concurrency (if you want to). Your functions MUST have `lambda:InvokeFunction` permissions so that they can invoke themselves. Following the Principle of Least Privilege, you should limit the `Resource` to the function itself, e.g.:

If you'd like to know more about how **Lambda Warmer** works, and why you might (or might not) want to use it, read this *[Lambda Warmer: Optimize AWS Lambda Function Cold Starts](https://www.jeremydaly.com/lambda-warmer-optimize-aws-lambda-function-cold-starts/)* post.
## Installation
Install Lambda Warmer from NPM as a project dependency. Lambda Warmer uses Bluebird as its only dependency to manage delays.
Install Lambda Warmer from NPM as a project dependency.

@@ -39,0 +41,0 @@ ```