AWS bills go directly to your AWS account — Stacktape's subscription fee is separate. Many deployed AWS resources can incur cost, and always-on resources compound over time. This page covers the highest-impact levers for reducing what you pay without sacrificing reliability.
Use the cost dashboards and per-resource breakdown in the Stacktape Console to identify where your spend is concentrated before optimizing. Set up budget alerts so you catch cost spikes early.
Choose the right compute model
The biggest cost lever is choosing the right compute model for your workload. Lambda functions, container services, and batch jobs have fundamentally different pricing structures — picking the wrong one can cost you 5–10x more than necessary.
Lambda functions: pay-per-invocation
Lambda functions cost nothing when idle — you pay only for the compute time consumed during each invocation. This makes them the cheapest option for low-traffic or bursty workloads. Beyond sustained high traffic, a container service running 24/7 is usually cheaper per-request because you avoid per-invocation overhead.
Provisioned concurrency can reduce cold starts, but it adds idle compute cost — each provisioned instance bills continuously. Use it only when latency requirements justify the tradeoff. For most internal or background endpoints, occasional cold starts are an acceptable tradeoff for zero idle cost.
Container services: always-on cost
A Stacktape web service is a container running 24/7 with a public HTTPS URL, so treat it as always-on compute that bills continuously. Private services and worker services are also container-based resources — see their resource pages for runtime and scaling behavior. Before deploying a container service, confirm your workload genuinely needs an always-on process. If traffic is sporadic, a Lambda function with an HTTP trigger is usually cheaper.
Right-size the resources block. For Fargate-backed container workloads, AWS pricing is tied to requested CPU and memory, so right-sizing is the first optimization. Start at the smallest combination that keeps your application responsive and scale up only when metrics show resource pressure.
Batch jobs: pay only for runtime
Batch jobs run containerized tasks to completion — you pay only for the compute time used. Use batch jobs for data processing, ML training, image encoding, or any task that runs to completion rather than serving ongoing traffic. Set timeout on jobs with a known upper bound so an overrun attempt is killed; if retryConfig is set, Stacktape retries the job after failure, timeout, or Spot interruption.
| Feature | Lambda function | Web service | Batch job |
|---|---|---|---|
| Pricing model | Per-invocation | Per-hour (24/7) | Per-job runtime |
| Best for traffic pattern | Bursty / low | Steady / high | Periodic tasks |
Use ARM/Graviton architecture
AWS Graviton (arm64) instances are typically priced below comparable x86 (x86_64) instances across Lambda and Fargate. Where your application code supports it, choosing ARM reduces compute cost without changing behavior.
ARM works with most application code without changes — Node.js, Python, Go, Java, and .NET all run natively on arm64. The main exception is native compiled binaries or Lambda layers built specifically for x86. Native binaries and prebuilt artifacts need to match the target architecture.
Prefer ARM unless you have native binary compatibility constraints. See the Lambda function, web service, private service, worker service, and batch job pages for how to configure architecture on each resource type.
Start every new project on ARM where supported. Only fall back to x86 if you hit a specific compatibility issue — that's rare for modern application stacks.
Use spot instances for batch jobs
Batch jobs support useSpotInstances, which uses discounted spare AWS capacity and can save up to 90%, but jobs can be interrupted. If a Spot interruption happens, your container gets a SIGTERM and 120 seconds to shut down gracefully.
Spot instances are a good fit for jobs that can safely restart — data imports, image processing, ML training with checkpoints. Combine with retryConfig so interrupted jobs automatically retry, and set timeout so a stuck job doesn't bill indefinitely:
resources.cpu sets the vCPU count and resources.memory sets memory in MB. The value 7680 MB is intentionally below 8 GB because AWS reserves memory for system processes — requesting exactly 8,192 MB may provision a larger instance than needed.
In this example, attempts: 3 sets the maximum retry attempts before the job is marked failed; the default is 1. retryIntervalSeconds: 30 sets the initial wait between retries (default is 0). retryIntervalMultiplier: 2 creates exponential backoff — waits of 30s, 60s, 120s (default is 1 — constant interval). The timeout: 3600 kills the job after 1 hour if it hasn't completed, preventing runaway costs.
Do not use spot instances for jobs with non-idempotent side effects (sending emails, charging payments) or strict completion deadlines.
Pick the right load balancing
For web services, the load balancing type directly affects monthly cost. The loadBalancing property accepts three types:
http-api-gateway (default) charges ~$1 per million requests with no base cost. At low traffic, this is the cheapest option. At high sustained traffic (above ~500k requests/day), the per-request charges add up and a flat-rate load balancer becomes more cost-effective.
application-load-balancer has a flat base cost of ~$18/month plus usage-based charges. It becomes more cost-effective than API Gateway at higher traffic volumes. It's required for gradual deployments, top-level firewalls, and WebSocket support.
network-load-balancer is for non-HTTP traffic (TCP/TLS) like MQTT, game servers, or custom protocols — use it only when you need raw TCP. It does not support CDN, top-level firewall, or gradual deployments.
Most teams should start with the default http-api-gateway. Switch to application-load-balancer only when you need its specific features (gradual deployments, WebSockets, firewall) or when your request volume makes the flat monthly cost cheaper than per-request pricing.
Right-size Lambda memory
Lambda CPU scales proportionally with memory. More memory means more CPU, which often means faster execution and lower total cost — a function that takes 3 seconds at 256 MB might finish in 800 ms at 1,024 MB, costing less overall despite the higher per-millisecond rate.
Profile your functions with real-world payloads. Increase memory in steps (512 → 1,024 → 2,048) and compare total billed duration × memory. The sweet spot is where additional memory stops reducing execution time.
Set timeout to the lowest value your function needs. Timeouts don't affect cost directly, but they limit how long a stuck invocation runs before being killed — preventing wasted spend from runaway functions.
Right-size container resources
For Fargate-backed container workloads, AWS pricing is tied to requested CPU and memory — over-provisioning wastes money every hour. Check CPU and memory utilization in the Stacktape Console metrics view or with stacktape metrics — if utilization is consistently below 30%, you're paying for capacity you don't use.
Start at the smallest CPU/memory combination that keeps your application responsive and scale up only when metrics justify it. See the web service, private service, and worker service pages for the supported CPU and memory values on each resource.
For services with variable load, auto-scaling adds instances under pressure rather than over-provisioning a single large instance. See the web service page for all scaling options — here's a typical setup:
In this example, cpu: 0.5 requests half a vCPU and memory: 1024 requests 1,024 MB — the smallest values that keep this service responsive. minInstances: 1 is the always-on floor (you always pay for at least one instance), while maxInstances: 4 caps horizontal scale-out and acts as your cost ceiling. keepAvgCpuUtilizationUnder: 70 tells the auto-scaler to add instances when average CPU exceeds 70% — adjust this threshold based on observed metrics. See the web service page for all available scaling options and supported CPU/memory values.
Choose the right database engine
Relational databases are often the largest line item in an AWS bill. The engine choice determines both the pricing model and how well it adapts to your traffic pattern.
Aurora Serverless v2 for variable workloads
Aurora Serverless v2 scales capacity automatically based on demand. You pay only for the capacity you consume at any moment. Set a low minCapacity for dev/staging environments to minimize idle cost, and cap maxCapacity to control the upper bound of your bill.
Aurora Serverless v2 is the recommended engine for most new projects where traffic is variable or unpredictable. It handles traffic spikes automatically without manual instance resizing and avoids paying for idle capacity during off-hours.
Standard RDS for predictable workloads
Standard RDS uses fixed instance sizes with hourly billing. If your traffic is steady and predictable, a right-sized RDS instance can be cheaper than Aurora Serverless v2 because you avoid the per-ACU premium. Use burstable t family instances for databases with occasional spikes, and switch to memory-optimized r family only for steady, memory-intensive workloads.
Avoid over-provisioning high availability
Enabling multiAz on a standard RDS instance creates a synchronous standby replica, which roughly doubles the instance cost. Skip it for development and staging stages. For production, enable it only when your uptime requirements justify the extra cost. Aurora clusters replicate across 3 AZs automatically, so multi-AZ resilience is built in without the explicit flag.
For dev/staging stages, use Aurora Serverless v2 with a low minCapacity. This gives you a real database that costs very little when idle. For production, evaluate whether your traffic is stable enough for standard RDS (cheaper per-hour when fully utilized) or variable enough to benefit from Aurora Serverless v2 (cheaper at low or fluctuating utilization).
Use serverless databases where possible
For key-value and document workloads, DynamoDB in on-demand mode costs nothing at zero traffic. You pay per read and write operation with no idle cost. This makes it ideal for applications with unpredictable or spiky access patterns. Switch to provisioned throughput only when your traffic is steady and predictable enough to forecast capacity needs.
For Redis use cases that don't require sub-millisecond latency from a dedicated cluster, consider Upstash Redis — a serverless, pay-per-request Redis with no idle cost. Redis caches bill per-hour for always-on instances regardless of utilization, so they're only cost-effective when you need consistent low-latency access under sustained load.
Add a CDN for cacheable traffic
A CDN (CloudFront) caches responses at edge locations for cacheable content and can reduce origin traffic. CloudFront pricing is per request and data transfer rather than a monthly base fee.
Enable a CDN on your web service when it returns cacheable content (static assets, public API responses, server-rendered pages). The network-load-balancer load balancing option is designed for non-HTTP TCP/TLS traffic and does not support CDN, top-level firewall, or gradual deployments — use http-api-gateway or application-load-balancer for HTTP workloads where CDN caching is part of the design. Skip the CDN for APIs where every response is unique and user-specific — caching won't help, and the extra hop adds slight latency.
You can restrict the CDN price class to reduce per-request cost in premium regions. Lower price classes limit which edge regions serve your content, which reduces cost but increases latency for users outside the covered regions.
Reduce log retention
CloudWatch log storage accumulates cost over time. Batch job logs default to 90 days of retention. For other resources, check the logging section on that resource's page before changing retention. You can view logs with stacktape logs.
For development and staging stages, 7–14 days of log retention is usually enough. For production, 30–60 days covers most debugging scenarios. For batch jobs, set retentionDays in the logging block — other resources may expose their own logging settings, so check each resource's page for details:
If you need long-term log storage for compliance, consider forwarding logs to a cheaper external service rather than keeping them in CloudWatch indefinitely.
Delete unused stages
Every deployed stage consumes AWS resources. Old feature-branch stages, abandoned test stacks, and forgotten staging environments accumulate idle cost — especially for always-on resources like container services, databases, and Redis caches.
Review your stacks regularly in the Stacktape Console or with stacktape stack list. Delete any stage that's no longer needed:
For PR-preview workflows, see the stacks-per-git-branch pattern and make cleanup part of the workflow so old stages are deleted after branches are merged.
Avoid unnecessary NAT Gateways
A NAT Gateway is one of the most expensive networking components in AWS — it bills a flat hourly rate plus per-GB data processing fees. Avoid NAT Gateways unless you have a concrete networking requirement, such as static outbound IP allowlisting, private subnet egress for a workload that needs it, or internet access for Lambda functions inside the VPC. Most workloads don't need one. When you do need NAT, stackConfig.nat: ec2 or ha-ec2 runs small Stacktape-managed instances instead of gateways (about $7 instead of $32 per month per zone, no per-GB fee) at the cost of about a minute of failed outbound calls when an instance dies; see VPC and networking. Non-production stages with nat: ec2 share one NAT instance by default, so five preview stages pay about $7.70 per month for NAT in total instead of five times that; see shared network for non-production stages.
For details on VPC networking and private subnet configuration, see the Lambda function, web service, and multi-container workload resource pages.
Use dev mode during development
Running stacktape dev lets you iterate locally without redeploying for every code change. Use it to shorten the feedback loop during development — see the dev mode overview for exact local/cloud runtime behavior.
For databases that support running locally during development, see local databases in dev mode — running a local instance avoids the cost of a deployed database while you iterate.
Set up budget alerts
AWS costs can spike unexpectedly — a misconfigured auto-scaling policy, a traffic surge, or a forgotten stack. Budget alerts notify you when spending exceeds a threshold, giving you time to react before the bill grows.
Create a budget for each AWS account you want to watch, with the monthly limit set to your expected bill. Keep the default alerts at 80% (early warning) and 100% (act now). A budget covers the whole account, so put stages with different spending expectations in separate AWS accounts if you need separate limits.
Cost optimization checklist
Use this checklist when reviewing a stack's cost profile:
- Use ARM/Graviton architecture where supported
- Lambda memory is profiled and right-sized (not left at default)
- Container CPU/memory matches actual utilization (check metrics)
- Auto-scaling is configured for container services with variable traffic
- Load balancing type matches traffic volume (API Gateway vs ALB)
- Database engine matches workload pattern (serverless vs fixed instance)
- Database
multiAzis disabled for non-production stages - Log retention is reduced for development/staging stages
- Unused stages are deleted
- Budget alerts are configured
- CDN is enabled for services with cacheable responses
- Batch jobs use spot instances where safe
- Batch jobs have
timeoutset to prevent runaway costs - No unnecessary NAT Gateways (private subnet with NAT disabled unless needed)
Cost Optimization Tips FAQ
How do I see what each resource costs?
The Stacktape Console provides per-resource cost breakdowns that attribute AWS charges to individual resources, stages, and projects. You can also view overall AWS spend across your organization using the cost dashboards. AWS bills your AWS account directly — these tools help you understand the bill, but they don't add charges.
Does Stacktape add cost on top of AWS?
Stacktape's subscription fee is separate from your AWS bill. AWS resources are billed directly by AWS to your connected AWS account. See billing and subscription for plan details.
Can a Stacktape web service scale to zero?
No. A web service is a container running 24/7 with a public HTTPS URL, so treat it as always-on compute rather than a scale-to-zero endpoint. If your workload has periods of zero traffic, a Lambda function is cheaper — it costs nothing when idle.
When should I use Aurora Serverless v2 vs standard RDS?
Use Aurora Serverless v2 when your database traffic is variable, unpredictable, or has significant idle periods — it scales capacity automatically and you pay only for what you use. Use standard RDS when traffic is steady and predictable — a fixed-size instance avoids the per-ACU premium. For dev/staging, Aurora Serverless v2 at a low minCapacity is almost always cheaper since it scales down when unused.
How do I reduce Lambda cold start costs without provisioned concurrency?
Provisioned concurrency reduces cold starts but adds idle compute cost, since each provisioned instance bills continuously. To avoid that idle cost, right-size memory instead — more memory means more CPU, which speeds up initialization (see Right-size Lambda memory). For most internal or background endpoints, occasional cold starts are an acceptable tradeoff for zero idle cost.
How does DynamoDB on-demand pricing compare to provisioned?
DynamoDB on-demand mode charges per read and write operation with no idle cost. Provisioned mode lets you reserve a fixed throughput (reads/writes per second) at a lower per-unit price but bills continuously even at zero traffic. On-demand is cheaper for variable or low-traffic tables. Provisioned with auto-scaling is cheaper when you have sustained, predictable throughput and can accurately forecast capacity.
How do I prevent unexpected cost spikes?
Set up budget alerts with thresholds at 80% and 100% of your expected monthly spend. Cap auto-scaling with maxInstances on container services and maxCapacity on Aurora Serverless v2 databases. Set timeout on batch jobs so stuck jobs are killed. Review the per-resource breakdown weekly to catch anomalies early. Delete old stages you're no longer using.