On my Ububtu server, I have a python script which runs 400+ threads processing some PHP files in every 30 seconds. Apache web server works fine. But when too many users hit the site, it becomes slow. So for better performance, I shifted to NGINX from apache. But now, I get poor results from those PHP files. What should I do?
Related
I run my wordpress PHP website on windows server IIS 7.5. I have noticed that even there are no visitors in my website, some php-cgi.exe still running for long time. each of them (15-20%), so together CPU get almost (100%) slowing down my websitee when a new visitoer comes in.
I turned off all plugins, I turned off rewrite rules but nothing helped.
What can be done in order to stop php-cgi.exe process from running after visitor letf my webiste? or any other idea?
Thanks
The question is specific to the PHP instead of IIS.
There are so many reasons that lead to high CPU usage when the PHP-cgi.exe process consumes 100% CPU in the Task Manager.
Such as the Malformed PHP scripts containing some infinite loop, these poorly coded scripts will call the PHP-cgi.exe PHP worker program on the server and will eat 100% of CPU.
A large number of PHP processes on the server take up a considerable amount of server resources. Every user instance creates a large amount of process on the server. As a result, the CPU usage shoots up.
Besides, if there is something wrong with fetching certain content with lacking user privileges, PHP can cause high CPU usage.
See this blog for more details.
https://bobcares.com/blog/php-cgi-exe-high-cpu/
i have a case that I'm having issues troubleshooting. I have a PHP script that executes many queries (postgres) for data analysis so they get cached and can be loaded up quickly for the user. This php script loops through certain input parameters, data and generates about 50-60 sql queries, executes them, and stores them in a db cache. Some queries take 2-3 seconds, others few minutes.
After its execution everything works perfectly, but when they are running, Apache does not seem to respond to any access to the site (the browser just hangs on 'waiting for server'). PHP-FPM status only shows 3 active processes (the limit is 50). The server has 160GB ram and mulitple multi-core cpu and only running this application. If I restart php-fpm, the site responds again and works normally. The server load during execution is very low (~1.5 in top, it has 64 cores to use).
I cannot seem to find why Apache/php-fpm seems to not respond to any other user until the process is fully complete even though I'm the only user and there's few processes running. Everything else on the server runs super fast (phpmyadmin, pgadmin, terminal, etc.) .
At first, thought it was php-fpm reaching its limit, but did not seem to be the case after adjusting parameters,
Would appreciate any pointers on how/where to look.
thanks
I have a apache 2.4, php, mysql based web application. The application works like charm most of the time with 40ms response times. Already performance tuned with apache cache, php's opcache and apache mod_deflate.
However rarely once every 2 hours or so...when I invoke the application on a browser...it hangs saying waiting ..... for few seconds say 40 seconds or so...and then picks up back to super speed.
what do you think could be possible reasons?
Just for information. it's all localhost. and there is no network.
ISSUE: My website is extremely slow processing pages, and often times just hangs.
OLD environment: I used to run Apache 2.2 (from Apachelounge), PHP 5.3, and MySQL 5.5 on a Windows 2008 Web Server phyical box, hosted by Peer1 (ServerBeach). Website ran fast and reliable. At the time, I was using "mysql_" commands versus "mysqli_".
NEW environment: I now have a google compute engine VM running Windows Server 2012 R2. I installed Apache 2.4 from apachehaus.com (httpd-2.4.12-x64-vc11-r2.zip), PHP 5.6.9 (VC11 x64 Thread Safe), and MySQL 5.6.25 (64 bit). With some tweaking to the new httpd.conf and vhosts.conf files, I got my website back up and running. I also converted all the mysql_* references successfully to mysqli_*. Here's what I'm noticing: If I pull up the task manager on the apache server and watch the httpd process, every time I navigate to a website page, the CPU process climbs drastically and slowly gets back down to 0%. Often times, it'll even hit between 95-100% CPU utilization and stay there for a good 5 seconds, before slowly getting back down to 0%. Also, the apache memory utilization keeps getting larger with every page request, and never goes down. The website and mysql calls work and pages display fine, it just takes a long time to process.
I believe this to be a PHP issue, but I could be wrong. Recommendations are welcome.
I've written some JS scripts on my school's VLE.
It uses the UWA Widget Format and to communicate with a locally-hosted PHP script, it uses a proxy and AJAX requests.
Recently we've moved the aforementioned locally-hosted server from a horrible XP-based WAMP server to a virtual Server 2008 distribution running IIS and FastCGI PHP.
Since then - or maybe it was before and I just didn't notice - my AJAX calls are starting to take in excess of 1 second to run.
I've run the associated PHP script's queries on PHPMyAdmin and, for example, the associated getCategories SQL takes 0.00023s to run so I don't think the problem lies there.
I've pinged the server and it consistently returns <1ms as it should for a local network server on a relatively small scale network. The VLE is on this same network.
My question is this: what steps can I take to determine where the "bottleneck" might be?
First of all, test how long your script is actually running:
Simplest way to profile a PHP script
Secondly, you should check the disk activity on the server. If it is running too many FastCGI processes for the amount of available RAM, it will swap and it will be very slow. If the disk activity is very high, then you know you've found your culprit. Solve it by reducing the maximum number of fastcgi processes or by increasing the amount of server RAM.