Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

391
Vistas
MySQL connection handling issues in PHP/PDO

I have migrated my PHP application to a serverless model where the cloud provider limits the amount of active connections between a container instance and the MySQL server. Sometimes during the week, this limit of 100 active connections to MySQL per container instance is exceeded . The SQL client library used in PHP is Medoo, an abstraction of PDO, we use PHP 7.3 and Slim Framework 3.

When checking the SHOW PROCESSLIST; from the MySQL server, it is possible to see several connections that are already old and with sleep status, why weren't they closed? According to the PDO documentation, PHP closes MySQL connections when finishing the script, are there any exceptions in this "end script" condition? When does the script ends? Is there some Apache or PHP config that may be avoiding this and causing the problem?

After contextualizing you, the reader, to the problem. My question is: What could be causing this? Are there any config in PHP or Apache that might be related to the issue? What should I pay attention to in the code? What would you try?

And no, we have not set persistent connections.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Unfortunately PDO does not have any functionality to configure connection limits.

In order to handle the db connections, GCP provide in it's official documentation some good practices to manage it.

In summary I suggest to try the following things:

  • Implement a connection pool so your connections are reuse.
  • Make sure to properly open and close the connections.
  • Handle properly broken or unsuccessful connections implementing timeouts.
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda