Search code examples
mysqlgoogle-cloud-platformgoogle-cloud-sql

How to lower costs of having MySQL db in Google Cloud


I set up Google Cloud MySQL, I store there just one user (email, password, address) and I'm querying it quite often due to testing purposes of my website. I set up minimal zone availability, the lowest SSD storage, memory 3.75GB, 1vCPUs, automatic backups disabled but running that database from the last 6 days costing me £15... How can I decrease the costs of having MySQL database in the cloud? I'm pretty sure paying that amount is way too much. Where is my mistake?


Solution

  • I suggest using the Google Pricing Calculator to check the different configurations and pricing you could have for a MySQL database in Cloud SQL.

    Choosing Instance type

    As you've said in your question, you're currently using the lowest standard instance, which is based on CPU and memory pricing.

    As you're currently using your database for testing purposes, I could suggest to configure your database with the lowest Shared-Core Machine Type which is db-f1-micro, as shown here. But note that

    The db-f1-micro and db-g1-small machine types are not included in the Cloud SQL SLA. These machine types are designed to provide low-cost test and development instances only. Do not use them for production instances.

    Choosing Storage type

    As you have selected the lowest allowed disk space, you could lower cost changing the storage type to HDD instead of a SSD if you haven't done so, as stated in the documentation:

    Choosing SSD, the default value, provides your instance with SSD storage. SSDs provide lower latency and higher data throughput. If you do not need high-performance access to your data, for example for long-term storage or rarely accessed data, you can reduce your costs by choosing HDD.

    • Note that Storage type could only be selected when you're creating the instance and could not be changed later, as stated in the message when creating your instance.

      Choice is permanent. Storage type affects performance.

    Storage type

    Stop instance when is not in use

    Finally, you could lower costs by stopping the database instance when it is not in use as pointed in the documentation.

    Stopping an instance suspends instance charges. The instance data is unaffected, and charges for storage and IP addresses continue to apply.


    Using Google Pricing Calculator

    The following information is presented as a calculation exercise based in the Google Pricing Calculator

    The estimated fees provided by Google Cloud Pricing Calculator are for discussion purposes only and are not binding on either you or Google. Your actual fees may be higher or lower than the estimate. A more detailed and specific list of fees will be provided at time of sign up

    Following the suggestions above, you could get a monthly estimate of 6.41 GBP. Based on a 24 hour per 7 days running instance.

    MySQL instance on Cloud SQL HDD 24x7

    And using a SSD, it increases to 7.01 GBP. As said before, the only way to change the storage type would be to create a new instance and load your data.

    MySQL instance on Cloud SQL SDD 24x7

    And this could lower to 2.04 GBP if you only run it for 8 hours 5 days a week running on HDD.

    MySQL instance on Cloud SQL HDD 8x5