If the communication protocol uses TCP/IP, the socket connection between the client and the middleware is very exquisite.
The short connection and persistent connection should be cleverly used in applications. Purely using persistent connections or purely using short connections,
Usually not reasonable. If a socket is used for a long time to relax, this will undoubtedly be a waste of middleware resources. If the number of such casual persistent connections is large, it may affect the middleware performance. Middleware automatically disconnects casual connections for a long time through heartbeat packets. In fact, this is the last line of defense of middleware against such events.
It is not very good if the remote equations are all short connections. For example, some remote methods are executed in blocks. If a remote method is executed to establish a socket connection with the middleware, the connection will be closed immediately after execution, this is not good. Because it is time-consuming to establish a socket connection, some remote methods are executed in blocks, and
It takes a lot of time. Therefore, we can establish a persistent connection before these block-based remote methods are executed. It is reasonable to close this persistent connection after these remote methods are executed.
In fact, both persistent connections and short connections are relative. Things in the world are often not pure. The so-called persistent connection has short connections and short connections have long connections. Can you see it?
Set the thread mode of the middleware thread pool, and skillfully use the combination of long and short connections on the client side to reasonably build a multi-layer architecture.