1

Well I have an issue with a Codeigniter application and the database connections. As far as I've read on the Internet, CodeIgniter uses singleton to handle instances of the objects, such as the database object. So, with this, I understand that always that there is an instance of the database live there would be only 1 connection in mysql (I am using mysql).

So, I am using an Ajax cross domain request to save "visits" of several sites in different servers in a centralized database. The problem now is that as the sites that I am saving the requests from are worldwide I am getting a huuuuge amount of requests, I have no problem saving the data in the database, the server is very powerful, the thing is that some how, every time a request happen the I have a bran new connection to the database, so I am getting more than 1000 live connections in mysql per minute... and then mysql crashes because it only supports up to 9000 live connections.

Isn't is supposed that using singleton (natively by codeigniter) I would only have 1 live connection and not one per request?

Thank you all for reading, hope you can help with this.

Regards

andres.gtz
  • 624
  • 12
  • 22
  • 1
    You are mixing things here, PHP scripts usually doesn't run for ever & every request will create a new CodeIgniter instance + a new database connection, If your database connections aren't getting closed on shutdown then you have to check the database config file /config/database.php & make sure you have pconnect set to FALSE, – ahmad Mar 21 '15 at 16:51
  • That was actually it, pconnect set to FALSE. – andres.gtz Mar 23 '15 at 16:25

0 Answers0