Server protocol


1. [Recommendation] For high-concurrency servers, it is recommended to reduce the time_wait timeout of the TCP protocol.

Note: The operating system will close the connection in the time _ wait state after 240 seconds by default. Under high concurrent access, the server will be closed because it is in the time _ wait state. The number of wait connections is too large and new connections may not be established, so the wait value needs to be reduced on the server.

Positive example: On the Linux server, please modify the default value (seconds) by changing the /etc/sysctl.conf file:

net. ipv 4. tcp _ fin _ timeout = 30

2. [Recommended] Increase the maximum number of file handles (File Descriptor, abbreviated as fd) supported by the server.

Note: The design of mainstream operating systems is to manage TCP/UDP connections in the same way as files, that is, one connection corresponds to one fd. The default maximum number of fds supported by mainstream Linux servers is 1024. When the number of concurrent connections is large, it is easy to cause "open too many files" errors due to insufficient fds, causing new connections to fail to be established. It is recommended to increase the maximum number of handles supported by the Linux server several times (related to the amount of memory on the server).

3. [Recommended] Set the -XX: HeapDumpOnOutOfMemoryError parameter to the JVM to let the JVM output

dump information when it encounters an OOM scenario.

Note: OOM occurs with probability, and even one case occurs regularly every few months. The on-site information when it occurs is very valuable for troubleshooting .

4. [Reference] Use forward for internal redirection of the server; use the URL assembly tool class to generate the external redirection address, otherwise

it will cause URL maintenance inconsistencies and potential security risks. .