Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Slow initial connection on cPanel server

Discussion in 'Workarounds and Optimization' started by celiac101, May 24, 2018.

Tags:
  1. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    I've been tweaking my server to make it faster, and have been very successful so far. It is a very busy server with ~1.2M unique monthly visitors.

    One problem I am having that I cannot figure out, is that there is a slow initial connection to the server, but after that all pages load fast, ~3 seconds, and given the age of the hardware and size of the databases this seems pretty decent. The initial connection can take as long as 7-8 seconds, however, and I can't pin down why.

    Any ideas would be appreciated. Below is my setup.

    ~130 gigs of memory
    PHP Version 7.0.30
    MySQL Version 5.5.5-10.1.33-MariaDB
    default-storage-engine=MyISAM
    Memcached
    Apache handler: PHP-FPM
    Server version: Apache/2.4.33 (cPanel)
    Apache MPM Event
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,400
    Likes Received:
    1,952
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    celiac101 likes this.
  3. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    Excellent, I did learn a lot from those threads, and litespeed seems to be a consistent recommendation to solve this issue. Does anyone know if it would conflict with memcache or mod security? I have no idea how litespeed works, or what it could conflict with.

    Another common recommendation is Nginx. I have the same questions about it, would it conflict with anything like memcache or mod security?

    Can you run both Nginx and litespeed? Is one better than the other?
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,400
    Likes Received:
    1,952
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    I'm having trouble locating the LiteSpeed plugin in my cPanel. I don't see it in in Softacalus. Where is it located?
     
  6. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,565
    Likes Received:
    438
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    You'll need root access to the server to install Litespeed. It's not installed to a single cPanel account via Softaculous.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    So two posts ago one of your other staff members said:

    "I recommend using LiteSpeed over Nginx, as LiteSpeed offers an official plugin for use with cPanel."

    So I guess I'm wondering what you guys mean by "plugin"? If I have to install it via command line, which I can do because I'm the server admin, then I certainly would not call it "an official plugin for use with cPanel."

    In any case, I guess I'm asking how to install it.
     
  8. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,400
    Likes Received:
    1,952
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @celiac101,

    To clarify, I was referring to the cPanel & WHM server environment. It's still a third-party application that requires root access to the server to install. Litespeed provides installation instructions at:

    cPanel WHM Plugin for Managing LiteSpeed Web Server - LiteSpeed Technologies

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    I'm still trying to improve performance, and am having difficulty with changing my swap memory. Since I have 130 gigs of memory it seems like I should be able to set my swappiness from the default of 60 to 10, or even 1, and it should increase my server's performance. However, when I run this command:
    sysctl -w vm.swappiness=10

    and then verify it:
    cat /proc/sys/vm/swappiness
    10

    I then run various site speed tests and my performance is slower. One thing that occurred to me is that perhaps the memory that is allocated to swap, which when I run Top shows:
    Swap: 8388604k total
    is not being used, and is still reserved for swap?

    Any ideas would be helpful, but for some reason lowering my swap value to anything below the default 60 seems to decrease my server's performance as measured by various site speed sites like pingdom.com.
     
  10. rarod

    rarod Active Member

    Joined:
    Apr 20, 2017
    Messages:
    33
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Check with "free -h" if you are using swap. Ideally you should have near 0 used swap.

    To flush swap: swapoff -a && swapon -a
     
  11. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    It does appear I am using it, see below, and again, when I've tried to use less swap it seems to slow things.

    Code:
                 total       used       free     shared    buffers     cached
    Mem:          126G       119G       6.7G       242M       1.4G        94G
    -/+ buffers/cache:        23G       102G
    Swap:         8.0G       324M       7.7G
    
     
  12. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    The flush swap command was very helpful, I ran that first, then set it to 10, and now I see my swap at 0. So how can I re-allocate my memory to use less of it for swap? Currently I see 8 Gigs dedicated to swap. I would like to change that to 1 gig.
     
  13. rarod

    rarod Active Member

    Joined:
    Apr 20, 2017
    Messages:
    33
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Swap uses hard disk, not memory. This is why is slower when the system uses swap.

    If you set swappiness to 10 the system should use less swap.
     
  14. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    Thank you for this info. One issue I had after setting the system swapiness to 10 was that after rebooting my server it changed back. Is there a way to make sure it stays at 10? I've been using the commands below to work on this:

    Flush Swap:
    swapoff -a && swapon -a

    Set swapiness to 10:
    sysctl -w vm.swappiness=10

    and then verify it:
    cat /proc/sys/vm/swappiness
    10

    To Check Usage:
    free -h
     
  15. rarod

    rarod Active Member

    Joined:
    Apr 20, 2017
    Messages:
    33
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    In /etc/sysctl.conf file add the next line:

    vm.swappiness=10
     
  16. celiac101

    celiac101 Well-Known Member

    Joined:
    Dec 19, 2012
    Messages:
    77
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    I've been running Litespeed for about 2 weeks now, and am seeing speed improvements from it, however, in google pagespeed I am getting slow mobile DOM Content: "DOM Content Loaded (DCL) measures when HTML document has been loaded and parsed."

    I was wondering if anyone has opinions about whether the following 2 changes might improve this:

    1) Upgrading PHP from 7.0.x to 7.1.x.

    2) Upgrading to InnoDB from MyISAM: I am getting mixed messages about InnoDB vs. MyISAM (what I'm using now), as far as which is faster. I am reading that InnoDB may be slightly faster, but probably not much, and some people even say that I might not notice any difference at all.

    Before making such a big change, I would love to hear from anyone who has experience with making this change in IPB, and whether their site speed improved enough to make it worth it.

    My main site is a PHP forum that has nearly 1 million posts, and over 100K topics, and is about 2 gigs in size.
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice