1

I am having a webservice API in a php file (api.php). Android / iOS app will get the data from this Web service. There are 1000 - 3000 users as of now. App will get the data for every 5 seconds (Real time data) from the server. I am experiencing the high CPU usage at peek time. Each www-data consumes 2% of CPU. I am having the 8 cores processor. It reaches the maximum CPU at the peek time. Any suggestions on this ?

Apache Configuration.

<IfModule mpm_prefork_module>
    StartServers 4
    MinSpareServers 20
    MaxSpareServers 40
    MaxClients 200
    MaxRequestsPerChild 4500 
</IfModule>

Virtual host details:

<VirtualHost *:80>
  ServerName  track.domain.com
  Redirect permanent / https://track.domain.com/
</VirtualHost>

<VirtualHost *:443>
   SSLEngine On
   SSLCertificateFile /var/certificate/track.domain.com/track_domain_com.crt
   SSLCertificateKeyFile /var/certificate/track.domain.com/track.domain.com.key
   SSLCACertificateFile /var/certificate/track.domain.com/track_domain_com.ca-bundle
   #SSLCertificateChainFile /var/certificate/track.domain.com/track_domain_com.ca-bundle

  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin webmaster@track.domain.com
  ServerName  track.domain.com
  ServerAlias www.track.domain.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/track.domain.com/public_html
  #DocumentRoot /var/www/html/track.domain.in/public_html
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/html/track.domain.com/log/error.log
  CustomLog /var/www/html/track.domain.com/log/access.log combined

<IfModule mod_security2.c>
        SecRuleEngine Off
    SecAuditEngine Off
        SecAuditLog     ${APACHE_LOG_DIR}/modsec_audit.log
        SecDebugLog ${APACHE_LOG_DIR}/modsec_debug.log
</IfModule>

</VirtualHost>

CPU usage: enter image description here Apache usage: enter image description here Top usage: enter image description here

Muthu
  • 1,550
  • 10
  • 36
  • 62
  • 1
    I think we need to see your PHP code in order to find potentially hidden inefficiencies in your code. Serving 1000+ users should in itself not be such a big problem for Apache – Marged Jul 31 '17 at 06:13
  • 1
    From the `top` output, seems like mysql is the bottleneck, perhaps you can look into optimizing the queries if possible, or move the db to different server – Dusan Bajic Jul 31 '17 at 07:00

0 Answers0