npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-plugin-flambe

v0.1.7

Published

Eliminates lambda cold starts

Downloads

35

Readme

npm downloads total npm version npm license

Installation

npm install serverless-plugin-flambe --save-dev

or

yarn add serverless-plugin-flambe --dev

Usage

In the serverless file, add serverless-plugin-flambe within the plugins entry.

Example:

functions:
  hello:
    handler: src/hello.handler
    timeout: 15

plugins:
  - serverless-plugin-flambe

By default all functions will then be automatically scheduled, wrapped to accept scheduled events, and immediately invoked post-deployment. If you want more granular control, options can be configured within a custom flambe variable.

Custom Declaration

In case your project doesn't require all of your lambdas to be warm, you can list the name of a specific lambda or use regular expressions declared in the custom level variables.

Example:

custom:
  flambe:
    regex:
      - hello
      - /good.*/
    memorySize: 512
    rate: rate(5 minutes)

The above example will keep the function hello warm as well as functions prefixed with the name good. If there are no lambdas that match in the declared list, nothing will be scheduled.

Lambda Configuration

In order to fine-tune the rate, input, and flow of your code, lambdas are configured on a per-lambda basis using the field flambe

| Option | Values | Default | Description | | :--- | :--- | :--- | :--- | | rate | AWS rate | 5 minutes | How often the lambda is to be called | | wrapper | String | null | The file path where a custom wrapper exists (same as a function handler definition) | | input | Object | { flambe: true } | The event the lambda receives, when it is pinged |

Options Example

functions:
  hello:
    handler: handlers.hello
    timeout: 10
    flambe: 
      rate: 'rate(3 minutes)'
      
  goodbye:
    handler: handlers.goodbye
    flambe:
      wrapper: wrapper.logger
      input:
        custom: 'property'

Custom Wrapper(s)

If you want to build a custom wrapper instead of the default flambe wrapper, it needs to be written as a higher-order-function.

Example:

// wrappers.js
const logger = (original) => (evt, ctx, cb) => {
  console.log('Logging event data:', JSON.stringify(evt, null, 2));
  return original(evt, ctx, cb);
}

module.exports = {
  logger,
};

Plugin Conflicts

Make sure serverless-plugin-flambe is placed before any plugins that compile code. Example:

plugins:
  - serverless-plugin-flambe
  - serverless-webpack

Cost

Cost per execution: $0.0000002

Cost per memory allocated 1024MB: $0.000001667

Calls per day: 288

Calls per month: 8640

Total monthly cost per-lambda: $0.016

**Prices calculated using the following aws information here.

Changelog

0.1.5

  • Flambe log retention now uses the value set in the provider

0.1.4

  • Fixed a misspelling that was preventing options stage from being resolved

0.1.3

  • Default to options stage, region instead of provider

0.1.2

  • Re-enabled cleanup phase post local invocation

0.1.1

  • PATCH: Using relative paths for original handlers instead of copying the source

0.1.0

  • Changed how flambe custom options are defined
  • Decrease memorySize of generated function to 128 MB
  • Using Serverless lambda invocation instead of custom