我正在优化一个网站,我现在面临的问题是服务器相关的。 在页面加载期间,有大约40-50个请求发送到服务器(取决于页面),并且在任何情况下,服务器在某个文件上挂起大约5-6秒(主要是图像,导致css和js被合并) ,或两三个。看看萤火虫截图,以得到一个更好的主意,我在说什么
http://i.stack.imgur.com/aDhih.png
(这里有90个请求,因为js和css不合并)。
网站是Bigelow化学家 。 任何想法可能导致这一点。 我可以深入了解一下,我只需要提示可能是这种行为的原因。 谢谢
看来你的web服务器没有configuration为处理这个请求数量。
启用Keep Alive
# KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to "Off" to deactivate. # KeepAlive On # # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # We recommend you leave this number high, for maximum performance. # MaxKeepAliveRequests 200
调整您的服务器参数以拥有足够数量的进程来处理并发请求
# prefork MPM # StartServers: number of server processes to start # MinSpareServers: minimum number of server processes which are kept spare # MaxSpareServers: maximum number of server processes which are kept spare # MaxClients: maximum number of server processes allowed to start # MaxRequestsPerChild: maximum number of requests a server process serves <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 50 MaxClients 150 MaxRequestsPerChild 0 </IfModule> # worker MPM # StartServers: initial number of server processes to start # MaxClients: maximum number of simultaneous client connections # MinSpareThreads: minimum number of worker threads which are kept spare # MaxSpareThreads: maximum number of worker threads which are kept spare # ThreadsPerChild: constant number of worker threads in each server process # MaxRequestsPerChild: maximum number of requests a server process serves <IfModule mpm_worker_module> StartServers 5 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0 </IfModule>