High CPU usage for my Linode 8192

Can anyone give me suggestion what to do with this linode where daily traffic of 40000 may be coming.

Today it was sluggish at the peak time:

https://ibb.co/ciwZ8G

Should I upgrade to Linode 12GB ?

16 Replies

Hey there,

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:

https://www.linode.com/docs/platform/di … g-a-linode">https://www.linode.com/docs/platform/disk-images/resizing-a-linode

Hope that helps!

Can I issue a support ticket? I have not subscribed to any paid support plans though?

Hey again,

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:

https://www.linode.com/docs/platform/support

40k/day is nothing. Your server is misconfigured.

emestee sorry for late reply.

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?

emestee you're genius. Yes php opcode cache is missing. Let me enable, then I think it'd work fast.

I've Ubuntu 12 version. Yes it is all old.

Then do yourself a huge favour, clone this Linode into a new one, perform and test upgrades on the new one, then re-replicate the databases (if needed), switch the DNS to the new one and kill the old one.

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.

I'm a web developer doing all these will take me a year for sure.

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.

Since you run this in production, you are the system administrator. You should either find yourself a partner or learn to do this on your own. That this is still on Ubuntu 12 is a huge mistake and it will only cost you more as time passes. In actual reality these things are trivial and can be done rather quickly once you have the necessary experience. If you can spare the additional $40 or however much another 8k Linode costs, you can move the projects one by one with careful testing and virtually no downtime. Unless you can switch to PHP-FPM you would only be able to do so much with mod_php…

Tell us about the configuration. What MPM model is used by Apache? Is PHP an Apache module or fastcgi? Here's a brief checklist:

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

8) Wrap it in cloudflare

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.

FPM is running, but is it actually processing PHP requests or is it still mod_apache?

Probably the easiest way to verify that it is FPM and not mod_php that's processing PHP requests would be to look at FPM access log (which has to be enabled).

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.

Using this article I've installed FPM on Ubuntu 14.

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.

How about using PHP 5.5.9 on Ubuntu 14? I want to try running my Drupal 6 on this which at the moment running on Ubuntu 12 using mod_php.

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

emestee many thanks for your valuable suggestion. Now with FPM on Ubuntu 12, with APC and memcache the performance is excellent.

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

Today's Performance

Here is the photo: https://imgur.com/1SQ61TF

Thirdly how can I install Event-MPM?

emestee as in https://scottlinux.com/2014/06/18/switc … nnections/">https://scottlinux.com/2014/06/18/switch-to-or-enable-apache-event-mpm-in-ubuntu-14-04-for-http-connections/

the person says there is no advantage of using MPM event on SSL sites. Is it true?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct