My website has not that many visits (let’s say that at best I have 100 users connected at the same time) and when I watch the stats on my mysql server I can see that I have up to 70 simultaneous connections to the mysql server!
I think that the problem come from Yii that is not closing the connections, so they stay idle until the wait_timout value is reach and then mysql closes theses connections.
How can I force Yii to close the db connection when there are no more requests to perform?
that’s on MySQL side to decide when to close temporary connections. what’s the status of command? sleep? if sleep then don’t worry or configure your MySQL to kill connections faster
on other hand,
If you want only 1 persistent connection to db and agree with all problem you may have to gain (decent) performance on connection bubbling, just add to config in db section
'db' => [
'persistent' => true
....
]
p.s.
but with 100 users you will not notice performance from persistent connection, only troubles
This is an apache webserver, I’m using PHP-FPM. No crons are defined during the day, and I only have two small ones at night.
But since it’s not a Yii problem I think I’ll try to find where the bottleneck comes from, but for that I need to wait that a lot of people are connected (in general between 6 and 10 pm)