ISPConfig-3 nginx PHP-FPM first 2 sites fast

Discussion in 'General' started by minyor, Jan 20, 2019.

  1. minyor

    minyor New Member

    I installed Debian 9 and ISPConfig-3 with nginx, PHP-7.0. I used this tutorial:

    I have about 10 PHP wordpress sites and they works correctly but I noticed that sometimes some of them reload pages twice as fast then the other. After some time testing I found out that if I restart "service php7.0-fpm restart" and then reload pages for two randomly chosed sites, then these 2 sites from now on become twice as responsive compared to the rest of my sites...

    The first two then refreshing in 1 second, the rest refreshing in 2 or more seconds depending on site.
    There's no errors in log/error.log
    Had someone experienced this? Where should I start to look?
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    First time I see complaints of Wordpress site loading too fast.
    My first quess is the page loads from your browser cache. Have you tried another browser or from another workstation? On the other hand, it is strange that only two sites would fit in to that cache.
    Maybe it is you web server that has enough memory to cache two websites, and the rest are read from disk.
    You could get some numbers for load times with pingdom tools. . Or are those 1 second and 2 second times already accurate measurements?
  3. minyor

    minyor New Member

    Hi, Teleman, thanks for the response and the suggestion.
    I apologies, I typo-ed, I meant ~2 second versus ~0.5 seconds refresh time.
    It really would be nice for cache to be on for all of my sites or at least so I control the ones to be cached..

    I tried test 2 first fast refreshing sites, here are the results (The first 2 are properly cached):
    Performance grade C75
    Page size 6.0 MB
    Load time 2.04 s
    Requests 84
    Performance grade C76
    Page size 3.2 MB
    Load time 3.27 s
    Requests 97
    Performance grade C76
    Page size 3.0 MB
    Load time 2.23 s
    Requests 88

    The test seem to show real not cached speed and it seem about right.
    The first time I refresh them in browser load time is comparable next time all my sites are get cached and get loaded for about ~1sec.
    But first 2 sites get loaded in ~0.5 sec when cached... And this behavior changes when I reload PHP-FPM.
    So I wonder if I can somehow force all of them to load for ~0.5 sec? That would be great! But how..

    So I guess, my problem that my other sites does not getting fully cached ether on server side or client side and are keep loading full time or halve time when I refresh them.
    If it's on server side, can it be "mariadb" settings I can temper with to force them to cache?
    Is there any log files related to caching process I could look into?
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    The server caches disk reads in memory. So how much memory does your server have?
    Install dstat (apt-get install dstat) and keep this running while your web server is running:
    dstat --disk-tps --disk-util -c --mem -s --load 10 360
    It may be your database performance, too but that should also be faster if the access happens from cache memory.
    Are you sure it is not that some websites have more plugins or some such, that make them slower to load?
  5. minyor

    minyor New Member

    I have 8GB of ram, Intel Atom 8 cores, 1TB hdd.
    All sites are different, some have more plugins, some less but any of them consistently about 2 times faster if I do restart PHP-FPM and refresh selected site first.
    They are all redeployed from an old server that was based on "ISPManager" with apache and on it subjectively, they was running full cached, less than 1 sec refresh time..

    htop shows: 5.38G/7.79G

    -dsk/total- sda- ----total-cpu-usage---- ------memory-usage----- ----swap--- ---load-avg---
    reads writs|util|usr sys idl wai hiq siq| used  buff  cach  free| used  free| 1m   5m  15m
       2     4 |2.26|  2   0  97   0   0   0|5692M  383M 1596M  303M| 632k   10G|0.25 0.26 0.20
       0     3 |0.84|  0   0  99   0   0   0|5691M  383M 1596M  304M| 632k   10G|0.21 0.25 0.20
       0     2 |1.16|  6   1  92   0   0   0|5695M  383M 1596M  301M| 632k   10G|0.18 0.24 0.20
       0     6 |0.44|  2   1  97   0   0   0|5693M  383M 1597M  301M| 632k   10G|0.31 0.27 0.21
       0     8 |0.56|  0   0  99   0   0   0|5693M  383M 1597M  301M| 632k   10G|0.26 0.26 0.20
       0     2 |2.84|  2   0  97   0   0   0|5694M  383M 1597M  301M| 632k   10G|0.22 0.25 0.20
       0     9 |10.4| 14   1  84   1   0   0|5750M  384M 1597M  244M| 632k   10G|0.27 0.26 0.20
       0    15 |15.6| 10   1  87   2   0   0|5722M  384M 1597M  271M| 632k   10G|0.76 0.36 0.24
       0     0 |0.32|  0   0 100   0   0   0|5722M  384M 1597M  272M| 632k   10G|0.64 0.35 0.24
       0     0 |0.72|  1   0  98   0   0   0|5722M  384M 1597M  271M| 632k   10G|0.62 0.36 0.24
       0     6 |2.48|  2   0  97   0   0   0|5721M  384M 1597M  273M| 632k   10G|0.61 0.36 0.24
       0    11 |8.52|  5   1  93   1   0   0|5717M  384M 1597M  276M| 632k   10G|0.51 0.35 0.24
       0     3 |1.80|  0   0  99   0   0   0|5718M  384M 1597M  275M| 632k   10G|0.58 0.37 0.25
       8     3 |1.84|  4   0  96   0   0   0|5722M  384M 1602M  266M| 632k   10G|0.65 0.39 0.26
       0     4 |0.72|  1   0  99   0   0   0|5722M  384M 1602M  266M| 632k   10G|0.55 0.38 0.25
       0     2 |2.92|  7   2  91   0   0   0|5737M  384M 1602M  251M| 632k   10G|0.54 0.38 0.26
       0     0 |0.44|  1   0  98   0   0   0|5734M  384M 1603M  253M| 632k   10G|0.53 0.38 0.26
       0     6 |0.28|  1   0  99   0   0   0|5735M  384M 1603M  252M| 632k   10G|0.53 0.39 0.26
    Last edited: Jan 20, 2019
  6. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Can you repost that junk within CODE tags so it can be read?
  7. minyor

    minyor New Member

  8. minyor

    minyor New Member

    Any other suggestions?
    I installed everything on default. Surely someone must have experienced this problem before me?
    I mean it should be some simple tweak in some config file right? ..
  9. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Why should it be?
    I compared to my web server, which also runs e-mail server and database. I use Apache though, and not NGinx. There are about 100 websites plus those databases and e-mails. Memory used is 4,4 GB and 3,9 is used for cache. So your server uses much more memory. And the dstat output looks to me like all memory on your host is used. My host has 3 GB memory free. Uptime is 24 days so it is running in steady state.
    Is your host running something else in addition to those 10 Wordpress sites? Are they somehow very large or with huge databases?

    Have you installed wordpress plugins that try to speed up the site by cacheing stuff to memory? In this case they may slow the server down my using too much memory.
    I looked at another setup, where e-mail server is separate from the web and database server. There memory used is 3,6 GB, and this host runs several very hevy Joomla sites. So again this leads me to think your server is using more memory than it should. If you get the memory usage down there is more memory left for use as cache which should speed up all websites.
    If this does not help, you have to analyze more thoroughly what is happening on your server. Have you booted it resently to maybe get rid of some memory consuming old processes?
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Have you scanned your server for Malware already? Might be that some of your sites are hacked and do other things at the moment like bitcoin mining or sending spam.
    Taleman likes this.
  11. minyor

    minyor New Member

    @till Thank for suggestion, I installed clamav daemon, it constantly checks traffic. Seem no bitcoin mining, otherwise i'd noticed high CPU levels.

    Yes, I forgot to mention that my server also hosts 5 java spring boot applications and GitLab, both of which use memory a lot.
    GitLab uses ~2GB alone.
    Also my government mode for PHP-FPM not 'ondemand' but dynamic so my 10 PHP sites eat about 3-4GB.
    WordPress site's database dump sizes vary within 20-60MB each, they are pretty heavy and not really optimized enough.
    I tried all modes: 'ondemand', 'dynamic', 'static' but caching behavior is the same.
    I don't know, really, what plugins in these wordpress sites installed or what do they look like, I do not even know PHP, I more of a Java guy and a sys-admin.
    I also tried to reboot my server yesterday but this behavior did not changed.
    The thing is, I'm not really complaining, everything is working great, I have 7 more PHP YI2 sites and 1 Joomla site and they load instantly.
    Even these 10 wordpress sites run acceptable. It's just that 2 first to refresh run twice as fast and I find it very odd :)
    I guess, sometime later, I'll try to install apache instead of nginx and see what it'll do.
    Meanwhile, I will try to free some more RAM.

Share This Page