Solutions for LVS Server Load balancer tcp persistent connection Distribution

Source: Internet
Author: User
Tags connection reset

Solutions for LVS Server Load balancer tcp persistent connection Distribution

Although the application keepalived solves the backend server Load balancer and high availability problems, you must pay attention to many problems in specific applications. Many applications use tcp or http persistent connections. Because the overhead of establishing a tcp connection or http connection is large, the application needs to communicate frequently with the server, at this time, it is undoubtedly very appropriate to maintain a persistent connection. After exploring the lvs & keepalived persistent connection configuration, the configuration is mainly in three places:
1. The SoTimeout of the client is set by the setSoTimeout method of java.net. Socket in java. setSoTimeout (0) indicates that the timeout time is infinite. This value sets timeout for read blocking.
Ii. lvs settings:
Check whether it is ipvsadm -- list -- timeout. For example, my machine will return the following results:
# Ipvsadm -- list -- timeout
Timeout (tcp tcpfin udp): 7200 5 60
This indicates that the timeout time of my tcp session is 7200 seconds.
Set timeout:
Ipvsadm -- set 7200 5 60
If this value is too small, your client will receive an error message such as connection reset by peer.
Iii. keepalived Configuration:
It is the persistence_timeout of virtual_server, which means that the route from the same user (determined by ip address) to the same real
Server. You must do this for persistent connection applications. The Configuration value is best consistent with the timeout configured by lvs.
4. Example:
Virtual_server 172.19.1.19 5222 {
Delay_loop 2
Lb_algo wrr
Lb_kind DR
Persistence_timeout 7200
Protocol TCP

Real_server 172.19.1.8 5222 {
Weight 1
TCP_CHECK {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
}
}
Real_server 172.19.1.9 5222 {
Weight 1
TCP_CHECK {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.