Run Applications on Spot Instances for Cost Savings
Run Applications on Spot Instances with Kapstan
Kapstan allows you to run applications on spot instances in Kubernetes clusters, offering significant cost savings for workloads that can handle interruptions. Spot integration with Kubernetes ensures efficient management of resources.
What Are Spot Instances?
Spot instances are unused compute capacity offered by cloud providers at a lower cost than on-demand instances. These are ideal for workloads that can tolerate interruptions and require a cost-effective solution.
Benefits of Spot Instances in Kapstan
- Lower Costs: Spot instances reduce compute costs by up to 70–90%.
- Scalability: Easily scale workloads that can handle interruptions.
- Automated Rescheduling: Kubernetes reschedules workloads when spot instances are interrupted.
- Optimized Resources: Best suited for batch jobs, development environments, and stateless applications.
How to Enable Spot Instances in Kapstan?
Before enabling spot instances, make sure your application can handle interruptions. See best practices for spot instances.
- Open the configuration page for your application (e.g., "api-gateway").
- Go to the Hardware tab in the left menu.
- Find the Run on Spot toggle under the "Hardware" section.
- Turn on the toggle to activate spot instances.
- Save the changes to deploy the configuration.
Learn more in the AWS Spot Instances Documentation.
Best Practices for Spot Instances
Follow these steps to ensure applications run smoothly with spot instances:
Best Practice | Key Benefit |
---|---|
Stateless Applications | Avoids data loss and simplifies recovery. |
Idempotent Tasks | Ensures no errors during rescheduling. |
Graceful Shutdown | Ensures smooth termination. |
Checkpointing | Minimizes downtime for long tasks. |
Small Container Images | Speeds up pod launches. |
Details:
- Stateless Applications: Prefer applications that don’t store state locally. This avoids issues during interruptions.
- Idempotent Tasks: Make sure tasks can run multiple times without issues.
- Checkpointing: Save the application state at intervals to resume from the last save if interrupted.
- Graceful Shutdown: Handle termination signals to:
- Stop accepting new connections.
- Flush data to storage.
- Save the application state.
- Clean up resources.
- Optimize Container Images: Reduce container size to improve launch speed.
Frequently Asked Questions
Can all applications use spot instances?
No. Only fault-tolerant or stateless applications that can manage interruptions should use spot instances.
How does Kapstan handle interruptions?
Kapstan uses Kubernetes' tools to reschedule workloads when interruptions occur.
How much can I save with spot instances?
You can save up to 70–90%, depending on the cloud provider and workload.
What happens during an interruption?
Kubernetes reschedules the affected pods to other available instances.