Use xhprof to analyze zabbix page performance problems

Source: Internet
Author: User
What is xhprof? Xhprof is a powerful tool for php performance analysis. Everything written in php should be clear. About the function: count the number of function calls. zabbix is always very unsatisfactory in terms of memory usage, CPU usage, and zabbix page performance. The page cannot be run. The page features are rich and powerful,

What is xhprof? Xhprof is a powerful tool for php performance analysis. Everything written in php should be clear. About the function: count the number of function calls. zabbix is always very unsatisfactory in terms of memory usage, CPU usage, and zabbix page performance. The page cannot be run. The page features are rich and powerful,

What is xhprof?

Xhprof is a powerful tool for php performance analysis. Everything written in php should be clear.

General functions:

  • Count the number of function calls
  • Memory usage
  • CPU usage
  • ...
Zabbix page Problems

The performance of zabbix has always been very disappointing, and some pages cannot be run.

The page features are rich and powerful, but the performance is not enough.

One problem we encountered recently is that the page screens. php is very slow to open, and

Switching hosts is also very slow. On average, you need to wait for 15 s. A lot of colleagues complained.

So, let's analyze the problem with xhprof.

Troubleshoot packet capture
  • First, packet capture tests were conducted when both complaints were slow. It was found that a large number of events were consumed while waiting for the server to respond,

After the page is refreshed, it is found that the loading event of each chart is very short, which means that the problem is not data loading, but the whole page.

.

  • Second, when testing with other accounts, we found that the loading speed was related to the account. Further tests showed that the super administrator's

The speed is very low, while the speed of other accounts is basically the same.

The biggest difference between accounts is the difference in permission checks-Super administrators do not need permission checks.

Now remember to use xhprof to analyze the next page.

  • Packet Capture analysis results:

Xhprof Analysis

Configuration and use are not mentioned much. You can use Baidu on the Internet.

Paste an analysis result:

We can intuitively see that a large number of events are wasted on the CScreen: get call. The problem is very simple. Let's take a look at this part of the code.

Analyze code

Screen: get this is an api call, so the code path is in api/classes/CScreen. php. Let's take a look at the get method.

Soon I found something suspected:

// editable + PERMISSION CHECK                if ($userType == USER_TYPE_SUPER_ADMIN || $options['nopermissions']) {                }                   elseif ($result) {                        $groupsToCheck = array();                        $hostsToCheck = array();                        $graphsToCheck = array();                        $itemsToCheck = array();                        $mapsToCheck = array();                        $screensToCheck = array();                        $screensItems = array();                        $dbScreenItems = DBselect('SELECT si.* FROM screens_items si WHERE '.dbConditionInt('si.screenid', $screenIds));                        while ($screenItem = DBfetch($dbScreenItems)) {

As you can see, if it is a Super User, no permission check is performed. Otherwise, a very complicated permission check process is performed.

I printed the corresponding SQL statement and found that it was very long and executed for up to 4.8 s, which is consistent with the DBselect in the preceding xhprof diagram.

The speed is also slow.

Solution

After the code has been located, the solution is no longer a problem. Simply comment it out.

Verification results

Try again to capture the package:

Original article address: xhprof is used to analyze zabbix page performance problems. Thank you for sharing it with me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.