1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Understanding MySQL / MariaDB connection durations
This technical guide details the resource limits on Infomaniak's web hostings; it is essential to distinguish real time (clock) from processing time (processor) to understand the origin of script interruptions.
1. MySQL connection time (I/O)
Limit: 30 real seconds
This limit corresponds to the absolute time elapsed "clock in hand". It concerns the communication between PHP and the database server (MySQL/MariaDB).
As soon as a connection is opened, the database server allocates a maximum of 30 seconds to receive the request, execute it, and return the results. If this deadline is exceeded (often due to a poorly optimized SQL query), the MySQL server abruptly cuts the connection. This usually generates the error MySQL server has gone away.
2. PHP processing time (CPU)
Limit: 10 CPU seconds
This limit concerns exclusively the computing power consumed by the web server to execute the PHP code.
It is crucial to note that waiting time does not count. When PHP waits for a response from the database, it is paused and consumes almost no CPU time. Consequently, a script will be interrupted by the web server only if it performs intensive calculations (complex loops, cryptography, file processing) for more than 10 cumulative seconds.
Interaction of the two limits
To ensure the stability of the application, each operation must simultaneously respect these two distinct constraints:
- The application has 30 seconds of total time to interact with the database (network latency + SQL execution).
- The application has 10 seconds of pure computing time to process the received data.
Example of valid operation: A script that waits 25 seconds for a complex response from MySQL (I/O) and then processes the result for 2 seconds (CPU) will work perfectly, as it has not exceeded either of the two individual quotas, even if the total time is 27 seconds.