我有一個簡單的扭曲應用程序,它服務於「Hello World!」通過HTTP協議。我試圖運行多個實例來使用所有處理器。haproxy後面的扭曲應用程序
但我提到,單個扭曲的應用程序處理haproxy後面的相同應用程序的甚至1個,2個或5個實例的請求要多得多。我無法弄清楚爲什麼會發生這種情況。
我運行5000個線程通過JMeter獲得/
。當我在127.0.0.1:9001上運行它時,它在500ms時間內成功處理每個請求。當我在127.0.0.1:8080上運行它時,有些響應是503 Service Unavailable
,有些響應超過500ms。
這裏是我的配置文件:
global
maxconn 500000
user german
defaults
mode http
retries 0
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
balance roundrobin
# if something goes wrong with server, redistribute client to a working server
option redispatch
listen http 127.0.0.1:8080
mode http
option httpchk GET/HTTP/1.1
server prototype-local 127.0.0.1:9001 maxconn 0 weight 1 maxqueue 0 cookie server01 check inter 5000 rise 1 fall 3
balance roundrobin
# to see ip's of clients
option forwardfor
option http-server-close
# disable or enable immediate session resource cleaning(useful for chat)
# option nolinger
# inserts cookie to each client requet to identify a process
cookie SWCOMMET insert indirect nocache
# will be enalbed as soon as main server with process crashed :nice fail resistance
option allbackups
我的意思是響應時間永遠不會高於500毫秒。當有太多的併發請求時,響應時間會增加。 –
關於專用內核的不錯建議。我想這個問題是在連接超時選項。一旦連接在5秒內沒有建立,503由haproxy返回。我將這個值增加到了50s,並且我得到了與應用程序本身相同的行爲。 –
好,所以這顯然是一個應用程序的問題,反應太慢。您正在飽和所有線程,並且新連接必須等待較舊的連接被釋放。你確定你不會在應用程序的任何地方浪費時間嗎?真的,500毫秒對此非常重要。 5-50微秒對此更合理。 –