• <i id='W2whA'><tr id='W2whA'><dt id='W2whA'><q id='W2whA'><span id='W2whA'><b id='W2whA'><form id='W2whA'><ins id='W2whA'></ins><ul id='W2whA'></ul><sub id='W2whA'></sub></form><legend id='W2whA'></legend><bdo id='W2whA'><pre id='W2whA'><center id='W2whA'></center></pre></bdo></b><th id='W2whA'></th></span></q></dt></tr></i><div id='W2whA'><tfoot id='W2whA'></tfoot><dl id='W2whA'><fieldset id='W2whA'></fieldset></dl></div>

  • <small id='W2whA'></small><noframes id='W2whA'>

    1. <legend id='W2whA'><style id='W2whA'><dir id='W2whA'><q id='W2whA'></q></dir></style></legend>
        <bdo id='W2whA'></bdo><ul id='W2whA'></ul>
      <tfoot id='W2whA'></tfoot>

        如何仅在需要时运行 Google Cloud SQL?

        How to run Google Cloud SQL only when I need it?(如何仅在需要时运行 Google Cloud SQL?)

        • <bdo id='xhjtV'></bdo><ul id='xhjtV'></ul>
            <tbody id='xhjtV'></tbody>

          <small id='xhjtV'></small><noframes id='xhjtV'>

              • <legend id='xhjtV'><style id='xhjtV'><dir id='xhjtV'><q id='xhjtV'></q></dir></style></legend>
                <i id='xhjtV'><tr id='xhjtV'><dt id='xhjtV'><q id='xhjtV'><span id='xhjtV'><b id='xhjtV'><form id='xhjtV'><ins id='xhjtV'></ins><ul id='xhjtV'></ul><sub id='xhjtV'></sub></form><legend id='xhjtV'></legend><bdo id='xhjtV'><pre id='xhjtV'><center id='xhjtV'></center></pre></bdo></b><th id='xhjtV'></th></span></q></dt></tr></i><div id='xhjtV'><tfoot id='xhjtV'></tfoot><dl id='xhjtV'><fieldset id='xhjtV'></fieldset></dl></div>
                • <tfoot id='xhjtV'></tfoot>

                • 本文介绍了如何仅在需要时运行 Google Cloud SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Google Cloud SQL 宣称,对于最小的机器类型,每小时只需 0.0150 美元,而且我要按每小时收费,而不仅仅是我连接的小时数.这是因为我在使用游泳池吗?如何设置我的后端,使其仅在需要时查询云数据库,这样我就不会按一天中的每个小时收费?

                  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 because I'm using a pool? How do I setup my backend so that it queries the cloud db only when needed so I don't get charged for every hour of the day?

                  const mysql      = require('mysql');
                  const pool = mysql.createPool({
                      host : process.env.SQL_IP,
                      user     : 'root',
                      password : process.env.SQL_PASS,
                      database : 'mydb',
                      ssl      : {
                            [redacted]
                      }
                  });
                  
                  function query(queryStatement, cB){
                    pool.getConnection(function(err, connection) {
                      // Use the connection
                      connection.query(queryStatement, function (error, results, fields) {
                        // And done with the connection.
                        connection.destroy();
                        // Callback
                        cB(error,results,fields);
                  
                      });
                    });
                  }
                  

                  推荐答案

                  这与其说是关于池,不如说是关于 Cloud SQL 的性质.与 App Engine 不同,Cloud SQL 实例始终启动.在我离开项目一周后的一个星期六早上,我艰难地了解到了这一点.:)

                  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.

                  无法安排服务停止,至少在 GCP SDK 中是这样.您总是可以编写一个 cron 作业,或类似的东西,在例如当地时间下午 6 点,M-F 运行一些 gcloud sql instances patch [INSTANCE_NAME] --activation-policy NEVER 命令.我懒得这样做,所以我只是为自己设置了一个日历提醒,在我的工作日结束时关闭我的实例.

                  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.

                  这是当前 SDK 文档的 MySQL 实例启动/停止/重启页面:https://cloud.google.com/sql/docs/mysql/start-stop-restart-instance

                  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

                  另外请注意,GCP 平台中有一个正在进行的功能请求"以启动/也根据流量停止 Cloud SQL(第 2 代).您还可以访问链接并在那里提供您宝贵的建议/意见.

                  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.

                  这篇关于如何仅在需要时运行 Google Cloud SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Set the variable result, from query(设置变量结果,来自查询)
                  What is dynamic SQL?(什么是动态 SQL?)
                  Mysql - How to quit/exit from stored procedure(Mysql - 如何退出/退出存储过程)
                  Does MySQL have time-based triggers?(MySQL 有基于时间的触发器吗?)
                  is it possible to call a sql script from a stored procedure in another sql script?(是否可以从另一个 sql 脚本中的存储过程调用 sql 脚本?)
                  Procedure to loop through comma separated string is not working(遍历逗号分隔字符串的过程不起作用)
                    <bdo id='3RD2A'></bdo><ul id='3RD2A'></ul>
                  • <small id='3RD2A'></small><noframes id='3RD2A'>

                        • <legend id='3RD2A'><style id='3RD2A'><dir id='3RD2A'><q id='3RD2A'></q></dir></style></legend>
                          <i id='3RD2A'><tr id='3RD2A'><dt id='3RD2A'><q id='3RD2A'><span id='3RD2A'><b id='3RD2A'><form id='3RD2A'><ins id='3RD2A'></ins><ul id='3RD2A'></ul><sub id='3RD2A'></sub></form><legend id='3RD2A'></legend><bdo id='3RD2A'><pre id='3RD2A'><center id='3RD2A'></center></pre></bdo></b><th id='3RD2A'></th></span></q></dt></tr></i><div id='3RD2A'><tfoot id='3RD2A'></tfoot><dl id='3RD2A'><fieldset id='3RD2A'></fieldset></dl></div>

                            <tbody id='3RD2A'></tbody>
                            <tfoot id='3RD2A'></tfoot>