I have deployed my PHP API on a Linux based server. It's users are 40000-50000. Server has Disk space 20GB and out of that, 15GB is used. I have used MySQL for Database. GZip is enabled and the response JSON on http://example.com/getData is nearly equal to 100KB. Initially, it used to take 2-3 seconds on each getData call (which includes querying from data table and processing on PHP), but now it is taking more than 15 seconds for a single request. I have checked the CPU usage by TOP command in linux. This is the CPU status:
top - 09:30:44 up 14:44, 3 users, load average: 1.16, 2.54, 2.28 Tasks: 222 total, 1 running, 221 sleeping, 0 stopped, 0 zombie Cpu(s): 6.2%us, 1.5%sy, 0.0%ni, 92.2%id, 0.0%wa, 0.0%hi, 0.0%si, 0.2%st Mem: 2051652k total, 1576444k used, 475208k free, 204408k buffers Swap: 0k total, 0k used, 0k free, 456548k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15942 www-data 20 0 320m 14m 6480 S 1 0.7 0:04.50 apache2
15356 mysql 20 0 1320m 52m 7448 S 1 2.6 1:00.19 mysqld
15973 www-data 20 0 321m 15m 6444 S 1 0.8 0:06.75 apache2
15811 www-data 20 0 318m 12m 5648 S 1 0.6 0:04.33 apache2
28989 root 20 0 96716 3928 2948 S 1 0.2 0:00.03 sshd
15806 www-data 20 0 323m 17m 6756 S 0 0.9 0:04.10 apache2
15807 www-data 20 0 321m 16m 6708 S 0 0.8 0:04.83 apache2
15817 www-data 20 0 322m 16m 6416 S 0 0.8 0:06.19 apache2
15832 www-data 20 0 320m 14m 6416 S 0 0.7 0:04.11 apache2
15838 www-data 20 0 320m 14m 6416 S 0 0.7 0:04.05 apache2
15849 www-data 20 0 321m 15m 6416 S 0 0.8 0:06.15 apache2
15851 www-data 20 0 321m 15m 6424 S 0 0.8 0:04.26 apache2
15853 www-data 20 0 320m 15m 6740 S 0 0.8 0:05.45 apache2
15856 www-data 20 0 323m 18m 6644 S 0 0.9 0:04.68 apache2
All the queries running time is less than 0.01 second and the microtime difference between end and start of the getData function is 0.51.
What may be the reasons of this slow response on browser?