Apache using 100% CPU for only 220 concurrent users

Please I am a young programmer i need some help, I developed an Examination system with

cakephp and I want the students to write the exam offline using this application, I am using wampserver on

windows server 2012 r2, Hp laptop Core i7 with 1TB HDD Hard disk, 16GB RAM, 2.7Ghz cpu, my problem is when 200 and above candidates login and start exam Apache will use up my CPU and start kicking students away saying this site can’t be reach.

Please how can I solve this problem?

Hope to hear from you guys soon

Thank you.

Ok, your problems are:

  1. wamp
  2. windows
  3. hp laptop

OMG! Are u serious those are your server specs? ok ok … anyway, probably is normal… (performance issues)… but please provide more informations about your app:

  • Cakephp and PHP versions
  • Database setup
  • Any cache configuration?

…What else more do we need to know?

PS: i don’t understood about the “offline” application… can you explain how it works?

Thank you for your response I have below

  • Cakephp version: 2.*
  • PHP 5.6 versions
  • Database MySQL 5.*
  • Any cache configuration? Yes there is cache
    And also error log
    MySQL only uses 5% of my CPU
    Offline I mean the application work on local network LAN

Presently I am thinking of buying gaming laptop HP omen, also I need if there is a way to increase this numbers or reduce Apache CPU usage, memory has no issue as it only use less than 30% of memory but 100% of CPU with 220 concurrent request, same I have also deployed it using core server still have the same problem of running out of CPU

You’d be better of putting in on a dedicated host with some load balancing.

The application is supposed to run and access locally without internet connection

Upgrade to PHP 7.2 at least. PHP 7.x is around twice as fast as PHP 5.6.

Also investigate implementing heavier caching.

Also, you definately need a dedicated host, preferably running Linux with Nginx and PHP-FPM. No reason the dedicated host can’t be a laptop though.

1 Like

Enabling stuff like OPCache will also help big-time as PHP doesn’t have to compile everything all the time.
In bigger apps, I have seen huge increases in performance and decreases in resource usage.

Another thing I would recommend is using an SSD.
Laptop HDDs are notoriously slow, which can make it that your CPU (or Apache process) is waiting for your HDD to feed it the data it needs.

My suggestions (in order of “importance”):

  1. update to PHP 7.x
  2. use OPCache
  3. use an SSD
  4. use MariaDB instead of MySQL (it’s a drop-in so don’t worry about incompatibility)
  5. don’t use wamp (it’s not made for production), but use nginx with php-fpm (Docker can help you with this, though on Windows, Hyper-V is needed for Docker)

@FinlayDaG33k thanks alot I have set it up using nginx and mariaDB, I connected one computer to it and it work fine but cgi/fastCGI is now using lot of CPU with one computer connected to it 3% CPU usage, although I want to buy gaming laptop tomorrow with 500gb ssd, 1TB HDD and 3.0ghz and 32gb ram and 4gb cache so that I can do real test as I am expecting the application to handle 350 to 500 concurrent request on LAN

I’d recommend not buying a gaming laptop for this purpose (but if you want to game, then go ahead).
If you don’t game on it as well, I’d recomment looking into something like a Dell XPS-series laptop.
But if all you are doing on it is run this application, you might be off better using something like an Intel NUC or Gigabyte Brix.
saves you some money for the same purpose.

As for the load testing, you could give Siege a try, it’ll basically hit your app with loads of concurrent requests.

The dedicated host would deal with load balancing and a different computer combined with it will be the most suitable and effective way of dealing with this issue since the issue is arising because of a blend of both.

Do note that a dedicated host is often off-site, which might not always be appreciated.
For a publicly available app, a dedicated webhost (or even VPS if you know what you’re doing) is desirable, but for something that only has to be available for the LAN (eg. an intranet portal) this is not always desired.

Thanks guys, I bought HP omen and everything is all fine handling large numbers of concurrent request with Apache