从Prestashop到Google Cloud SQL的首次连接始终失败 [英] First connect from Prestashop to Google Cloud SQL always fails

查看:85
本文介绍了从Prestashop到Google Cloud SQL的首次连接始终失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在作为GCE实例的开发服务器上设置PrestaShop安装,并使用Cloud SQL作为数据库服务器.除了一件事情之外,其他所有东西都工作正常:只要站点上长时间不活动,那么之后的第一个页面加载总会给我这个错误:

I'm setting up a PrestaShop installation on a development server which is a GCE instance and using Cloud SQL as a database server. Everything works just fine except one thing: whenever there is a long period of inactivity on the site, the first page load after that always gives me this error:

无法建立到数据库的链接:SQLSTATE [HY000] [2003]

Link to database cannot be established: SQLSTATE[HY000] [2003]

如果我刷新页面,该错误消失了,并且直到我停止使用该网站一个小时左右,该错误才再次出现.几乎看起来数据库实例正在进入睡眠模式或类似的状态.

If I refresh the page the error is gone and never appears again until I stop using the site for an hour or so. It almost looks like database instance is going into sleep mode or something like that.

我提到Prestashop的原因是这样的事实,当我使用Adminer或从mysql控制台客户端连接到数据库时,从未遇到此错误.

The reason I mentioned Prestashop is the fact that I never get this error when using Adminer or connecting to the database from mysql console client.

推荐答案

使用按次计费模式,实例将在15分钟的超时后自动旋转下来,以节省资金.然后,它们在下次访问时需要花费几秒钟的时间来旋转.可能是Prestashop暂停了这些最初的请求(尽管我没有使用该应用程序的经验).

With the per use billing model, instances are spun down after a 15 minute timeout to save you money. They then take a few seconds to be spun up when next accessed. It may be the Prestashop is timing out on these first requests (though I have no experience with that application).

尝试将您的实例更改为具有12小时超时的套餐计费,以查看是否有帮助

Try changing your instance to a package billing, which has a 12 hour timeout, to see if this helps

https://developers.google.com/cloud-sql/faq#how_usage_calculated

这篇关于从Prestashop到Google Cloud SQL的首次连接始终失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆