Skip to content

Extends SST SsrSites with an optional warming feature.

Notifications You must be signed in to change notification settings

SpencerDuball/sst-warmer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sst-warmer

This is a simple package that simply extends an SsrSite construct from SST and allows you to keep a specified number of functions warm. Keeping lambdas warm can help with cold starts and the benefits are most evident when the lambda's bundle size is large, read more about how warming works and the associated costs in this post by Open Next.

If you want to keep any of the following SST-deployed sites warm than this package is for you!

  • RemixSite
  • SvelteKitSite
  • AstroSite
  • SolidStartSite

If you want to keep a NextjsSite warm then you are in luck! This is already supported via SST, see the documentation to learn more.

This package exists only to bridge the gap unil this issue is closed, note that a PR is out already here as well. The API for this package matches exactly with the PR referenced above, so when SST supports this natively you can seamlessly remove this package and upgrade. I mostly just wanted to speed my site up in the meantime and figured I would package this up & share as it was a request feature in the SST discord.

Installation

npm install sst-warmer

Usage

This package is pretty simple, just ensure that you have the appropriate peer dependencies installed:

  • "aws-cdk-lib": ">=2.24",
  • "constructs": ">=10.1.0",
  • "sst": ">=2.11.16"

Then you can import the "warm" version of the site you want to create, and use it. Since this packages declares sst as a peer dependency it should be compatible with any version of SST so long as you meet the peer dependency requirements, this also means it will be a drop in replacement for your current site construct with the only difference noticable is the added warm prop.

// This was your old construct ...
import { RemixSite } from "sst/constructs";

const site = new RemixSite(stack, "web", {
  path: "packages/web/",
  customDomain: app.stage === "prod" ? domainName : undefined,
  cdk: { server: { architecture: Architecture.ARM_64 } },
  environment: SiteEnv,
});

// .. and this is the construct with warming
import { RemixSite } from "sst-warmer";

const site = new RemixSite(stack, "web", {
  path: "packages/web/",
  customDomain: app.stage === "prod" ? domainName : undefined,
  cdk: { server: { architecture: Architecture.ARM_64 } },
  environment: SiteEnv,
  warm: 5, // + we will keep 5 lambda warm
});

About

Extends SST SsrSites with an optional warming feature.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published