High CPU usage for my Linode 8192
Today it was sluggish at the peak time:
Should I upgrade to Linode 12GB ?
16 Replies
At a glance It looks like that may have been a brief traffic spike moving outbound from your Linode. Is your traffic still high? How often are you seeing this issue and how long does it last?
Since this looks like outbound traffic only this is most likely tied into some internal processes on your Linode that you can mitigate, however without direct access to the internals of your instance I wouldn't be able to say what process or processes might be responsible.
If you'd like you can always open up a support ticket with us and we'd be happy to take a closer look at your account to see if we can determine anything else. That being said, if you feel ready to resize now instead, I'm including some documentation below that should help to walk you through the process:
Hope that helps!
As long as you have an active account with us you're more than welcome to open up a support ticket with us at any time, and this wouldn't require any sort of paid subscription, it's just a part of the package! That being said, we're an unmanaged infrastructure provider, so we wouldn't be able to access the direct internals of your Linode to investigate and sometimes we're limited in the ways that we can help when we can. At a glance though, I think we should be able to help point you in the right direction.
For more information on reaching out to our support team, I'm including a little more documentation below which should serve as a step by step guide:
Couple of Drupal sites are hosted on this Linode.
One getting most visitors is the Drupal 6 site.
Do you have any suggestions? How to go about optimizing it?
There are no applications I've installed on it. May be I can try optimizing Mysql. But sometimes I find Apache hogging 100% of CPU. Is there any way to make it fast?
1) Switch to PHP-FPM
2) Switch to Event MPM, and configure it according to your load
3) Ensure Apache to FPM and PHP to MySQL communications are over UDS and not TCP
4) Install a local DNS cache
5) Ensure PHP opcache is enabled, if your PHP is too old, use APC or some other opcode caching mechanism
6) MySQL can be tweaked, in particular you can enable query cache, audit for missing indices and slow queries and so on
7) Set PHP production settings (i.e. warnings and logging off); disable Apache access log and MySQL general log
As a point of reference, one of the web servers I have in this configuration is a Linode 8192, it has served about 3 million connections (probably something like 10 million requests) over the last ten days without breaking past 0.5 load.
Side note: before doing any changes, take a performance snapshot with a tool like ab (for example, ab -n 300 -c 20) and increase concurrency until the server chokes. Make record of every test you perform and redo it after every change. At the end of the process you will have a very clear picture of how your webserver performs and how it improved.
I've Ubuntu 12 version. Yes it is all old.
Opcode cache alone will not save you. You want Apache 2.4 with FPM and a recent (7.x) PHP. This isn't available to you on Ubuntu 12. The performance will be crap.
Is there anywhere any service who will do these? Otherwise Linode's $100/pm charges will be way too much for me.
Or may be I'd need to move to any other CPanel providers who provide free administration. But CPanel makes the VPS even slower.
I've a dozen websites hosted. Moving to PHP 7 will break all of them.
About the DNS I'm using that of Linode's.
For my Drupal 6 site with some 40000 visitors I've enabled PHP opcode cache + enabled Varnish for Drupal. I want to defer porting to Drupal 8 as it is not fully ready nor as fast as Drupal 6
I'm not sure if FPM is running but this command output I see:
ps aux | grep php-fpm
root 12545 0.0 0.5 338428 21512 ? Ss Mar03 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
www-data 12548 0.0 0.1 338428 6732 ? S Mar03 0:00 php-fpm: pool www
www-data 12549 0.0 0.1 338428 6732 ? S Mar03 0:00 php-fpm: pool www
root 14275 0.0 0.0 11752 2096 pts/1 S+ 01:38 0:00 grep php-fpm
The Drupal 6 seems to be running fine. At least I can heave a sigh if that works out. Please suggest.
I've not installed Event MPM as you've suggested.
Secondly how to know answer to your question: > PHP requests or is it still mod_apache?
I can see this in the Apache log:
[Tue Mar 06 12:46:17.581307 2018] [mpm_prefork:notice] [pid 7914] AH00171: Graceful restart requested, doing restart
[Tue Mar 06 12:46:20.713408 2018] [:notice] [pid 28023] FastCGI: process manager initialized (pid 28023)
[Tue Mar 06 12:46:20.765533 2018] [ssl:warn] [pid 7914] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Mar 06 12:46:20.765765 2018] [mpm_prefork:notice] [pid 7914] AH00163: Apache/2.4.7 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 PHP/5.5.9-1ubuntu4.23 OpenSSL/1.0.1f configured -- resuming normal operations
[Tue Mar 06 12:46:20.765785 2018] [core:notice] [pid 7914] AH00094: Command line: '/usr/sbin/apache2'
[Tue Mar 06 12:47:06.348682 2018] [mpm_prefork:notice] [pid 7914] AH00171: Graceful restart requested, doing restart
[Tue Mar 06 12:47:09.747345 2018] [:notice] [pid 28320] FastCGI: process manager initialized (pid 28320)
My
/etc/apache2/mods-enabled/mpm_prefork.conf
file looks like(on my 8GB RAM Linode)
<ifmodule mpm_prefork_module="">StartServers 50
MinSpareServers 10
MaxSpareServers 20
MaxRequestWorkers 600
ServerLimit 600
MaxConnectionsPerChild 0</ifmodule>
free -m
total used free shared buffers cached
Mem: 7970 7239 731 73 53 5081
-/+ buffers/cache: 2104 5866
Swap: 255 0 255
Here is the photo:
Thirdly how can I install Event-MPM?
Alternatively you could a2dismod php and see what happens after you restart the server.
On ubuntu the package would be libapache2-mpm-event, which you then would enable with a2enmod. You then would do some calculations based on your load, and configure the Apache MPM and the FPM worker pool to max out the performance. Tools like ab (apache benchmark) can measure how well the server is responding under load and what is the dropoff point.
I would also verify that both Apache to FPM communication and PHP to MySQL communication is over UNIX domain sockets, as opposed to TCP. The next step then would be verifying that the websites emit correct caching headers for static and dynamic content, so that browsers do not reload static content they already have cached.
Still, I highly recommend to upgrade to latest LTS version of Ubuntu.
the person says there is no advantage of using MPM event on SSL sites. Is it true?