Ad Widget

Collapse

Multiply the speed of your zabbix server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bbrendon
    Senior Member
    • Sep 2005
    • 870

    #16
    Originally posted by Palmertree
    Do an http watch and you will notice that javascripts and css sheets will be pulled in frequently between pages. Also, they do not get compressed in there native format unless converted to php. With this fix, you can change the expired time to 6 hours or whaver you like. We have seen a very good turn around on performance doing this. Especially on slow connections.
    Have you used the deflate and expires modules? They address these issues.
    Unofficial Zabbix Expert
    Blog, Corporate Site

    Comment

    • dugrands
      Junior Member
      • Dec 2008
      • 13

      #17
      Hi guys, I have been doing further analysis of the overview page of one of my zabbix installations that has almost 200 hosts and realized that another huge performance problem comes from the way the hostnames are inserted into the page using the vtext.php file.

      When loading the page, it takes about 9 seconds to load overview.php(8 seconds for page generation and about 1 second for downloading the resulting html). All the css files, js files and images are cached locally by default by my browser (chromium on openSuse). However the problem comes after the overview page has been downloaded and the browser starts to load each individual vtext.php for the names (obviously not cached locally because it's php script) which is what takes about 20 more seconds thus bringing the total time to around 30 seconds.

      My idea is that the image files used in the labels for the name not be generated on the fly, rather have a pool of those images already created on the drive when hosts are added (I doubt space would be a problem for such small images) so that they can be cached automatically by the browsers.

      I had also thought of using vertical text (css) but then realized that IE would not render the text correctly.

      I (maybe everyone else too) would be grateful for other ideas on how to circumvent this problem and if the solution could probably be included in the next version of zabbix as I am expecting the number of hosts to top 400 in that server of mine in a couple of months.

      BTW. Thanks Alexei for the great product, it really beats everything else!
      Last edited by dugrands; 11-11-2009, 13:25.

      Comment

      • bek99
        Junior Member
        • May 2009
        • 9

        #18
        Depending how crazy you want to get, you could "smush" the png images and minify all the static js & css files as well. APC is also a good call (I prefer APC primarily due to plans of it shipping with php6, but x-cache would probably do well as well.)

        Comment

        • dugrands
          Junior Member
          • Dec 2008
          • 13

          #19
          The actual problem is not the sizes of the png files as they are already compressed by the deflate module in apache. It's the latency that exists from when the browser sends a request and finally when it starts receiving the image, which takes around 300ms to 800ms, and now you multiply that by 200 as the browser's do tend to fetch each individual image sequentially. The idea is to make the link a .png directly so that the browsers can cache the images thus eliminating the need for those small but numerous latencies.

          Comment

          • linuxgurugamer
            Member
            • Oct 2010
            • 66

            #20
            Script for 1.8.3 to change Javascripts to PHP

            I've taken this information and written a small shell script which converts all the Zabbix Javascript files to PHP files, and also modifies the jsLoader.php file to properly load them.

            Instead of adding lines to the beginning of each javascript, I simply copied them to new files with .php appended to the name, and then modify the jsLoader.php to include the files. I put the necessary header lines into a file called js.header.php, and include that before I include the javascript files.

            To use:

            BACKUP YOUR ENTIRE DIRECTORY FIRST!!!!!!!

            The shell script was gzip'd to allow uploading.

            Put both files into your Zabbix root directory.

            Run the script: js-to-php-convert.sh
            The script will take a few minutes to run, while running it will display each PHP file name as it is being converted.

            During the process the web frontend will stop working. When the process is complete, simply refresh the page.
            Attached Files

            Comment

            • Sparky
              Member
              • Jun 2010
              • 54

              #21
              Hi Guys

              Sorry for digging up an old thread.

              I have tried the suggestions in this thread, as well as some others I found, but I cannot seem to get the compression up and running.

              mod_deflate is enabled, and I have made the change in the deflate.conf file to show what should be compressed, but in the deflate.log file I have enabled I am not showing any entries. Is there anything I am missing? Running Ubuntu Server 10.04

              Comment

              • dugrands
                Junior Member
                • Dec 2008
                • 13

                #22
                reduced time to load overview.php in half

                No problem Sparky, maybe this link will help:
                Description: mod_deflate is an Apache module which “provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.&#…


                Actually I have been thinking of updating the thread as well. Forgive me for this post may end up being too long you may skip directly to THE SOLUTION if you like.

                After continued growth the number of hosts in my zabbix setup have more than doubled and we are monitoring more items. Since everyone in my company loves the overview page (despite having all the relevant information on the dashboard) I have been asked to re optimize the overview page again since it started to take about 24+ seconds to load. CPU, memory and IO loads are almost non existent on the server so I figured it is not about lack of resources. Using the chrome tools I noticed that the server spends roughly 12 seconds before giving a response on the overview.php request which gets downloaded in .5 seconds and the other 12+ seconds is spent downloading the vtext.php files for each host (in host location = top mode) so I ended up hacking the way the overview.php is created so that instead of using images, it uses vertical text thus avoiding the vtext.phps all together.

                I am no expert in CSS so my solution is not complete and will not work with ie 9 and most probably many other older browsers. I only tried the solution with the latest chrome and firefox which worked then forced the rest of the company to switch to either of the two since I could not invest more time to investigate ie. I am sure that someone can and will perfect my solution, and if you do, please share it on the forum for everyones benefit.

                THE SOLUTION
                This slashed the time necessary to load the my overview page by half. All files' locations are respective to the zabbix php frontend root folder.


                step1: open /include/triggers.inc.php and change the line
                $header = array_merge($header,array(new CImg('vtext.php?text='.$hostname)));
                to
                $header = array_merge($header,array(new CVText($hostname)));
                step2: open /include/triggers.inc.php and change the line
                $descr = array(new CImg('vtext.php?text='.$descr));
                to
                $descr = array(new CVText($descr));
                step3: repeat steps 1 and 2 but for the file /include/items.inc.php

                step4: download class.cvtext.php and put it in the /include/classes folder

                step 5: open /styles/default.css and add the following

                .tVertical {
                margin: 0;
                padding: 5px;
                list-style-type: none;
                line-height: 1em;
                }

                .tRotateVertical {
                writing-mode: tb-rl;
                -webkit-transform:rotate(270deg);
                -moz-transform:rotate(270deg);
                -o-transform: rotate(270deg);
                display:block;
                padding: 0;
                margin: 0;

                }
                step6: open /styles/table.css and make sure the 'table.tableinfo tr.vertical_header td' rule looks like the following: special note on the "vertical-align: bottom;" part

                table.tableinfo tr.vertical_header td {
                padding-left: 0px;
                padding-right: 0px;
                padding-top: 5px;
                padding-bottom: 5px;
                margin: 0px;
                white-space: nowrap;
                word-spacing: 0px;
                font-weight: bold;
                background-color:#CCCCCC;
                vertical-align:bottom;
                text-align: center;
                width: 20px;
                }
                step7: cross your fingers and load the overview.php page in your browser. By the way, did I mention you should make a backup of all the files before you modify them in case you do not like the end result?
                Attached Files

                Comment

                • dugrands
                  Junior Member
                  • Dec 2008
                  • 13

                  #23
                  having found a semi solution for the vtext.php problem, I realize that the time to cut the loading of the overview.php could still be reduced if the time to calculate the table object could be reduced.
                  On my setup the server takes roughly 12 seconds from the time it receives the request to the time it returns the page. during that time cpu usage is never more than 40% (usually it's around 2 - 5%), load averages are never more than 0.6 on a quad core processor, free memory is around 2 GB and iowait is almost always 0.00 only rising to 0.10 when it does. In other words, I do not understand why the 12 seconds when the server is apparently not stressed in any way.
                  If anyone has an idea, please share it. Maybe Alexei could help us here.
                  I wonder if it's possible to drive the overview.php load time to a sub second value, maybe using some sort of caching or optimized queries..

                  Comment

                  • skogan
                    Member
                    • Nov 2007
                    • 70

                    #24
                    I have modified the previous solution to use inline SVG. After some trial and error I came up with a solution that displays vertical text in overview screen reliably for both the new browsers (FF 3, Chrome) and the old ones, even if they don't support SVG at all (fallback to vtext.php).
                    The solution had a significant effect on performance of the overview screen in my setup.

                    To set it up:
                    1. Copy the attached svgvtext.inc.php file into the include/classes directory.

                    2. In include/config.inc.php

                      add in the Include Classes section

                      PHP Code:
                      require_once('include/classes/svgvtext.inc.php'); 
                    3. In include/items.inc.php and include/triggers.inc.php
                      replace

                      PHP Code:
                      $header=array_merge($header,array(new CImg('vtext.php?text='.$hostname))); 
                      with

                      PHP Code:
                      $header=array_merge($header,array(new SVGVText($hostname))); 
                      and

                      PHP Code:
                      $header=array_merge($header,array(new CImg('vtext.php?text='.$descr))); 
                      with

                      PHP Code:
                      $header=array_merge($header,array(new SVGVText($descr))); 



                    Let me know how this solution works in your environment, especially if you serve large overview screens.
                    Attached Files

                    Comment

                    • untergeek
                      Senior Member
                      Zabbix Certified Specialist
                      • Jun 2009
                      • 512

                      #25
                      It would be nice to incorporate this into the base install, if it does as you say.

                      What do you say, richlv? Anyone else?

                      Comment

                      • skogan
                        Member
                        • Nov 2007
                        • 70

                        #26
                        I think it should be tested on some large systems before that - my patch increases the size of the overview screen significantly, plus there is a lot of base64 encoding going on. It might slow things down noticeably in some cases.

                        Also, the SVG it generates is not theme-friendly. This, however, should be an easily correctable problem.
                        Last edited by skogan; 20-12-2010, 21:01.

                        Comment

                        Working...