HTTP响应性能在负载下降
I use following PHP code to measure execution time of PHP / MySQL scripts.
$start = microtime(true);
/* any PHP with HTML output */
echo (microtime(true) - $start);
This measurement always prints similar result regardless of server load. The execution time is most commonly 0.1 second across various pages completely unaffected by server load.
But when the server is under some load (100 concurrent users), each page takes several seconds to physically appear in the browser. From this observation I assume the HTTP server is suffering performance drops right?
Where should I begin to fix this issue?
我使用以下PHP代码来测量PHP / MySQL脚本的执行时间。 p>
无论服务器负载如何,此测量始终会打印出类似的结果。 在不受服务器负载影响的各个页面上,执行时间通常为0.1秒。 p>
但是当服务器处于某种负载(100个并发用户)时,每个页面需要几秒钟才能实际显示 在浏览器中。 根据这一观察,我假设HTTP服务器正在遭受性能下降吗? p>
我应该从哪里开始解决这个问题? p>
div> $ start = microtime(true);
/ *任何带HTML输出的PHP * /
echo(microtime(true) - $ start);
code> pre>
Put measures at the very start and finish of script to measure all php time.
Enable in your webserver (Apache or Nignx) time logging. For ex: https://lincolnloop.com/blog/tracking-application-response-time-nginx/
How many php processes are there? Check may be your requests are in queue waiting for free php worker? Try to tweak settings of you webserver of php-fpm (if you use it).