I'm running Zabbix server 1.6.2, monitoring ~400 hosts /~5000 items / ~2500 triggers. Everything used to be OK, but soon after upgrading to 1.6, the graphs page loading time went up to 20 minutes.
I discovered, that with old frontend (I believe it was 1.5.something), things were still fast and as a workaround, I used this for a while, but now I would like to get latest version to work as fast, as it was before.
So I looked the database processlist and found that there were two queries that took long time - they both located in include/graphs.inc.php in this function:
When they are executed, database is really working hard - I can say this based on the cpu utilization maxed out and load is also high depending on the amount of queries.
MySQL SHOW PROCESSLIST is saying, that query is 'Sending data' for the whole time.
I've tried to use database optimizing tools such as mysqltuner-1.0.0.pl and tuning-primer.sh and tested many MySQL memory configurations.
I also learned, that when running for about a day, there are 5000 joins that are performed without indexes.
Since I've been using Zabbix by upgrading from one of the earliest versions, I re-checked that I have the same database structure and indexes as in the latest release. There were few indexes missing, but they weren't in in any of tables used by this function.
At the moment there are no index on trends nor trends_uint table, only primary keys. Is this how it's supposed to be?
And another thing - I don't know if this has anything to do with it, but I've set ZBX_MAX_PERIOD to 3 years and ZBX_PERIOD_DEFAULT to 24h in include/defines.inc.php.
my total database size 24GB
trends table holding ~60M records > 4GB
trends_uint table holding ~4.5M records > 300MB
graphs_items table holding ~5.5M records > 700KB
Current MySQL configuration:
table_cache = 256
tmp_table_size = 512M
max_heap_table_size = 512M
join_buffer_size = 8M
query_cache_limit = 32M
query_cache_size = 64M
key_buffer_size = 16M
innodb_file_per_table
innodb_buffer_pool_size = 1500M
max_allowed_packet = 16M
thread_stack = 128K
thread_cache_size = 8
sort_buffer_size = 8M
long_query_time=5
log-slow-admin-statements
log-queries-not-using-indexes
log-slow-queries=/var/log/mysql_slow-queries.log
Database server
MySQL 5.0.45
64bit Oracle Enterprise Linux 5
2 Xeon 3.4GHz CPU
6G RAM
Application server
32bit Oracle Enterprise Linux 5
1 Xeon 3GHz CPU
3G RAM
Is there anything else I can do to find the cause of this problem?
I discovered, that with old frontend (I believe it was 1.5.something), things were still fast and as a workaround, I used this for a while, but now I would like to get latest version to work as fast, as it was before.
So I looked the database processlist and found that there were two queries that took long time - they both located in include/graphs.inc.php in this function:
Code:
/*
* Function: get_min_itemclock_by_graphid
*
* Description:
* Return the time of the 1st apearance of items included in graph in trends
*
* Author:
* Aly
*
*/
function get_min_itemclock_by_graphid($graphid){
$min = 0;
$row = DBfetch(DBselect('SELECT MIN(t.clock) as clock '.
' FROM graphs_items gi, trends t '.
' WHERE gi.graphid='.$graphid.
' AND t.itemid = gi.itemid'));
if(!empty($row) && $row && $row['clock'])
$min = $row['clock'];
$row = DBfetch(DBselect('SELECT MIN(t.clock) as clock '.
' FROM graphs_items gi, trends_uint t '.
' WHERE gi.graphid='.$graphid.
' AND t.itemid = gi.itemid'));
if(!empty($row) && $row && $row['clock'])
$min = $min == 0 ? $row['clock'] : min($min, $row['clock']);
return $min;
}
MySQL SHOW PROCESSLIST is saying, that query is 'Sending data' for the whole time.
I've tried to use database optimizing tools such as mysqltuner-1.0.0.pl and tuning-primer.sh and tested many MySQL memory configurations.
I also learned, that when running for about a day, there are 5000 joins that are performed without indexes.
Since I've been using Zabbix by upgrading from one of the earliest versions, I re-checked that I have the same database structure and indexes as in the latest release. There were few indexes missing, but they weren't in in any of tables used by this function.
At the moment there are no index on trends nor trends_uint table, only primary keys. Is this how it's supposed to be?
And another thing - I don't know if this has anything to do with it, but I've set ZBX_MAX_PERIOD to 3 years and ZBX_PERIOD_DEFAULT to 24h in include/defines.inc.php.
my total database size 24GB
trends table holding ~60M records > 4GB
trends_uint table holding ~4.5M records > 300MB
graphs_items table holding ~5.5M records > 700KB
Current MySQL configuration:
table_cache = 256
tmp_table_size = 512M
max_heap_table_size = 512M
join_buffer_size = 8M
query_cache_limit = 32M
query_cache_size = 64M
key_buffer_size = 16M
innodb_file_per_table
innodb_buffer_pool_size = 1500M
max_allowed_packet = 16M
thread_stack = 128K
thread_cache_size = 8
sort_buffer_size = 8M
long_query_time=5
log-slow-admin-statements
log-queries-not-using-indexes
log-slow-queries=/var/log/mysql_slow-queries.log
Database server
MySQL 5.0.45
64bit Oracle Enterprise Linux 5
2 Xeon 3.4GHz CPU
6G RAM
Application server
32bit Oracle Enterprise Linux 5
1 Xeon 3GHz CPU
3G RAM
Is there anything else I can do to find the cause of this problem?

Comment