www/src/content/docs/blog/container-spot-capacity.mdx
import { YouTube } from "@astro-community/astro-embed-youtube";
We are adding support for using Spot instances when you create a Fargate service with the Cluster component through the capacity prop. Spot instances can be around 50% cheaper and we talk about how they work here.
You can create container services with ECS and Fargate in SST with the Cluster component.
You are charged per hour of vCPU and GB of memory used. With our base config, this works out to around $12 per month.
Spot instances are spare capacity that AWS has and it's available at a discounted rate, around $6 per month.
You can enable this using the new capacity prop.
const cluster = new sst.aws.Cluster("MyCluster", { vpc });
new sst.aws.Service("MyService", {
cluster,
loadBalancer: {
ports: [{ listen: "80/http" }],
},
capacity: "spot",
});
You can also configure the % of regular Fargate vs Spot capacity you want to use.
capacity: {
fargate: { weight: 1 },
spot: { weight: 1 }
}
Learn more about the capacity prop.
There are a couple of caveats.
This makes Fargate Spot a good option for dev or PR environments.
capacity: $app.stage === "production" ? undefined : "spot";
Get started by checking out the Fargate Spot capacity example.
You can also check out our container service quick starts.
These will help you get started with building container services.