Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

A guide to optimize Cloud SQL costs

Riya2311
Staff


image4.pngCloud SQL is a fully managed relational database service for MySQL, PostgreSQL, and SQL Server. It offers benefits such as reliability, connectivity, security, availability, streamlined migration, observability, and maintenance.

Cloud SQL editions

Cloud SQL offers different editions to cater to varying application needs, however, these editions are currently only available for Cloud SQL for MySQL and Cloud SQL for PostgreSQL.

  • Enterprise Edition: This edition provides a balance of performance, availability, and cost, making it suitable for a wide range of applications.image6.png
  • Enterprise Plus Edition: Designed for applications that demand the highest levels of performance, this edition includes enhanced performance features.

Users have the flexibility to upgrade their existing instances to the Enterprise Plus Edition or switch to the Enterprise Edition using in-place upgrades. Additionally, Database Migration Service can be utilized to move instances between the two editions.

Cloud SQL pricing
MySQL and PostgreSQL Instance Pricing SQL Server Instance Pricing
CPU and Memory Pricing: The cost of CPU and memory resources is determined by the region where your Cloud SQL instance is located. CPU and Memory Pricing: Similar to MySQL and PostgreSQL, CPU and memory costs are region-specific
Storage and Networking Pricing: Charges for storage and networking resources are separate from CPU and memory costs. Storage and Networking Pricing: Separate charges apply to storage and networking resources
Instance Pricing (Shared-Core Instances Only): An additional instance charge applies specifically to shared-core instances. Licensing: Cloud SQL for SQL Server includes licensing fees. However, for high-availability or regional instances, only a single license is charged for the active resource, providing cost-efficiency.

Cloud SQL also offers CUDs, which provide significant cost savings in exchange for committing to continuous usage for one or three years. These discounts are ideal for workloads with predictable resource needs.

Note: As a managed service, Cloud SQL does not support BYOL (Bring Your Own License), and CUDs do not apply to licensing costs.

Recommendations for optimizing Cloud SQL costs

There are several ways to optimize your Cloud SQL costs:

  • Single Zone vs Multi Zone deployments: To optimize costs on GCP, choose single-zone deployments for less critical workloads or development environments. Reserve multi-zone deployments for production or mission-critical applications where uptime is a priority since it incurs higher costs due to the additional standby instance and replication traffic.
  • Rightsizing: Avoid overestimating your instance's resources by periodically reviewing Cloud SQL utilization and using custom vCPU and memory options.
  • Choosing between HDD and SSD: SSDs offer better performance but are more expensive. Consider moving non-critical or non-production workloads to HDDs for cost savings.

    image2.png

     

    image5.png

     Note: The cost savings from HDD are minimal, unless you're storing large amounts of data. Consider using HDD storage if you're storing at least 10 TB of data.

    • Enabling automatic storage increase: This option automatically adds storage capacity as needed, reducing application downtime and saving money.

      image1.png

      • Scheduling instance stop/start: Stop non-production instances during specific time windows when they're not in use.
      • Removing non-critical HA and read replicas: High availability and read replicas incur additional costs. Remove them for non-critical instances.
      • Preventing Query performance problems: Optimize SQL commands to reduce instance load and enable the use of lower-cost instance types. Cloud SQL Insights can help you identify and resolve query performance issues.
      • Query Insights: This feature in Cloud SQL provides detailed visibility into query performance, helping identify and optimize inefficient queries. By pinpointing slow or resource-intensive queries, it enables cost savings through reduced compute usage and better resource allocation.
        image7.png
      • Active Assist for Cloud SQL: This tool helps you detect and right-size over-provisioned instances, identify idle instances, and optimize billing.
        Example: A project’s development environment includes a Cloud SQL instance that has been idle for 60 days post-project completion. Active Assist flags this instance, prompting the user to review and potentially delete or pause it to save costs.

        image3.png

By implementing these recommendations and analyzing their effort levels, you can effectively optimize your Cloud SQL costs.

Understanding discount options

Google Cloud offers Committed Use Discounts (CUDs) as a cost-saving mechanism for predictable workloads. By committing to continuous usage of resources for either one or three years, users can enjoy significant discounts compared to on-demand pricing.

For Cloud SQL, CUDs provide:

  • Upto 25% discount on on-demand pricing for a one-year commitment.
  • Upto 52% discount on on-demand pricing for a three-year commitment.

These discounts can drastically lower Cloud SQL costs for organizations with stable and predictable database workloads. CUDs are purchased through the Google Cloud Console billing page and are automatically applied to eligible resources.

By following these best practices and leveraging the available tools and discounts, you can optimize your Cloud SQL costs while maintaining performance and reliability. Remember to continuously monitor your instances and adjust your configurations as needed to ensure you're getting the most out of your investment.

4 1 3,554
Authors