CodeIgniter database connections not being closed

前端 未结 6 1409
灰色年华
灰色年华 2021-02-05 04:48

I have built a social community website in CodeIgniter which is now getting a fair bit of traffic, the hosting company have started complaining and saying that the database is r

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 05:52

    I had that same issue a while back, and the solution was multi-part (no single part of the problem surfaced until all parts became problematic together). PConnect should be off unless you know how to use it (as others have said).

    Another thing to consider is whether your web server is threaded (such as Apache's worker mode--most common web servers are). If you're getting a lot of traffic, and your threads aren't closing quickly, you might be hitting some concurrent web server / database server connection limits, or exhausting memory/processor resources. That could cause some database connections to hang.

    So, I'd check for other signs of the problem, and not assume the database is the source. It could very well be a symptom. Do you have any information about the null connections (like which database user spawned them)? That could help you trace it back...

    Edit: One thing I forgot--sometimes PHP errors can screw up CI's destruct operations (which automatically close the connections, from my understanding), so you might check your error logs too.

提交回复
热议问题