PostgreSQL Performance and Cost Analysis Across 23 AWS EC2 Instance Types
PostgreSQL Performance and Cost Analysis Across 23 AWS EC2 Instance Types
Executive Summary
For workloads requiring 33,000 requests per second (RPS) with a 1 GB dataset, the m8g.large instance using gp3-baseline storage is the most cost-effective configuration, costing approximately $82/month. While the c8i.large provides the highest raw throughput per dollar spent, Graviton-based instances (arm64) generally offer a superior balance of performance and cost for PostgreSQL deployments.
Cost-Performance Frontier for 33,000 RPS
When targeting a throughput of 33,000 RPS with a 1 GB dataset, 30 out of 52 tested configurations meet the requirement. The selection of the optimal instance depends on whether the priority is absolute minimum cost or maximum efficiency.
Cheapest Configuration
- Instance: m8g.large
- Storage: gp3-baseline
- Architecture: arm64 (Graviton)
- Cost: ~$82/mo
- Performance: 45,515 RPS (1.4× target)
Best RPS per Dollar
- Instance: c8i.large
- Storage: gp3-baseline
- Architecture: x86-64
- Performance: 52,203 RPS
- Efficiency: 451,476 RPS/€·hr
Comparative Analysis of Instance Families
Performance varies significantly across EC2 families, with newer generations and Graviton processors showing distinct advantages in throughput and latency.
Graviton (arm64) vs. x86-64
Graviton instances (highlighted in green in the source data) frequently appear on the cost-performance frontier. For example, the m8g.large (arm64) outperforms the m7i.large (x86-64) in both cost ($82/mo vs $90/mo) and throughput (45,515 RPS vs 41,305 RPS) when using gp3-baseline storage.
Performance Scaling by Instance Size
Increasing instance size generally improves throughput, though the RPS per dollar often diminishes as instances grow larger:
- m8g.large: 45,515 RPS (~$82/mo)
- m8g.xlarge: 70,871 RPS (~$147/mo)
- m8g.2xlarge: 81,451 RPS (~$278/mo)
Impact of Storage Configuration: gp3-baseline vs. gp3-max
Storage configuration significantly impacts the monthly cost without always providing a proportional increase in throughput.
Using the c8i.large as an example:
- gp3-baseline: 52,203 RPS at ~$84/mo
- gp3-max: 53,444 RPS at ~$184/mo
In this scenario, upgrading to gp3-max increased the monthly cost by over 100% while providing only a marginal increase in requests per second, suggesting that for this specific workload, baseline gp3 storage is sufficient.
Low-End Performance (T-Series Instances)
T-series instances (t3, t4g) are unsuitable for high-throughput PostgreSQL workloads. These instances consistently failed to meet the 33,000 RPS target, with most delivering between 2,800 and 5,300 RPS. For instance, the t4g.small on gp3-baseline only achieved 2,842 RPS, making it an order of magnitude slower than the m8g.large.