dtgj8529 2018-11-16 10:40
浏览 79

从PHP PDO应用引擎到Cloud SQL的连接速度缓慢

I'm trying to deploy a PHP55 application to GAE (standard instances) with cloud SQL connection.

I'm using unix_socket DSN connection as shown in documentation, but the connection time to cloud sql instance is very very slow (it can take up to 200ms sometimes), and have a serious impact in application response time (it should answer in 50ms, but actually have an 150ms average response time) :

"timer (seconds)": {
            "begin": 0,
            "app": 0.043889999389648,
            "pdoinit": 0.000070095062255859,
            "pdook": 0.20270991325378,
            "pdoutf8": 0.037790060043335,
            "controller": 0.062999963760376,
            "preparequery": 0.015130043029785,
            "executequery": 0.0024099349975586,
            "return": 0.0051000118255615,
            "returnok": 0.00011014938354492
        }

Here is the same performance check from f1-micro compute engine instance :

"timer (seconds)": {
            "begin": 0,
            "app": 0.0002980232238769531,
            "pdoinit": 0.000014066696166992188,
            "pdook": 0.0019490718841552734,
            "pdoutf8": 0.0009219646453857422,
            "controller": 0.0030989646911621094,
            "preparequery": 0.005979061126708984,
            "executequery": 0.0009448528289794922,
            "return": 0.0031609535217285156,
            "returnok": 0.000025033950805664062
        },

My application and Cloud SQL instance are on the same location id. So no problem here.

Got another app accessing cloud SQL from compute engine in the same region, without any problem.

Maybe there is another connection method I did not see in the documentation ? I saw lot of people having problems like this, without solution. Maybe app engine is not the right solution ?

thanks a lot for your help !

  • 写回答

1条回答 默认 最新

  • dqhnp44220 2018-11-16 23:49
    关注

    The official CloudSQL documentation basically states that there are no alternative ways to connect to CloudSQL from AppEngine standard than the ways mentioned in the AppEngine documentation (i.e. sockets):

    General information for connecting to Cloud SQL from App Engine

    When connecting to Cloud SQL from App Engine standard or flex environment, you can connect only by using the instructions linked below. You cannot use IP addresses (public or private) to connect to Cloud SQL from App Engine applications. Connections from App Engine applications to Cloud SQL are secure and encrypted; you do not need to configure TLS/SSL.

    SOURCE

    If it's an option for your application, you might try compute Engine vm's or kubernetes Engine, to be able to use regular tcp connections. Possibly even with private ip's, to increase the network performance.

    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计