0

I'm using CentosOS VPS, Nginx & Varnish & Apache and I have problem with high load, only if many people visit website in same time. Website which cause a problem (user: livetvk+), have many php pages (90% are cached and on CloudFlare) and when people opening pages I see many /usr/local/apache/bin/httpd process with 3-4% CPU.

Here is my log in peak period:

USER      PID CMD                            TIME %CPU %MEM
nobody    9244 /usr/local/apache/bin/httpd 00:00:04  5.4  0.3
livetvk+ 12592 /usr/local/bin/php-cgi /hom 00:00:00  5.0  0.2
amavis  12089 /usr/bin/perl -T /usr/sbin/ 00:00:00  4.5  0.6
livetvk+ 12381 /usr/local/bin/php-cgi /hom 00:00:00  4.3  0.5
livetvk+ 12406 /usr/local/bin/php-cgi /hom 00:00:00  4.2  0.5
livetvk+ 12601 /usr/local/bin/php-cgi /hom 00:00:00  4.0  0.2
livetvk+ 12609 /usr/local/bin/php-cgi /hom 00:00:00  4.0  0.1
livetvk+ 12613 /usr/local/bin/php-cgi /hom 00:00:00  4.0  0.2
livetvk+ 12617 [php-cgi]                  00:00:00  4.0  0.0
mysql    12140 /usr/sbin/mysqld            00:00:00  3.9  1.5
root    12341 /usr/bin/spamd --pidfile /v 00:00:00  3.7  0.6
livetvk+ 12490 /usr/local/bin/php-cgi /hom 00:00:00  3.7  0.4
amavis  12143 /usr/sbin/clamd -c /etc/cla 00:00:00  3.2  0.6
root    12099 /usr/bin/spamd --pidfile /v 00:00:00  3.1  0.3
livetvk+ 12582 /usr/local/bin/php-cgi /hom 00:00:00  3.0  0.1
livetvk+ 12584 /usr/local/bin/php-cgi /hom 00:00:00  3.0  0.1
livetvk+ 12589 /usr/local/bin/php-cgi /hom 00:00:00  3.0  0.2
root    12602 /usr/local/bin/php /home/li 00:00:00  3.0  0.2
livetvk+ 12618 /usr/local/bin/php-cgi /hom 00:00:00  3.0  0.1

load average: 186.17, 72.93, 27.54

As you can see, load is pretty high and I got idea to limit this with: nice and cpulimit commands.

Because usr/local/bin/php make high load, my plan is to limit usr/local/bin/php to 2 or 3% CPU, and set lower priority with nice for same proces.

I don't know how is smart to limit php-cgi? I'm not sure is that a good idea, so I asking what do you guys think about it, and if anybody can offer better solution I will be appreciate.

I have:

  • CPU Model: Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz
  • CPU Details: 4 Core (2600 MHz)
  • Distro Name: CentOS Linux release 7.7.1908 (Core)
  • Kernel Version: 3.10.0
  • Platform: x86_64
  • RAM: 6GB
1
  • Why are you using non-CentOS packages for Apache httpd and PHP? Who is the liver livetvk+ user? Also, why are you using php-cgi instead of mod_php or php-fpm? There are a lot of weird things that you are doing that are really outside of the normal CentOS system. Commented Feb 25, 2021 at 0:39

1 Answer 1

1

/usr/local/bin/php-cgi is producing load, not something else, unlike you report, so please stick to facts unless you want to introduce confusion. Then, first of all, what's the problem with load? Load is what computers are supposed to do. Is it too high? Why? What do you expect or wish? What is not correct and why do you think so?

As for solutions -- that's what your application is. What is your aim in particular? Have you tried fixing your code? Any Apache tuning? Kernel tuning? Add some details. What you asked means very little.

4
  • I will try to answer to all your questions: The problem is high load. In peak load is 186.17, I want to 5-8 in peak. Load is high because many people opens php files in same time. In idle time load is 0.8-2.5. I tried to fix code and nothing hleps. I don't sure what do you mean to tune? I set Nginx & Varnish & Apache option as main webserver. Commented Feb 24, 2021 at 21:33
  • @Aleksandar Higher load is normal when performing. The right question is: how much resources do I need for so and so much load. How many CPUs do you have? Another one is, how can the load be reduced? You present no details whatsoever about this. There is even no related question from you. Do you think there's a problem with your code? Your server? What's your question? Commented Feb 24, 2021 at 21:38
  • I have: CPU Model: Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz CPU Details: 4 Core (2600 MHz) Distro Name: CentOS Linux release 7.7.1908 (Core) Kernel Version: 3.10.0 Platform: x86_64, RAM: 6GB I think my code is ok, server is ok. But I have problem with load. Question is how to reduce load? And don't know how much users this server can handle. If server can't handle, probably is server. And if can, maybe code making problem. I will answer if you have more questions. Commented Feb 24, 2021 at 22:31
  • @Aleksandar You need to do application profiling to find out what causes load. Is that CPU work or IO? From the listing in question it looks like heavy IO. Once you find out bottlenecks and other culprits, you will be able to think about optimisation. Commented Feb 25, 2021 at 8:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.