Its running all latest PHP and MySQL and cloudlinux.
Since last few weeks, after the MySQL upgrade was done, both sites are crazy slow at loading, and goes down multiple times, whenever few traffic comes.
I contacted cloudlinux and they said, both sites MySQL is killing the server.
Hello,
As I can see, the server is overloaded at the moment due to high amount of SELECT queries. Please check attached log.
According to perf top, most of the time MySQL stacks on JOIN::exec:
# perf top -g
- 92.42% 0.01% libc-2.12.so [.] __GI___ioctl ◆
- __GI___ioctl ▒
- 50.82% my_pthread_lvemutex_lock ▒
- 97.18% key_cache_read ▒
- _mi_fetch_keypage ▒
- 99.70% _mi_search ▒
- 73.98% mi_rkey ▒
99.99% ha_myisam::index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function) ▒
- handler::ha_index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function) ▒
- 81.65% 0xce2a39 ▒
- sub_select(JOIN*, QEP_TAB*, bool) ▒
- 89.94% 0xce618e ▒
- sub_select(JOIN*, QEP_TAB*, bool) ▒
- 53.28% 0xce618e ▒
- sub_select(JOIN*, QEP_TAB*, bool) ▒
- 73.77% JOIN::exec() ▒
handle_query(THD*, LEX*, Query_result*, unsigned long long, unsigned long long)
+-------+------------------+-----------+---------------------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-------+------------------+-----------+---------------------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| 4 | lvestats2 | localhost | db_lvestats2 | Sleep | 1 | | |
| 29970 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 3 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30004 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30032 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 3 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30082 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30105 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30128 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 19 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30153 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30156 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30159 | superbik_clients | localhost | superbik_devnew | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30161 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30164 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30165 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30166 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30167 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30171 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30174 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30176 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30178 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30180 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30181 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30185 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30188 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30189 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30197 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30199 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30203 | superbik_clients | localhost | superbik_devnew | Query | 4 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30204 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30210 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30212 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30215 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30216 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 2 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30218 | qubesys_clients | localhost | qubesys_new-qube-db | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30220 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30221 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30222 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30223 | superbik_clients | localhost | superbik_devnew | Query | 1 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30228 | superbik_clients | localhost | superbik_devnew | Query | 5 | Sending data | SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_catego |
| 30232 | root | localhost | | Query | 0 | starting | show processlist |
+-------+------------------+-----------+---------------------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
In catalog/controller/common/footer.php file,
find:
Code: Select all
$data['scripts'] = $this->document->getScripts('footer');
Code: Select all
if ((!empty($this->session->data['user_token']) || (!empty($this->session->data['token']))) && defined("PRINT_STATS") && PRINT_STATS == 1) {
//-----------------------------------------------------
//--- GZip Compression Monitor ------------------------
//-----------------------------------------------------
$do_gzip_compress = 0;
if ($this->config->get('config_compression')) {
if (get_php_version() >= 40004) {
if (extension_loaded("zlib")) {
ob_start("ob_gzhandler");
}
} elseif (get_php_version() > 40000 && isset($this->request->server['HTTP_ACCEPT_ENCODING'])) {
if (preg_match("/gzip/i", $this->request->server["HTTP_ACCEPT_ENCODING"]) || preg_match("/x-gzip/i", $this->request->server["HTTP_ACCEPT_ENCODING"])) {
if (extension_loaded("zlib")) {
$do_gzip_compress = 1;
ob_start();
ob_implicit_flush(0);
}
}
}
}
$start_time = microtime();
$starttime = explode(" ", $start_time);
$endtime = explode(" ", microtime());
$total_time = $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1];
$sql_time = $this->db->getQueryTime();
$php_time = $total_time - $sql_time;
$gzip_text = ($this->config->get('config_compression') ? "GZIP compression enabled" : "GZIP compression disabled");
$gzip_text .= ($this->config->get('config_compression') && !extension_loaded("zlib") ? "*" : "");
printf("<p align=\"center\"><font size=\"-2\">Page generated in %f seconds with ".$this->db->getQueryCount() . " queries, spending %f seconds doing MySQL queries and %f doing PHP things. $gzip_text</font></p>", $total_time, $sql_time, $php_time);
}
if ((!empty($this->session->data['user_token']) || (!empty($this->session->data['token']))) && defined("PRINT_QUERIES") && PRINT_QUERIES == 1) {
echo implode('<br><br>', $this->db->getQueryArray());
}
if ((!empty($this->session->data['user_token']) || (!empty($this->session->data['token']))) && $do_gzip_compress && isset($this->request->server['HTTP_ACCEPT_ENCODING'])) {
if (preg_match("/gzip/i", $this->request->server['HTTP_ACCEPT_ENCODING'])) {
$encoding = "gzip";
} elseif (preg_match("/x-gzip/i", $this->request->server["HTTP_ACCEPT_ENCODING"])) {
$encoding = "x-gzip";
}
$gzip_contents = ob_get_contents();
ob_end_clean();
if (defined("PRINT_STATS") && PRINT_STATS == 1) {
$s = sprintf ("\n<!-- Use Encoding: %s -->", $encoding);
$s .= sprintf("\n<!-- Not compress length: %s -->", strlen($gzip_contents));
$s .= sprintf("\n<!-- Compressed length: %s -->", strlen(gzcompress($gzip_contents, $this->config->get('config_compression'))));
$gzip_contents .= $s;
}
$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, $this->config->get('config_compression'));
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
header("Content-Encoding: $encoding");
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack("V", $gzip_crc);
echo pack("V", $gzip_size);
}
find:
Code: Select all
private $connection;
Code: Select all
private $query_time = 0;
private $query_count = 0;
private $query_array = array();
Code: Select all
$result->rows = $data;
Code: Select all
if ((defined("PRINT_QUERIES") && PRINT_QUERIES == 1) || (defined("PRINT_STATS") && PRINT_STATS == 1)) {
$startsqltime = explode(" ", microtime());
$endsqltime = explode(" ", microtime());
$totalsqltime = round($endsqltime[0] - $startsqltime[0] + $endsqltime[1] - $startsqltime[1], 3);
$this->query_time += $totalsqltime;
$this->query_count++;
}
if (defined("PRINT_QUERIES") && PRINT_QUERIES == 1) {
$query_stats = htmlentities($sql);
$query_stats .= "<br><b>Querytime:</b> ".$totalsqltime;
$this->query_array[] = $query_stats;
}
Code: Select all
public function escape($value) {
Code: Select all
public function getQueryCount() {
return $this->query_count;
}
public function getQueryTime() {
return $this->query_time;
}
public function getQueryArray() {
return (array)$this->query_array;
}
find:
Code: Select all
/**
*
*
* @param string $value
*
* @return string
*/
public function escape($value) {
Code: Select all
public function getQueryCount() {
return $this->adaptor->getQueryCount();
}
public function getQueryTime() {
return $this->adaptor->getQueryTime();
}
public function getQueryArray() {
return $this->adaptor->getQueryArray();
}
Code: Select all
define('PRINT_STATS', 1);
define('PRINT_QUERIES', 0);
Code: Select all
define('PRINT_STATS', 1);
define('PRINT_QUERIES', 1);
0 = Disable
To test this, login to your OC admin. Then, select your store and see the query results at the top of your store. I would suggest activating the PRINT_STATS only for now from your config.php file before jumping to the PRINT_QUERIES.
What is the text that you see on top of the site?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
With the use of VQMod and VQMod Manager, that shouldn't happen.Im afraid, something might get broken if I try your steps.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: dparakhiya and 420 guests