We have a dedicated server with 8 GB of RAM and PHP5.3 with MySQL 5.1
The maximum number of concurrent connections is about 500, and each connection performs 1-2 SELECT queries in smaller tables with user data, and then INSERT in a large transactions table. Selection requests did not take up much space, and we added monitoring between each request to see the response time of each request, and there were never any problems.
We have added tracking to our code, and sometimes this results in some simple INSERT queries taking 14-15 seconds. This query, listed below, sometimes takes 14 seconds, sometimes 6 seconds, sometimes 0.2 seconds or less. What could be the problem?
PHP code that sometimes returns these huge delays:
$starT = microtime(true); echo '×tampTS_02='.(microtime(true) - $startT); mysqli_query($GLOBALS['con'],"INSERT INTO `transactions` (`id`,`data`) VALUES('id','some_data')") or die(mysqli_error($GLOBALS['con'])); echo '×tampTS_03='.(microtime(true) - $startT);
There are about 2 million records in the transactions table.
CREATE TABLE IF NOT EXISTS `transactions` ( `id` int(11) NOT NULL, `data` varchar(1000) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
source share