Knowledge base
1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!
Understanding MySQL / MariaDB Connection Durations
This technical guide details the resource limits for Infomaniak Web Hosting; it is essential to distinguish between real time (clock time) and processing time (CPU time) to understand the cause of script interruptions.
1. MySQL connection time (I/O)
Limit: 30 seconds (actual time)
This limit corresponds to the absolute time elapsed, measured "as the clock ticks". 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 time limit is exceeded (often due to a poorly optimized SQL query), the MySQL server abruptly terminates the connection. This usually generates the MySQL server has gone away error.
2. PHP processing time (CPU)
Limit: 10 seconds CPU
This limit applies exclusively to the processing power consumed by the web server to execute PHP code.
It is crucial to note that the waiting time does not count. When PHP is waiting for a response from the database, it is paused and consumes almost no CPU time. Therefore, a script will only be interrupted by the web server if it performs intensive calculations (complex loops, cryptography, file processing) for more than 10 seconds cumulatively.
Interaction of the two limits
To ensure the application's stability, each operation must simultaneously meet these two distinct constraints:
- The application has a total of 30 seconds to interact with the database (network latency + SQL execution).
- The application has 10 seconds of pure processing time to handle 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 individual quotas, even though the total time is 27 seconds.
Link to this FAQ: https://faq.infomaniak.com/481
Has this FAQ been helpful?