2014-03-28 95 views
1

我有一個網站,在過去的幾個月裏像往常一樣獲得更多的流量。 我希望這個網站能夠在相同的時間內爲更多的用戶服務,而無需更改硬件。 在當下,我使用Apache2與Wordpress和Memcached。 我想知道我是否可以使用Nginx在本網站上獲得更多性能。 當我有Nginx運行在Web服務器與Wordpress和我運行一個60秒的時間10000用戶的測試,我只得到600成功的答案其他9400連接得到錯誤。 (大多是超時)。 IMG
當我使用Memcached除了以前的配置我得到9969成功答案,但最大用戶每秒不超過451 IMG
但在我的網站我有時超過1000用戶每秒。 所以有人可以告訴我什麼我做錯了嗎?Nginx的php-fpm和Memcached的問題

系統:
AWS EC2雲服務器的2GHz,650MB RAM
的Ubuntu 13.10
Nginx的1.4.7
Memcached的1.4.14
PHP-FPM爲PHP 5.5.3

+0

由於#1可愛的功能,我不能發佈兩個以上的鏈路,這裏是配置文件: Nginx的:http://pastebin.com/H3YyKYdj Memcached的:http://pastebin.com/Jz4ZmqsP PHP-fpm:http://pastebin.com/BmxrQGVz – Rustypredator

回答

0

我們有問題是不是一個真正的問題。 我們只解釋了測試結果錯誤。

400用戶限制不是實際限制,服務器能夠將用戶保持在一個恆定的級別,因爲它足夠快以便立即回答所有請求。

測試結果與我的網站沒有可比性,即獲得1k用戶,因爲它具有比AWS免費實例更好的硬件。 但我認爲每秒400個用戶是這樣的「弱」服務器一個非常好的結果..所以

問題解決了,我認爲,因爲我自己的閱讀測試結果stupidness的...

感謝無論如何,你的幫助bodi0。

0

你應該在數考慮是Avg error rate,你的WP + Nginx + Memcached配置看起來不算太差,所以我認爲這是不錯的選擇。 也許你可以增加memcached中的-m參數來匹配你的一半RAM。

但是: memcached不能保證數據在內存中可用,並且您必須爲高速緩存未命中風暴做好準備。避免錯失風暴的一個有趣的方法是設置到期時間與一些隨機偏移量,例如10 + [0..10]分鐘,這意味着一些項目將被存儲10和其他20分鐘(目標是並非所有項目都同時過期)。

此外,無論你分配多少內存給memcached,它只會使用它需要的數量,例如,它只分配實際使用的內存。 使用-k選項,但是(在您的配置中被禁用),當啓動memcached時,整個內存將被保留,因此無論它是否需要,它都會分配全部內存量。

這個451連接數實際上可能會有所不同,這取決於。在執行基準測試時查看平均值總是一個好主意,也就是說,最好爲服務客戶端提供0%Avg error rate451,而不是提供65%Avg error rate和8200 +服務的客戶端。

但是,爲了卸載一些更多的資源,您可以使用額外的Wordpress緩存,有很多插件,我個人爲此寫了一個。

關於nginx配置,你可以調整一些參數也存在:

worker_rlimit_nofile 100000; 

worker_connections 4000; 

# optmized to serve many clients with each thread, essential for linux use epoll; 
# accept as many connections as possible,may flood worker connections if set too low 
multi_accept on; 

# cache informations about FDs, frequently accessed files 
# can boost performance, but you need to test those values 
open_file_cache max=200000 inactive=20s; 
open_file_cache_valid 30s; 
open_file_cache_min_uses 2; 
open_file_cache_errors on; 

# to boost IO on HDD we can disable access logs 
access_log off; 

# copies data between one FD and other from within the kernel 
# faster then read() + write() 
sendfile on; 

# send headers in one peace, its better then sending them one by one 
tcp_nopush on; 

# don't buffer data sent, good for small data bursts in real time 
tcp_nodelay on; 
# number of requests client can make over keep-alive -- for testing 
keepalive_requests 100000; 

# allow the server to close connection on non responding client, this will free up memory 
reset_timedout_connection on; 

# request timed out -- default 60 
client_body_timeout 10; 

# if client stop responding, free up memory -- default 60 
send_timeout 2; 

# reduce the data that needs to be sent over network 
gzip on; 
gzip_min_length 10240; 
gzip_proxied expired no-cache no-store private auth; 
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml; 
gzip_disable "MSIE [1-6]\."; 
+0

感謝您的快速回復,我會測試這個,並提供反饋,如果它的工作。 但我需要更像這樣的結果:http://rusty.info/images/ap-ng/Apache+WP+Memcached.png 所以..更多的併發用戶和連接的那些不會被丟棄或類似的東西他們似乎與配置我有atm。 – Rustypredator