Linux
在頁面載入時提供隨機文件時伺服器掛起
我正在優化一個網站,我現在面臨的問題是伺服器相關的。在頁面載入期間,大約有 40-50 個請求發送到伺服器(取決於頁面),並且在每種情況下,伺服器在某個文件上掛起大約 5-6 秒(主要是圖像,導致 css 和 js 正在合併) ,或兩個或三個..看看螢火蟲螢幕截圖,以更好地了解我在說什麼
http://i.stack.imgur.com/aDhih.png
(這裡有 90 個請求,因為 js 和 css 沒有合併)。
網站是Bigelow Chemists。知道可能是什麼原因造成的。我可以更深入地了解一下,我只需要提示可能導致這種行為的原因。謝謝
您的 Web 伺服器似乎未配置為處理該數量的請求。
- 啟用保持活動狀態
# 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>