Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Haproxy parameter optimization

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Commonly used optimized configurations for global:

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

Detailed description of parameters:

Mode: set the default working mode to http, or you can set it separately in the backend section

Option httplog: set the log format of records in more detail, which can be set separately in the frontend section

Option http-server-close: actively disconnect the persistent connection. This should be enabled when the persistent connection is opened.

Note: when this option is enabled, haproxy will add "Connection:close" to the header when sending a request to the back-end server, but some servers will directly deny access when they see this header

Option http-pretend-keepalive: pretend to be connected

Note: when this option is turned on, haproxy removes the header "Connection:close". This option is used with http-server-close.

Option forwardfor: forward the real IP,except of the client to the backend to exclude the specified IP address range

Timeout http-request: disconnects when the request sent by the client is incomplete within a specified time

Timeout connect: the timeout for establishing a connection

Timeout client: the timeout when the customer is inactive

Timeout http-keep-alive: long connection timeout

Timeout check: health check-up timeout

Maxconn: maximum connections

Optimization of linux system:

1. Persistent connection: if a persistent connection is not set, it will result in a large amount of timewait

two。 Reduce time_wait Tim

# cat / proc/sys/net/ipv4/tcp_fin_timeout / / View the default retention period of timewait, which defaults to 60s

Permanent effect is set in / etc/sysctl.conf

Setting method: net.ipv4.tcp_fin_timeout = 10

3. Set up time_wait rapid recycling and reuse

# cat / proc/sys/net/ipv4/tcp_tw_reuse

# cat / proc/sys/net/ipv4/tcp_tw_recycle

Default is 0, set to 1

Setting method:

Net.ipv4.tcp_tw_reuse = 1

Net.ipv4.tcp_tw_recycle = 1

4. Modify the available range of local ports

# cat / proc/sys/net/ipv4/ip_local_port_range

The default is 32768 to 61000

It is recommended to make the value of 32768 smaller so that more ports can be used, such as 1024

Setting method:

Net.ipv4.ip_local_port_range = 4000 65535

Sysctl-p makes the setting effective

5. Set the openable file descriptor and view it with ulimit-n. The default is 1024.

Echo'*-nofile 65535'> > / etc/security/limits.conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report