新聞中心
global常用的優(yōu)化配置:
為雙臺(tái)子等地區(qū)用戶(hù)提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及雙臺(tái)子網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)、雙臺(tái)子網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
mode http
log global
option httplog
option http-server-close
option http-pretend-keepalive
option forwardfor except 127.0.0.0/8
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 655350
參數(shù)詳解:
mode:設(shè)置默認(rèn)工作模式為http,也可以在backend段中單獨(dú)設(shè)置
option httplog:設(shè)置記錄的日志格式更為詳細(xì),可以在frontend段中單獨(dú)設(shè)置
option http-server-close:主動(dòng)斷開(kāi)長(zhǎng)連接,當(dāng)開(kāi)啟長(zhǎng)連接時(shí),應(yīng)該開(kāi)啟此項(xiàng)
注:當(dāng)開(kāi)啟此選項(xiàng)時(shí),haproxy在向后端服務(wù)器發(fā)送請(qǐng)求時(shí),會(huì)在header中添加“Connection:close”,但是有些服務(wù)器看到此頭部時(shí),直接會(huì)拒絕訪(fǎng)問(wèn)
option http-pretend-keepalive:假裝自己是保持連接的
注:當(dāng)開(kāi)啟此選項(xiàng)時(shí),haproxy會(huì)去掉頭部“Connection:close”,此選項(xiàng)與http-server-close一起使用
option forwardfor:向后端轉(zhuǎn)發(fā)客戶(hù)端的真實(shí)IP,except表示排除指定的網(wǎng)段
timeout http-request:當(dāng)客戶(hù)端發(fā)送的請(qǐng)求,在指定時(shí)間內(nèi)發(fā)送不完整時(shí),斷開(kāi)連接
timeout connect:建立連接的超時(shí)時(shí)長(zhǎng)
timeout client:當(dāng)客戶(hù)超過(guò)多久不活動(dòng)時(shí)的超時(shí)時(shí)長(zhǎng)
timeout http-keep-alive:長(zhǎng)連接超時(shí)時(shí)長(zhǎng)
timeout check:健康檢查超時(shí)時(shí)長(zhǎng)
maxconn:最大連接數(shù)
linux系統(tǒng)的優(yōu)化:
1.長(zhǎng)連接:如果不設(shè)置長(zhǎng)連接,會(huì)造成大量的timewait
2.縮短time_wait時(shí)間
#cat /proc/sys/net/ipv4/tcp_fin_timeout //查看timewait的默認(rèn)保持時(shí)長(zhǎng),默認(rèn)為60s
永久生效在/etc/sysctl.conf中設(shè)置
設(shè)置方法:net.ipv4.tcp_fin_timeout = 10
3.設(shè)置time_wait快速回收和重用
#cat /proc/sys/net/ipv4/tcp_tw_reuse
#cat /proc/sys/net/ipv4/tcp_tw_recycle
默認(rèn)為0,設(shè)置為1
設(shè)置方法:
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
4.修改本地端口可用范圍
#cat /proc/sys/net/ipv4/ip_local_port_range
默認(rèn)為32768到61000
建議把32768的值設(shè)的小一點(diǎn),以便可以使用更多的端口,如設(shè)為1024
設(shè)置方法:
net.ipv4.ip_local_port_range = 4000 65535
sysctl -p使設(shè)置生效
5.設(shè)置可打開(kāi)文件描述符,用ulimit -n進(jìn)行查看,默認(rèn)為1024
echo '* - nofile 65535' >> /etc/security/limits.conf
分享題目:haproxy參數(shù)優(yōu)化
路徑分享:http://www.dlmjj.cn/article/peoope.html