简体   繁体   English

DeadlineExceededError连接到Google Cloud SQL

[英]DeadlineExceededError connecting to Google Cloud SQL

We have a google app engine application connected to GCSQL, and we are having a lot of DeadlineExceededError problems while trying to connect the database. 我们有一个连接到GCSQL的Google App Engine应用程序,并且在尝试连接数据库时遇到很多DeadlineExceededError问题。 The error seems to be produced by a big amount of users opening the application in a short period of time. 该错误似乎是由大量用户在短时间内打开应用程序产生的。 When we look up the opening connectios at the dashboard during this time, there aren't more than 45 opened connections at the same time and it fails on a big percentage of querys (reading, writing and connecting), taking too much time to do it. 在此期间,当我们在仪表板上查找打开的connectios时,同时打开的连接数不超过45个,并且它在大部分查询(读取,写入和连接)上均失败,这花费了太多时间它。 As a result of this spent time, the service shuts down and we receive the error. 由于花费了这些时间,服务关闭,我们收到错误消息。

An error example: 错误示例:

Traceback (most recent call last):
  File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 223, in Handle
    result = handler(dict(self._environ), self._StartResponse)
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~ono-hat-prod/1.365115032772094991/onohatpreprod.py", line 5541, in post
    cursor.execute("SELECT %s FROM actuaciones WHERE numero = '%s' " % (rc,idHat))
  File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 499, in execute
    self._DoExec(request)
  File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 375, in _DoExec
    response = self._conn.MakeRequest('Exec', request)
  File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 873, in MakeRequest
    response = self._MakeRetriableRequest(stub_method, request)
  File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 897, in _MakeRetriableRequest
    response = self.MakeRequestImpl(stub_method, request)
  File "/python27_runtime/python27_lib/versions/1/google/storage/speckle/python/api/rdbms_apiproxy.py", line 67, in MakeRequestImpl
    except apiproxy_errors.ApplicationError, e:
 DeadlineExceededError

Piece of code until the error occurs: 一段代码,直到出现错误为止:

class detalleActuacion(webapp2.RequestHandler):
    def post(self):
        idHat = self.request.get('id')
        logging.info(idHat)
        num_conexiones = 0
        num_cierres = 0
        conn = rdbms.connect(instance=_INSTANCE_NAME, database='Actuaciones')
        num_conexiones = num_conexiones + 1
        cursor = conn.cursor()

        dict_act = {}
        request_cad = 'solucionado,duracion,numero,fecha_inicio_ventana,fecha_fin_ventana,'
        request_cad = request_cad+'tipo,titulo,tipo_cliente,ubicacion,zona_regional,'
        request_cad = request_cad+'zona_local,ciudad_ticket,zona_regional_subticket,zona_local_subticket,'
        request_cad = request_cad+'zona_local_ticket,skill,num_recursos,num_actuaciones,ubi_emplaz,'
        request_cad = request_cad+'ubi_provincia,ubi_lat,ubi_long,ubi_via,ubi_calle,ubi_numero,ubi_adic,'
        request_cad = request_cad+'ubi_CP,miga_terminal,miga_tlf,miga_dir,severidad,prioridad,serv_CATV,'
        request_cad = request_cad+'serv_datos,serv_DTV,serv_empresa,serv_telefonia,instr,num_rep,'
        rc = request_cad+'fecha_creac,fecha_creac_tp,fecha_sol,fecha_sol_tp,fecha_cierre,fecha_cierre_tp,'
        rc = rc+'fecha_inicio,fecha_fin,descr_adic,descr_log,grupo_pos,accion,cola,estado,estado_ticket,'
        rc=rc+'doc_adj,detalle_equipos,tarea,subtarea,subzona,TIR,elem_red,descripcion,num_afectados,'
        rc=rc+'repeticion,fecha_repeticion,dias_repeticion,dias_semana,fin_repeticion,cl_afectados,'
        rc=rc+'plan_tp,marca_seguimiento,tipificacion,miga,zona,bandeja,alerta,descr_log1,descr_log2,descr_log3,descr_log4,descr_log5,descr_log6,descr_log7,descr_log8,descr_log9,'
        rc=rc+'elem_red_2,estado_CRM,tecnico,tecnico2,tecnico3,tecnico4,tecnico5,num_asignaciones,ultima_modificacion,tiempo_proceso,fecha_inicio_real,fecha_fin_real'
        rc=rc+',observaciones1,observaciones2,observaciones3,observaciones4,observaciones5,observaciones6,observaciones7,observaciones8,observaciones9,observaciones10'
        cursor = conn.cursor()
        cursor.execute("SELECT %s FROM actuaciones WHERE numero = '%s' " % (rc,idHat))

Thank you in advance for your assistance. 预先感谢您的协助。

If there are 45 concurrent requests, there may be many more open connections. 如果有45个并发请求,则可能会有更多打开的连接。 See What are the connection limits for Google Cloud SQL from App Engine, and how to best reuse DB connections? 请参阅App Engine中Google Cloud SQL的连接限制是什么,以及如何最佳地重用数据库连接?

You could also try increasing the instance size: more RAM may reduce the latency of each request and so reduce the number of connections. 您还可以尝试增加实例大小:更多的RAM可以减少每个请求的延迟,从而减少连接数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM