| Apache Mina framework is often used as the development framework for the TCP server side because of its convenience of data reception and excellent performance in data transmission.With the rapid development of the Internet of Things in recent years,traditional industries begin to integrate with the Internet,and more and more terminals need to upload data to the server through TCP communication.The traditional single Apache Mina TCP server can no longer meet the high concurrence of clients' requests.To solve this problem,it is necessary to build server clusters and use multiple servers to share the pressure of clients' requests.Building a server cluster requires a very complex configuration of hardware and software,and Apache Mina doesn't provide the function of cluster development.Therefore,this research will extend a component that can directly support the development of the TCP server cluster on the basis of the existing modules of Apache Mina.And developers can make it easy to use the component when using Apache Mina to develop TCP server cluster,and simplify the development and building process of the server cluster.The main research works presented in the thesis are as follows:Ⅰ.It analyzes the source code that the Apache Mina TCP server side deals with Socket connections,points out the bottleneck of response delay and low throughput of a single Apache Mina server when it deals with high concurrent Socket connections.Then,adding a component called Mina-Cluster to Apache Mina is put forward.And this component enables Apache Mina to support the development and construction of the TCP server cluster directly.By analyzing the workflow of three commonly used cluster softwares,namely LVS,Nginx and HAProxy,a Master-Slave architecture solution is put forward to solve the problem of architecture designing of the component.Ⅱ.The Master-Slave architecture proposed in this thesis consists of three key designs.The Client node is in charge of communicating with the Master node and obtaining specific server information,the Master node is in charge of scheduling the client's requests,and the Slave node is in charge of collecting the specific server information and communicating with the Master node.Accordingly,this thesis divides the structure of three nodes of Client,Master and Slave in detail in 3 research points.The first research point is to design the structure of the Client node and define the communication process and communication protocol between the Client node and the Master node.The second research point is to design the structure of the Master node,including defining the communication process and communication protocol between the Master node and the Slave node,designing information storage module and configurable module,and designing scalable load balancing interface and three basic load balancing algorithms.The third research point is to design the Slave node structure and analyze the high availability of the Slave node by the Markov model.Ⅲ.It designs the API of the component and defines usage specification of the API,so that developers can easily use the component extended in Apache Mina,accelerate the development and the construction of TCP communication server cluster.The API mainly includes three basic classes: ClientToMaster encapsulates the communication process between the Client node and the Master node,Master encapsulates information storage module and load balancing algorithms,and Slave encapsulates server information collection module and the communication process between the Slave node and the Master node.Ⅳ.The function tests of Mina-Cluster are carried out and the results are analyzed,which shows that it can work properly.A cluster environment is built to test the performance of Mina-Cluster.It proves that Mina-Cluster has the effect of reducing the response time of the server.Finally,Mina-Cluster is applied to the intelligent gas meter communication server to further verify that it can be used in the actual projects. |