Suppose you have a php CLI file that runs every 2 minutes to perform MySQL data write operations.
If you use Corntab or MQ, every execution is
- Establish a MySQL connection
- Performing Bulk writes
- PHP manually end MySQL connection (actually MySQL connection is not finished, just PHP release)
- PHP ends Running free memory
- At this point, MySQL connection handles the sleep state
- After 2 minutes, execute 1 ~ 5 again
The script every 2 minutes, 24 hours down, MySQL will produce a lot of sleep connection, even if the optimization of MySQL wait_timeout thread_cache_size These parameters are not used?
If it is while (true), PHP uses pconnect only to establish a MySQL connection, as long as the PHP process is running, will never release MySQL connection right?
Does this save MySQL connections, thereby reducing the pressure on MySQL servers?
Reply content:
Suppose you have a php CLI file that runs every 2 minutes to perform MySQL data write operations.
If you use Corntab or MQ, every execution is
- Establish a MySQL connection
- Performing Bulk writes
- PHP manually end MySQL connection (actually MySQL connection is not finished, just PHP release)
- PHP ends Running free memory
- At this point, MySQL connection handles the sleep state
- After 2 minutes, execute 1 ~ 5 again
The script every 2 minutes, 24 hours down, MySQL will produce a lot of sleep connection, even if the optimization of MySQL wait_timeout thread_cache_size These parameters are not used?
If it is while (true), PHP uses pconnect only to establish a MySQL connection, as long as the PHP process is running, will never release MySQL connection right?
Does this save MySQL connections, thereby reducing the pressure on MySQL servers?
A CLI 2 minutes to run and no concurrency, just to see the database read the operation if there is a read-write separation on the solution. Optimizing PHP Connection Pooling This is too difficult.