The thing is I have a cronjob that repeats itself every 2min & calls a php script which does some mysql query.. now that thing is making mysql very busy which in the process is consuming too much memory.. my allocated RAM is 2GB.. it’s getting used in like 4hours or so then in couple of hours the extra VSwap of 2GB is getting used. then it simply crashes giving mysqli::real_connect(): (HY000/2002): Connection refused
I am not exactly sure what is wrong.. I know a cron that calls a mysql query every 2min might be a bad call.. but I donno how to manage it otherwise.. so I need a solution. I am using a CentOS 6.6 Server
Advertisement
Answer
I was using Codeigniter 3. There were some persistent connections. I had set the pconnect
to FALSE
. but that did not work so I added a destructor
to close the connection.
public function __destruct() { $this->db->close(); }
That sorted it. Thanks to all for your responses. I thought it was some server issue and I did not provide enough information in the question. It was stupid.