Compute costs are straightforward, unlike database costs which have complex, platform-specific pricing models with hidden multipliers and distinct optimization levers. Many teams focus on instance right-sizing, but structural issues like unnecessary Multi-AZ, always-on non-production databases, and unshrinkable storage often yield greater savings. This article details cost-saving strategies for Amazon RDS, Google Cloud SQL, and Azure Cosmos DB.
For RDS, instance hours dominate costs, so scheduling non-production instances to run only during business hours and disabling Multi-AZ for these environments are effective immediate savings. Migrating gp2 storage to gp3 helps right-size storage and IOPS independently, while purchasing Reserved Instances offers substantial savings for stable production databases.
Google Cloud SQL benefits from Committed Use Discounts, which apply automatically across resource usage for 1- or 3-year commitments. A significant "storage auto-grow trap" exists where storage automatically increases but never shrinks, requiring manual recreation of instances to reduce allocated storage. Query optimization and index management can also reduce required instance sizes.
Cosmos DB charges for Request Units per second (RU/s), not instances, with its three pricing modes (Manual, Autoscale, Serverless) presenting a common cost pitfall. Serverless mode is often the most cost-effective for non-production environments due to its pay-per-use model. The multi-region write multiplier significantly increases RU costs, often unnecessarily, when single-write-region with read replicas could achieve similar latency goals at a fraction of the price.
The universal win across all platforms is scheduling non-production databases to stop when not in use, automating the process to avoid manual oversight. This simple operational change can lead to substantial monthly and annual savings without any architectural alterations.
Optimization priorities include scheduling non-production instances and disabling unnecessary high availability on non-production systems, as these offer the highest impact with the lowest risk and effort across all platforms. Subsequent steps involve storage migration (RDS), committed use discounts (Cloud SQL), and switching to serverless or single-write regions (Cosmos DB).
Database cost optimization should be an ongoing process with quarterly reviews, as workloads evolve and new environments are added, ensuring sustained savings.
dev.to
dev.to
