How to run Google Cloud SQL only when I need it?

前端 未结 2 872
我寻月下人不归
我寻月下人不归 2021-02-15 23:41

Google Cloud SQL advertises that it\'s only $0.0150 per hour for the smallest machine type, and I\'m being charged for every hour, not just hours that I\'m connected. Is this b

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-16 00:22

    This is not so much about the pool as it is about the nature of Cloud SQL. Unlike App Engine, Cloud SQL instances are always up. I learned this the hard way one Saturday morning when I'd been away from the project for a week. :)

    There's no way to spin them down when they're not being used, unless you explicitly go stop the service.

    There's no way to schedule a service stop, at least within the GCP SDK. You could alway write a cron job, or something like that, that runs a little gcloud sql instances patch [INSTANCE_NAME] --activation-policy NEVER command at, for example, 6pm local time, M-F. I was too lazy to do that, so I just set a calendar reminder for myself to shut down my instance at the end of my workday.

    Here's the MySQL Instance start/stop/restart page for the current SDK's docs: https://cloud.google.com/sql/docs/mysql/start-stop-restart-instance

    On an additional note, there is an ongoing 'Feature Request' in the GCP Platform to start/stop the Cloud SQL (2nd Gen), according to the traffic as well. You can also visit the link and provide your valuable suggestions/comments there as well.

提交回复
热议问题