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

cloudniite

v0.0.6

Published

Cloudniite is a JavaScript library that helps you as a developer optimize and monitor your serverless application performance and metrics on AWS Lambda. We chose AWS because it has an exceptional ecosystem of cloud products and a huge community of develop

Downloads

16

Readme

Cloudniite

Cloudniite is a JavaScript library that helps you as a developer optimize and monitor your serverless application performance and metrics on AWS Lambda. We chose AWS because it has an exceptional ecosystem of cloud products and a huge community of developers that are passionate about the future of serverless. We integrate seamlessly with your application to help you ensure your customers are having a fast and responsive experience. We do this by helping you organize and monitor event-driven AWS Lambda functions. If you are unfamiliar with AWS Lambda, no need to worry, we will cover the core concepts in the next section.

demo gif

Learn how to use Cloudniite in your own project.

How do you optimize AWS Lambda functions?

Amazon has to prepare or spin-up, new virtual servers to run your code. This startup time only happens when your functions haven't been run in a while. For Amazon, it doesn't make sense to keep your function running on a server if no one is using it. So, after a period of time, if your function isn't used, Amazon will "destroy" the server it is living on. This function will now be considered "cold". Cold functions take longer to run and will leave your users waiting longer for a response because of the time it takes to spin up a server to host the function.

Developers have been using simple timers to "warmup" their functions so that they stay running and available for users. This solution works but we believed there could be a smarter way to manage and keep your Lambda functions warm and performant.

Installation

Cloudniite is available as the cloudniite package on npm.

npm install --save cloudniite

Getting Started

Creating a function

To minimize execution duration and cost, add an if statement to check if Cloudniite has invoked the funtion. This will warm-up the funtion without running the function logic

Two options for creating a function:

  • [ ] Manually in your text editor
  • [ ] Inside AWS Lamda function creator

Option 1: Manually in your text editor

  • [X] Text editor
  • [ ] AWS Lamda function creator
Yaml file *optional:

Recommended to add FunctionName: func at the bottom of the function in the yaml to create a custom name.

  • Otherwise, AWS CloudFormation generates a unique physical ID to name a resource.

  • this ID is the name of your function in AWS.

  • to refer to the function in our library you MUST use the function name in AWS.

  • exception: If you reuse templates to create multiple stacks, you must change or remove custom names from your template.

example:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  func:
    Type: AWS::Serverless::Function
    Properties:
      Handler: lambda.handler
      Runtime: nodejs8.10
      Environment: 
        Variables:
          S3_BUCKET: bucketName
      FunctionName: func 
Lambda file:
exports.handler = function(event, context, callback) {
    if (event.source === "Cloudniite-Warmup") {
        callback(null,"Warmup");
    } else {
         ....add lambda logic here
    }
}

Make sure both yaml and lambda files are in the same folder.

Option 2: Inside AWS Lamda function creator

  • [ ] Text editor
  • [X] AWS Lamda function creator

Setting up your server

const express = require('express');
const cloudniite = require('cloudniite');
configure(region,poolId, apiVersion = optional):

*default apiVersion is 2015. *Advice: if there is a config error, verify that the internet is working.

Configure returns a promise. If you wish to warm up on server start, use the .then method to invoke the other methods.

cloudniite.configure('region','poolId').then(() => {
//add methods here
});

Methods

Cloudniite lets you easily group your Lambda functions however you like. If you want to make sure all the Lambda functions associated with your landing page are warmed up, simply create a tag group passing in the functions you would like to be grouped together.

createTagGroup(tagGroup, functionName):
  • add as many functions as you want
    • if you want to add an array rather then individual functions, add a spread operator cloudniite.createTagGroup(#tagName, … [functionName1, functionName2, functionName3])
  • must be a string
cloudniite.createTagGroup("#tagGroup", "function1", "function2")

Then, whenever you want to warmup the LandingPage functions, just call our method passing in the tag group name.

warmupTagGroup(interval, tagGroup):

To warm up your function on a recurring timer, add an interval

  • intervals are set in minutes
  • null: no interval
cloudniite.warmupTagGroup(null,"#tagGroup"); 

You can also warm up individuals functions

warmupFunctions(interval, tagGroup):
  • intervals are set in minutes
  • null: no interval
cloudniite.warmupFunctions(null,"functionName");; 
Recomended:

Create a tag group for all the lambda functions on a route and call the warmupTagGroup method as middleware!

Visualizer

Here you can see:

  • List of all Tag Groups and the functions associated
  • List of all your functions
  • Graphs to help you decide when to use intervals for each function or tag group
  • and more...

To access the visualizer add a custom route to your server.

app.get('/getHtmlViz', cloudniite.getHtmlViz);

Go to the route on your port

  • URL format: port/getHtmlViz
example: http://localhost:3000/getHtmlViz

Authors

  • Linda Harrison - Initial work - GitHub
  • Stephen Grable - Initial work - GitHub
  • Muhammad Sheikh - Initial work - GitHub

License

Cloudniite is MIT licensed.