Slow initial connection on cPanel server

celiac101

Well-Known Member
Dec 19, 2012
85
1
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
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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?
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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?
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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.
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,233
363
cPanel Access Level
DataCenter Provider
Twitter
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.
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.
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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.
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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.
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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
 

celiac101

Well-Known Member
Dec 19, 2012
85
1
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.