Use Haproxy as the load balancer for SQL Server.
The sample configuration items in the document are used:
Timeout client 50s
Timeout server 50s
With this configuration item, there are sometimes "remote hosts forcing an existing connection to shut down" error.
The reason for this error is that once the SQL client does not send data to haproxy for more than 50s, Haproxy will close the connection, and the SQL client will send the data with an exception when it thinks the connection is still in flux.
After reviewing the official documentation for Haproxy, as well as the documentation for MySQL and SQL Server, change the configuration to:
Timeout Client 8h
Timeout Server 8h
Then it's normal. Why is it set to 8 hours? SQL Server did not find a similar wait timeout data, so borrowed from the MySQL configuration item, MySQL has a configuration named wait timeout, its default time is 8 hours, This configuration item means that when MySQL discovers that the TCP connection with the client is inactive for more than 8 hours (sending and receiving data), then MySQL shuts down the connection. This configuration is similar to the keep alive timeout in http1.1.
Reference:
apache:keep-alive Timeout
Amount of time the server would wait for subsequent requests on a persistent connection
Mysql:wait_timeout
The number of seconds the server waits for activity in an interactive connection before closing it.
haproxy:timeout Client
The inactivity timeout applies when the client was expected to acknowledge or send data.
Haproxy "remote host forced to shut down an existing connection" error and resolution