Recently one of my websites was suspended due to excessive CPU usage. Here is the e-mail from the hosting company:
Hello Sanil,
As you probably aware, here at Just Host we proactively monitor all
our servers to ensure that our clients websites are loading as fast as
possible at all times. During this routine monitoring we have found
that your account is utilizing an excessive amount of system
resources, and we have been forced to suspend your site as per our
terms and conditions '10% CPU/MEM/MySQL Policy'
For your reference, here is a copy of your usage report:
juks0n jukson.com Top Process %CPU 16.0 /usr/bin/php
/home/juks0n/public_html/min/index.php Top Process %CPU 12.0
/usr/bin/php /home/juks0n/public_html/min/index.php Top Process %CPU
11.7 /usr/bin/php /home/juks0n/public_html/min/index.php
%MEM 12.93
Does anyone have any idea why min is causing this problem or have any suggestions for resolving this issue?
Related
Health tab on ElasticBeanstalk environment shows 100 % of CPU is in use.
health monitor also shows these metrics
but when I visit the instance monitoring tab, it shows the CPU utilization as normal
running a top command shows this screen
What I can notice is the ST is high so what could be the reason that ElasticBens talk shows loaded CPU while EC2 Monitor shows normal?
I have found the root cause of this issue is that the instance type is t2.micro which are burst-able and this means there are CPU credit that is given to the instance when it process below baseline and there is also launch credit
at my case, it seemed that the instance consumed all the launch credit and also the accumulated CPU credit when it processed above the baseline (Brust)
when this case happens and the instance has no CPU credit, Amazon hypervisor throttled the CPU and increased the Stealing Time to 76%
How I solved this issue?
I added an extra instance to work alongside the throttled one which reduced the load on this instance, it then started accumulating credit and the stealing time went down
Out of the blue my Magento 2.3 installatie crashed, the CPU suddely raises and eventually Magento crashes. No updates or something like that, so that can't be te cause.
Main cause seems to be Redis, after stop-writes-on-bgsave-error no in Redis the system didn't crash anymore, but memory and CPU usage are stil high.
Found the cause, google was doing something like a DDOS attack. 150k requests per day...
Adjusted the robots.txt to do less indexing
In our Application there are more the 2000 pages which are deployed in prod server. Sometime when user browse some URL's the CPU spikes going more than 70%. I can not find when it's occurs and which URL create this. So can any one tell me best open source tool to Monitor and Create logs of W3WP.exe process CPU utilization and request URL's when CPU spikes more than 50%.
procdump + windbg
There is a sysinternals tool called procdump which can automatically create a memory dump of your process for analysis when cpu exceeds a threshold.
From the command line usage:
-c CPU threshold at which to create a dump of the process.
Once you have a process dump you will need to load it into windbg in order to analyze what's taking up all the cpu cycles. Covering off windbg is pretty big, but here's briefly what you need to do:
load the SOS dll (managed debug extension)
call the !runaway command to get list of long running threads
dive into a long running thread by selecting it and calling !clrstack command
There are many blogs on using windbg. Here is one example. A great resource on analyzing these types of issues is Tess Ferrandez's blog.
perfmon + procdump + windbg
Perfmon can help you see if the issue is related to high rates of memory allocation which is causing garbage collection. You can look at CPU for w3wp as well as allocation rates for the process and the number of Gen 2 collections occurring. Gen 2 collections mean Gen 1 and 0 are also collected, meaning it can be an expensive operation. Counters to look at:
# Gen 2 Collections
% Time in GC
Allocated Bytes/second
If you see some very high allocation rates, you will still need a memory dump (procdump) and windbg to analyse what the root cause is.
Again - Tess Ferrandez has a blog post on this flavor of high cpu. In this post the issue is allocating large objects onto the heap.
perfmon + appcmd
I haven't tried this myself but in theory it should work, and is simpler than other options - though will not produce same level of detail. You can configure perfmon alerts on cpu for w3wp.exe. The alerts can be configured to run a task. You can create a batch file which runs the appcmd IIS tool and tell it to dump all the running requests:
appcmd list requests > c:\temp\high-cpu-requests.txt
This way you will get a list of long running requests when the cpu is high, and hopefully be able to work out offending page from there.
IIS Advanced Logging may help you here.
Whilst it will not give you CPU Utilisation per request, it can log CPU utilisation in general. What you could do is try and match these spikes to the requests that come before it.
I am running a mobile website to get the live running status of any train in India. It is http://www.spoturtrain.com . The full code is written in PHP and Nginx is used as the webserver, php-fpm is used as the application server. All php requests are proxied to the app server. During peak traffic hours in the morning, the system load shoots up to 4 but the CPU% and the memory usage is low. Please take a look at the snapshot of the top command of the server.
Th %CPU displayed in the bottom section is per-thread, which means the percentage of one CPU core used by the indicated thread. The CPU(s) section indicates the total amount of available CPU that is being utilized, so it is possible to have one thread reporting that it is using 100% CPU, while only 25% (4 core) or 12.5% (8 core) of the overall CPU cycles are being consumed.
Analyzing thread CPU usage on Linux
You don't really ask a question, so it's hard to tell if you are wanting some advice or just asking to have the numbers explained. As #Charles states, a typical "acceptable" load is 1 per CPU core before noticeable performance degradation occurs, but in the case of PHP running on most web servers, you may (but probably won't in most cases) start noticing problems at anything above 1. Whether or not you do will largely depend on your disk and network I/O.
Whether or not the performance is acceptable for your application isn't something I can answer, but you can take a look at this thread for more places to jump into the options for getting your web server to thread requests.
What is thread safe or non thread safe in PHP
Whether or not you can do anything about it depends on your hosting situation.
We are using Magento Enterprise Edition on Nginx and FPC. Dedicated servers with ample ram and CPU. Everything runs fine with 60-70 visitors. However during high traffic like over 200 active visitors, we starts to have problem. During peak traffic our CPU is still under 10% and with 40% free memory. We have a dedicated App and DB server.
What could be wrong? Could this be a network issue? What are the chances that there is a problem with App server or the code base is not optimized given the fact that CPU is under 10% with ample ram.
Steve
Edit:
I am running a 32 core App server with 64GB of RAM. Have Nginx with PHP-FPM and FASTCGI. Upon checking the logs I found that that PHP-FPM has following errors during peak Hours:
[WARNING] [pool www] child 26196, script '/var/www/magento/index.php' execution timed out (600.011284 sec), terminating
I have 32 Workers process along with worker_connections 1024;
CDN is already setup and network is set to use 1G connection.