A command-line tool for analyzing Alibaba Cloud Spot instance prices and availability. This tool helps you find the most cost-effective Spot instances based on historical price data and availability patterns.
- 🔍 Instance Filtering: Filter instances by CPU, memory, and instance family
- 📊 Price Analysis: Analyze historical Spot prices with customizable time windows
- 💰 Cost Optimization: Find instances with the best price-to-performance ratios
- 📈 Availability Insights: Get insights into instance availability patterns
- 🎯 Multiple Output Formats: Support for both human-readable tables and JSON output
- ⚡ Fast & Efficient: Optimized for quick analysis of large instance catalogs
- Go 1.25.2 or later
- Alibaba Cloud account with ECS API access
# Clone the repository
git clone <repository-url>
cd spot-instance-advisor
# Build the binary (outputs to dist/spot-instance-advisor-OS-ARCH)
make build
# Or build directly with Go (not recommended for releases)
go build -o dist/spot-instance-advisor-$(go env GOOS)-$(go env GOARCH) .# Basic usage with table output
./spot-instance-advisor \
--accessKeyId YOUR_ACCESS_KEY_ID \
--accessKeySecret YOUR_ACCESS_KEY_SECRET \
--region cn-hangzhou
# JSON output for programmatic use
./spot-instance-advisor \
--accessKeyId YOUR_ACCESS_KEY_ID \
--accessKeySecret YOUR_ACCESS_KEY_SECRET \
--region cn-hangzhou \
--json--accessKeyId: Your Alibaba Cloud Access Key ID--accessKeySecret: Your Alibaba Cloud Access Key Secret--region: Target region (default: cn-hangzhou)
--mincpu: Minimum CPU cores (default: 1)--maxcpu: Maximum CPU cores (default: 32)--minmem: Minimum memory in GB (default: 2)--maxmem: Maximum memory in GB (default: 64)--family: Instance family filter (e.g., ecs.n1,ecs.n2)--instanceType: Specific instance types (comma-separated, e.g., ecs.n1.small,ecs.n2.large). Takes precedence over family parameter.--arch: CPU architecture filter: x86_64 or arm64
--cutoff: Discount threshold (default: 2)--limit: Maximum number of results (default: 20)--resolution: Price history analysis window in days (default: 7)
--json: Output results in JSON format
spot-instance-advisor/
├── main.go # Main application entry point
├── meta.go # Metadata and instance management
├── sort.go # Price analysis and sorting logic
├── go.mod # Go module dependencies
├── go.sum # Dependency checksums
├── Makefile # Build automation
└── README.md # This file
# Install dependencies
make deps
# Run tests
make test
# Build the application
make build
# Build for Linux
make build-linux
# Run with coverage
make test-coverage
# Clean build artifacts
make clean
# Update dependencies
make deps-updateThis project uses modern Go modules for dependency management:
- github.com/aliyun/alibaba-cloud-sdk-go: Alibaba Cloud SDK for Go
- github.com/fatih/color: Terminal color output
- github.com/sirupsen/logrus: Structured logging
When using the --json flag, the tool outputs structured JSON data:
[
{
"instanceTypeId": "ecs.n1.small",
"zoneId": "cn-hangzhou-a",
"pricePerCore": 0.1234,
"discount": 2.5,
"possibility": 0.8,
"cpuCoreCount": 1,
"memorySize": 2.0,
"instanceFamily": "ecs.n1",
"arch": "x86_64"
}
]instanceTypeId: Instance type identifierzoneId: Availability zone identifierpricePerCore: Price per CPU corediscount: Discount multiplier compared to on-demand pricingpossibility: Price stability indicatorcpuCoreCount: Number of CPU coresmemorySize: Memory size in GBinstanceFamily: Instance family identifierarch: CPU architecture (x86_64 or arm64)
./spot-instance-advisor \
--accessKeyId YOUR_KEY \
--accessKeySecret YOUR_SECRET \
--mincpu 1 \
--maxcpu 4 \
--minmem 2 \
--maxmem 8 \
--cutoff 3 \
--json./spot-instance-advisor \
--accessKeyId YOUR_KEY \
--accessKeySecret YOUR_SECRET \
--family ecs.n1,ecs.n2 \
--arch x86_64 \
--limit 10 \
--json./spot-instance-advisor \
--accessKeyId YOUR_KEY \
--accessKeySecret YOUR_SECRET \
--instanceType ecs.n1.small,ecs.n2.large \
--arch x86_64 \
--limit 10 \
--jsonNote: When using --instanceType:
- The specified instance types take precedence over
--familyparameter - Supports comma-separated multiple instance types
- All other filters (CPU, memory, architecture) will be skipped, directly using the specified instance types
- Invalid or non-existent instance types will be skipped
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
- Alibaba Cloud for providing the ECS API
- The Go community for excellent tooling and libraries