<?php
// Connect to mysql server
$link = mysql_connect(HOST, USER, PASSWORD);
if(!$link) {
die('Could not connect to server: ' . mysql_error());
}
// Select database
$db = mysql_select_db(DATABASE);
if(!$db) {
die('Cannot use the database');
}
mysql_set_charset('charset=utf8', $link);
//code
?>
I am php beginer.I have written a simple php HTTP API which read some data from database and return in body. This API is accessed by many uses application asynchronously . When we increase the number of user more than 200 each second, i nam getting following warning
PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections in /home/ws/public_html/include/get_details.php on line 3
I want to know best solution for it.
Thanks
first you can use mysqltuner to check your db status. Other solution, use redis or memcache to reduce the connections. If you have your sessions stored in DB, try to change and use redis. phpredis
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.