在页面加载时提供随机文件时服务器挂起

在页面加载时提供随机文件时服务器挂起

我正在优化一个网站,现在面临的问题与服务器有关。在页面加载期间,大约有 40-50 个请求发送到服务器(取决于页面),并且在每种情况下,服务器在某个文件上挂起大约 5-6 秒(主要是图像,因为 css 和 js 正在合并),或者两三秒。。看看 firebug 屏幕截图,以更好地了解我在说什么

https://i.stack.imgur.com/aDhih.png

(这里有 90 个请求,因为 js 和 css 尚未合并)。
网站是比奇洛化学家。知道是什么原因造成的吗?我可以更深入地研究一下,我只是需要一些提示来了解这种行为可能的原因。谢谢

答案1

看来您的网络服务器没有配置为处理那么多的请求。

  • 使能够活着

    # 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>
    

相关内容