[go: up one dir, main page]

CN116599962A - A data transmission method and system based on a distributed server - Google Patents

A data transmission method and system based on a distributed server Download PDF

Info

Publication number
CN116599962A
CN116599962A CN202310773143.5A CN202310773143A CN116599962A CN 116599962 A CN116599962 A CN 116599962A CN 202310773143 A CN202310773143 A CN 202310773143A CN 116599962 A CN116599962 A CN 116599962A
Authority
CN
China
Prior art keywords
data
registration center
server
application instance
client
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310773143.5A
Other languages
Chinese (zh)
Inventor
刘德建
郭孟祺
陈娟
郭凤英
郑坦
陈宏�
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian Tianquan Educational Technology Ltd
Original Assignee
Fujian Tianquan Educational Technology Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian Tianquan Educational Technology Ltd filed Critical Fujian Tianquan Educational Technology Ltd
Priority to CN202310773143.5A priority Critical patent/CN116599962A/en
Publication of CN116599962A publication Critical patent/CN116599962A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/566Grouping or aggregating service requests, e.g. for unified processing

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

本发明公开了一种基于分布式服务器的数据传输方法及系统,当应用实例需要进行数据传输时,为数据配置应用标识,并将其直接写入本地缓存队列中;应用实例所在的服务端的后台进程程序会定时的扫描本地缓存队列中的数据,将扫描到的数据聚合后发送至注册中心;注册中心接收到数据包后需要拆包,并根据应用标识得到各应用实例传输的数据。相较于现有技术中的每个应用实例都要与注册中心创建连接进行交互的方法,本发明的数据传输方法通过对一台服务器内,对于同一个注册中心的连接进行特殊管理,一台服务器上的应用实例只会与同一个注册中心创建一个连接,因此能够减少注册中心的连接数量,提高注册中心服务的实例数量以及服务性能与效率。

The invention discloses a data transmission method and system based on a distributed server. When an application instance needs to perform data transmission, an application identifier is configured for the data, and it is directly written into a local cache queue; the background of the server where the application instance is located The process program will regularly scan the data in the local cache queue, aggregate the scanned data and send it to the registration center; the registration center needs to unpack the data packet after receiving it, and obtain the data transmitted by each application instance according to the application identifier. Compared with the method in the prior art where each application instance needs to create a connection to interact with the registration center, the data transmission method of the present invention performs special management on the connection to the same registration center in one server, and one The application instance on the server will only create one connection with the same registry, so the number of connections to the registry can be reduced, and the number of instances of the registry service and service performance and efficiency can be improved.

Description

一种基于分布式服务器的数据传输方法及系统A distributed server-based data transmission method and system

技术领域technical field

本发明涉及数据传输技术领域,特别涉及一种基于分布式服务器的数据传输方法及系统。The invention relates to the technical field of data transmission, in particular to a distributed server-based data transmission method and system.

背景技术Background technique

目前,服务端大部分系统为了满足高并发、高可用等要求,基本上都是采用分布式部署的方式。而采用分布式部署架构后,就需要较多的应用实例部署在不同的机器之上,目前流行的微服务架构也是把众多的实例部署到多台架构之上,并且微服务架构方式下,存在一个注册中心,所有的微服务实例都需要到此注册中心进行注册处理。当注册成功之后,各个客户端都会与注册中心建立一个连接,通过此连接传输心跳以及监控信息,由注册中心汇总并进行后续的分析处理。At present, in order to meet the requirements of high concurrency and high availability, most systems on the server side basically adopt distributed deployment. After adopting the distributed deployment architecture, more application instances need to be deployed on different machines. The current popular micro-service architecture also deploys many instances on multiple architectures, and under the micro-service architecture, there are A registration center, all microservice instances need to go to this registration center for registration processing. After the registration is successful, each client will establish a connection with the registration center, and transmit heartbeat and monitoring information through this connection, which will be collected by the registration center for subsequent analysis and processing.

随着微服务支持的服务实例增多,每一个实例都需要与注册中心创建连接传输心跳,在接入的微服务数量达到一定程度之后,当出现网络异常或者其他异常情况,注册中心与各个客户端的信息通信,将会随着数量的增多而增加,数量众多的连接与心跳传输将给注册中心带来极大的负担。As the number of service instances supported by microservices increases, each instance needs to establish a connection with the registration center to transmit heartbeats. After the number of connected microservices reaches a certain level, when a network exception or other abnormal situation occurs, the registration center and each client Information communication will increase with the increase of the number, and the large number of connections and heartbeat transmission will bring a great burden to the registration center.

发明内容Contents of the invention

本发明所要解决的技术问题是:提供一种基于分布式服务器的数据传输方法及系统,能够减少服务器上的实例与注册中心的连接数量,提高注册中心服务的实例数量以及服务性能与效率。The technical problem to be solved by the present invention is to provide a distributed server-based data transmission method and system, which can reduce the number of connections between instances on the server and the registration center, and increase the number of instances served by the registration center as well as service performance and efficiency.

为了解决上述技术问题,本发明采用的技术方案为:In order to solve the problems of the technologies described above, the technical solution adopted in the present invention is:

一种基于分布式服务器的数据传输方法,包括步骤:A data transmission method based on a distributed server, comprising the steps of:

应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列;The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client;

应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心;The server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center;

注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier.

为了解决上述技术问题,本发明采用的另一种技术方案为:In order to solve the above-mentioned technical problems, another kind of technical scheme that the present invention adopts is:

一种基于分布式服务器的数据传输系统,包括应用实例、服务器以及注册中心;A data transmission system based on distributed servers, including application instances, servers and registration centers;

应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列;The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client;

应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心;The server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center;

注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier.

本发明的有益效果在于:当应用实例需要进行数据传输时,为数据配置应用标识,并将其直接写入本地缓存队列中;应用实例所在的服务端的后台进程程序会定时的扫描本地缓存队列中的数据,将扫描到的数据聚合后发送至注册中心;注册中心接收到数据包后需要拆包,并根据应用标识得到各应用实例传输的数据。相较于现有技术中的每个应用实例都要与注册中心创建连接进行交互的方法,本发明的数据传输方法通过对一台服务器内,对于同一个注册中心的连接进行特殊管理,一台服务器上的应用实例只会与同一个注册中心创建一个连接,因此能够减少注册中心的连接数量,提高注册中心服务的实例数量以及服务性能与效率。The beneficial effects of the present invention are: when the application instance needs to transmit data, configure the application identifier for the data, and write it directly into the local cache queue; the background process program of the server where the application instance is located will regularly scan the local cache queue The scanned data is aggregated and sent to the registration center; the registration center needs to unpack the data package after receiving it, and obtain the data transmitted by each application instance according to the application identification. Compared with the method in the prior art where each application instance needs to create a connection to interact with the registration center, the data transmission method of the present invention performs special management on the connection to the same registration center in one server, and one The application instance on the server will only create one connection with the same registry, so the number of connections to the registry can be reduced, and the number of instances of the registry service and service performance and efficiency can be increased.

附图说明Description of drawings

图1为本发明实施例的一种基于分布式服务器的数据传输方法的流程图;Fig. 1 is a flow chart of a data transmission method based on a distributed server according to an embodiment of the present invention;

图2为本发明实施例的一种基于分布式服务器的数据传输系统的示意图。FIG. 2 is a schematic diagram of a distributed server-based data transmission system according to an embodiment of the present invention.

具体实施方式Detailed ways

为详细说明本发明的技术内容、所实现目的及效果,以下结合实施方式并配合附图予以说明。In order to describe the technical content, achieved goals and effects of the present invention in detail, the following descriptions will be made in conjunction with the embodiments and accompanying drawings.

请参照图1,本发明实施例提供了一种基于分布式服务器的数据传输方法,包括步骤:Please refer to Fig. 1, the embodiment of the present invention provides a kind of data transmission method based on distributed server, comprises steps:

应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列;The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client;

应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心;The server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center;

注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier.

从上述描述可知,本发明的有益效果在于:当应用实例需要进行数据传输时,为数据配置应用标识,并将其直接写入本地缓存队列中;应用实例所在的服务端的后台进程程序会定时的扫描本地缓存队列中的数据,将扫描到的数据聚合后发送至注册中心;注册中心接收到数据包后需要拆包,并根据应用标识得到各应用实例传输的数据。相较于现有技术中的每个应用实例都要与注册中心创建连接进行交互的方法,本发明的数据传输方法通过对一台服务器内,对于同一个注册中心的连接进行特殊管理,一台服务器上的应用实例只会与同一个注册中心创建一个连接,因此能够减少注册中心的连接数量,提高注册中心服务的实例数量以及服务性能与效率。It can be seen from the above description that the beneficial effects of the present invention are: when the application instance needs to transmit data, configure the application identifier for the data and write it directly into the local cache queue; the background process program of the server where the application instance is located will regularly Scan the data in the local cache queue, aggregate the scanned data and send it to the registration center; the registration center needs to unpack the data packet after receiving it, and obtain the data transmitted by each application instance according to the application identifier. Compared with the method in the prior art where each application instance needs to create a connection to interact with the registration center, the data transmission method of the present invention performs special management on the connection to the same registration center in one server, and one The application instance on the server will only create one connection with the same registry, so the number of connections to the registry can be reduced, and the number of instances of the registry service and service performance and efficiency can be improved.

进一步地,还包括:Further, it also includes:

注册中心向注册中心客户端发送任务时,根据所述应用实例的应用标识对待发送的第二数据进行配置,将配置后的第二数据聚合为第二数据包并发送至应用实例所在服务器;When the registration center sends a task to the registration center client, configure the second data to be sent according to the application identifier of the application instance, aggregate the configured second data into a second data packet and send it to the server where the application instance is located;

所述服务器通过对应的后台进程程序对所述第二数据包进行拆包,将拆包得到的第二数据按照所述应用标识发送至对应注册中心客户端的本地缓存队列中。The server unpacks the second data packet through a corresponding background process program, and sends the unpacked second data to the local cache queue of the corresponding registration center client according to the application identifier.

由上述描述可知,通过注册中心与应用所在服务器的连接,能够将要发送给应用实例的任务进行聚合,并发送至其对应的服务器中,服务器对聚合的数据包拆包后即可根据应用标识将第二数据分发至对应的注册中心客户端的本地缓存队列中。保证通过应用实例所在服务端与注册中心的一个连接,即可实现应用实例中注册中心客户端与注册中心的数据传输,同时注册中心仅需发送一条消息至服务端即可,进一步提高数据传输的效率。It can be seen from the above description that through the connection between the registration center and the server where the application is located, the tasks to be sent to the application instance can be aggregated and sent to the corresponding server. After the server unpacks the aggregated data packet, it can send the The second data is distributed to the local cache queue of the corresponding registration center client. Ensure that the data transmission between the registration center client and the registration center in the application instance can be realized through a connection between the server where the application instance is located and the registration center. At the same time, the registration center only needs to send a message to the server, which further improves the efficiency of data transmission. efficiency.

进一步地,将拆包得到的第二数据发送至对应注册中心客户端的本地缓存队列中,之后包括:Further, the second data obtained by unpacking is sent to the local cache queue of the corresponding registration center client, and then includes:

注册中心客户端从所述本地缓存队列中获取所述第二数据,并根据所述第二数据从所述注册中心拉取任务数据。The registration center client obtains the second data from the local cache queue, and pulls task data from the registration center according to the second data.

由上述描述可知,注册中心客户端接收到注册中心发送的任务之后,即可主动从注册中心拉取任务数据,保证注册中心客户端与注册中心间的数据传输。It can be seen from the above description that after receiving the task sent by the registration center, the registration center client can actively pull task data from the registration center to ensure the data transmission between the registration center client and the registration center.

进一步地,应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,之前包括:Further, the server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, including:

注册中心客户端判断应用实例所在服务器是否存在对应的后台进程程序,若是,则直接由所述后台进程程序与注册中心建立连接,否则,创建后台进程程序,并由所述后台进程程序与注册中心建立连接。The registration center client judges whether there is a corresponding background process program on the server where the application instance is located, and if so, directly establishes a connection between the background process program and the registration center; establish connection.

由上述描述可知,注册中心客户端与注册中心之间通过应用实例所在服务器的后台进程程序来进行数据传输,该后台进程程序可由应用实例对应的注册中心客户端创建,确保服务器与注册中心的连接不中断。It can be seen from the above description that the data transmission between the registration center client and the registration center is carried out through the background process program of the server where the application instance is located. The background process program can be created by the registration center client corresponding to the application instance to ensure the connection between the server and the registration center without interruption.

进一步地,由所述后台进程程序与注册中心建立连接包括:Further, establishing a connection with the registration center by the background process program includes:

当存在多个注册中心时,由所述后台进程程序与注册中心建立连接,并为所述连接配置注册中心的唯一标识。When there are multiple registration centers, the background process program establishes a connection with the registration center, and configures the unique identifier of the registration center for the connection.

由上述描述可知,如果存在多个注册中心,将会存在多个连接,因此通过注册中心的唯一标识进行区分,保证数据传输的正常运行。It can be seen from the above description that if there are multiple registration centers, there will be multiple connections, so the unique identifiers of the registration centers are used to distinguish them to ensure the normal operation of data transmission.

请参照图2,本发明另一实施例提供了一种基于分布式服务器的数据传输系统,包括应用实例、服务器以及注册中心;Referring to Fig. 2, another embodiment of the present invention provides a data transmission system based on a distributed server, including an application instance, a server, and a registration center;

应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列;The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client;

应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心;The server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center;

注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier.

从上述描述可知,本发明的有益效果在于:当应用实例需要进行数据传输时,为数据配置应用标识,并将其直接写入本地缓存队列中;应用实例所在的服务端的后台进程程序会定时的扫描本地缓存队列中的数据,将扫描到的数据聚合后发送至注册中心;注册中心接收到数据包后需要拆包,并根据应用标识得到各应用实例传输的数据。相较于现有技术中的每个应用实例都要与注册中心创建连接进行交互的方法,本发明的数据传输方法通过对一台服务器内,对于同一个注册中心的连接进行特殊管理,一台服务器上的应用实例只会与同一个注册中心创建一个连接,因此能够减少注册中心的连接数量,提高注册中心服务的实例数量以及服务性能与效率。It can be seen from the above description that the beneficial effects of the present invention are: when the application instance needs to transmit data, configure the application identifier for the data and write it directly into the local cache queue; the background process program of the server where the application instance is located will regularly Scan the data in the local cache queue, aggregate the scanned data and send it to the registration center; the registration center needs to unpack the data packet after receiving it, and obtain the data transmitted by each application instance according to the application identifier. Compared with the method in the prior art where each application instance needs to create a connection to interact with the registration center, the data transmission method of the present invention performs special management on the connection to the same registration center in one server, and one The application instance on the server will only create one connection with the same registry, so the number of connections to the registry can be reduced, and the number of instances of the registry service and service performance and efficiency can be improved.

进一步地,还包括:Further, it also includes:

注册中心向注册中心客户端发送任务时,根据所述应用实例的应用标识对待发送的第二数据进行配置,将配置后的第二数据聚合为第二数据包并发送至应用实例所在服务器;When the registration center sends a task to the registration center client, configure the second data to be sent according to the application identifier of the application instance, aggregate the configured second data into a second data packet and send it to the server where the application instance is located;

所述服务器通过对应的后台进程程序对所述第二数据包进行拆包,将拆包得到的第二数据按照所述应用标识发送至对应注册中心客户端的本地缓存队列中。The server unpacks the second data packet through a corresponding background process program, and sends the unpacked second data to the local cache queue of the corresponding registration center client according to the application identifier.

由上述描述可知,通过注册中心与应用所在服务器的连接,能够将要发送给应用实例的任务进行聚合,并发送至其对应的服务器中,服务器对聚合的数据包拆包后即可根据应用标识将第二数据分发至对应的注册中心客户端的本地缓存队列中。保证通过应用实例所在服务端与注册中心的一个连接,即可实现应用实例中注册中心客户端与注册中心的数据传输,同时注册中心仅需发送一条消息至服务端即可,进一步提高数据传输的效率。It can be seen from the above description that through the connection between the registration center and the server where the application is located, the tasks to be sent to the application instance can be aggregated and sent to the corresponding server. After the server unpacks the aggregated data packet, it can send the The second data is distributed to the local cache queue of the corresponding registration center client. Ensure that the data transmission between the registration center client and the registration center in the application instance can be realized through a connection between the server where the application instance is located and the registration center. At the same time, the registration center only needs to send a message to the server, which further improves the efficiency of data transmission. efficiency.

进一步地,将拆包得到的第二数据发送至对应注册中心客户端的本地缓存队列中,之后包括:Further, the second data obtained by unpacking is sent to the local cache queue of the corresponding registration center client, and then includes:

注册中心客户端从所述本地缓存队列中获取所述第二数据,并根据所述第二数据从所述注册中心拉取任务数据。The registration center client obtains the second data from the local cache queue, and pulls task data from the registration center according to the second data.

由上述描述可知,注册中心客户端接收到注册中心发送的任务之后,即可主动从注册中心拉取任务数据,保证注册中心客户端与注册中心间的数据传输。It can be seen from the above description that after receiving the task sent by the registration center, the registration center client can actively pull task data from the registration center to ensure the data transmission between the registration center client and the registration center.

进一步地,应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,之前包括:Further, the server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, including:

注册中心客户端判断应用实例所在服务器是否存在对应的后台进程程序,若是,则直接由所述后台进程程序与注册中心建立连接,否则,创建后台进程程序,并由所述后台进程程序与注册中心建立连接。The registration center client judges whether there is a corresponding background process program on the server where the application instance is located, and if so, directly establishes a connection between the background process program and the registration center; establish connection.

由上述描述可知,注册中心客户端与注册中心之间通过应用实例所在服务器的后台进程程序来进行数据传输,该后台进程程序可由应用实例对应的注册中心客户端创建,确保服务器与注册中心的连接不中断。It can be seen from the above description that the data transmission between the registration center client and the registration center is carried out through the background process program of the server where the application instance is located. The background process program can be created by the registration center client corresponding to the application instance to ensure the connection between the server and the registration center without interruption.

进一步地,由所述后台进程程序与注册中心建立连接包括:Further, establishing a connection with the registration center by the background process program includes:

当存在多个注册中心时,由所述后台进程程序与注册中心建立连接,并为所述连接配置注册中心的唯一标识。When there are multiple registration centers, the background process program establishes a connection with the registration center, and configures the unique identifier of the registration center for the connection.

由上述描述可知,如果存在多个注册中心,将会存在多个连接,因此通过注册中心的唯一标识进行区分,保证数据传输的正常运行。It can be seen from the above description that if there are multiple registration centers, there will be multiple connections, so the unique identifiers of the registration centers are used to distinguish them to ensure the normal operation of data transmission.

本发明上述的一种基于分布式服务器的数据传输方法及系统,适用于微服务架构中,减少服务器上的实例与注册中心的连接数量,提高注册中心服务的实例数量以及服务性能与效率,以下通过具体的实施方式进行说明:The above-mentioned distributed server-based data transmission method and system of the present invention are suitable for micro-service architecture, reducing the number of connections between instances on the server and the registration center, and increasing the number of instances served by the registration center as well as service performance and efficiency, as follows To illustrate through specific implementation methods:

实施例一Embodiment one

请参照图1,一种基于分布式服务器的数据传输方法,包括步骤:Please refer to Figure 1, a distributed server-based data transmission method, including steps:

S1、应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列。S1. The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client.

在本实施例中,设微服务架构已经存在一个注册中心,在一个服务器上部署一应用实例,此时应用实例集成了注册中心客户端,在注册中心客户端上增加一层代理层。In this embodiment, it is assumed that a registration center already exists in the microservice architecture, and an application instance is deployed on a server. At this time, the application instance integrates the registration center client, and a proxy layer is added to the registration center client.

服务器上的注册中心客户端与此后台进程程序通过本地缓存队列来进行消息交互。当注册中心客户端需要发送数据,例如心跳信息时,直接向本地缓存队列中写入心跳消息,写入的内容主要包括应用唯一标识以及消息类型【心跳类型】。后台进程程序会定时的扫描本地缓存队列中的信息,读取完毕后,会间隔一段时间,聚合相关的心跳包消息,并进行一次聚合心跳包发送。The registration center client on the server interacts with the background process program through the local cache queue. When the registration center client needs to send data, such as heartbeat information, it directly writes the heartbeat message to the local cache queue. The written content mainly includes the unique application identifier and the message type [heartbeat type]. The background process program will regularly scan the information in the local cache queue. After reading, it will aggregate related heartbeat packet messages at intervals, and send an aggregated heartbeat packet.

本实施例中处理发送心跳信息,也可以进行监控数据等其他数据的传输。In this embodiment, heartbeat information is processed and sent, and other data such as monitoring data can also be transmitted.

S2、应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心。S2. The server where the application instance is located regularly scans the data in the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center .

具体的,注册中心客户端判断应用实例所在服务器是否存在对应的后台进程程序,若是,则直接由所述后台进程程序与注册中心建立连接,否则,创建后台进程程序,并由所述后台进程程序与注册中心建立连接。Specifically, the registration center client judges whether there is a corresponding background process program on the server where the application instance is located, and if so, directly establishes a connection between the background process program and the registration center; Establish a connection with the registry.

在本实施例中,通过注册中心客户端的代理层来判断服务器上是否存在一个独立的后台进程程序,并且该程序已启动;若不存在,则由代理层主动创建后台进程程序,并由此程序与注册中心创建一个连接;若存在,则直接使用程序与注册中心建立的这个连接。通过此步骤,已经确保了一台服务器上只会有一个连接与同一个注册中心进行通信。In this embodiment, it is judged whether there is an independent background process program on the server through the proxy layer of the registration center client, and the program has started; if it does not exist, the background process program is actively created by the proxy layer, and the program Create a connection with the registry; if it exists, use the connection established by the program with the registry directly. Through this step, it has been ensured that only one connection on a server communicates with the same registry.

其中,当存在多个注册中心时,由所述后台进程程序与注册中心建立连接,并为所述连接配置注册中心的唯一标识。Wherein, when there are multiple registration centers, the background process program establishes a connection with the registration center, and configures the unique identifier of the registration center for the connection.

在本实施例中,如果存在多个注册中心,将会存在多个连接,通过注册中心的唯一标识进行区分。In this embodiment, if there are multiple registration centers, there will be multiple connections, which are distinguished by unique identifiers of the registration centers.

S3、注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。S3. The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier.

在本实施例中,当注册中心接收到心跳包后,需要对心跳包进行拆包,并根据不同应用唯一标识获取对应的心跳消息,并进行后续的处理。In this embodiment, after receiving the heartbeat packet, the registration center needs to unpack the heartbeat packet, and obtain corresponding heartbeat messages according to unique identifiers of different applications, and perform subsequent processing.

实施例二Embodiment two

本实施例与实施例一的不同在于,进一步限定了注册中心需要通知相关应用实例进行任务时的数据传输方法:The difference between this embodiment and Embodiment 1 is that the data transmission method when the registration center needs to notify the relevant application instance to perform a task is further limited:

注册中心向注册中心客户端发送任务时,根据所述应用实例的应用标识对待发送的第二数据进行配置,将配置后的第二数据聚合为第二数据包并发送至应用实例所在服务器。When the registration center sends a task to the registration center client, it configures the second data to be sent according to the application identifier of the application instance, aggregates the configured second data into a second data packet, and sends it to the server where the application instance is located.

所述服务器通过对应的后台进程程序对所述第二数据包进行拆包,将拆包得到的第二数据按照所述应用标识发送至对应注册中心客户端的本地缓存队列中。The server unpacks the second data packet through a corresponding background process program, and sends the unpacked second data to the local cache queue of the corresponding registration center client according to the application identifier.

注册中心客户端从所述本地缓存队列中获取所述第二数据,并根据所述第二数据从所述注册中心拉取任务数据。The registration center client obtains the second data from the local cache queue, and pulls task data from the registration center according to the second data.

具体的,当注册中心需要通知相关注册中心客户端进行任务时,可以批量聚合信息的方式,发送聚合的消息包至注册中心客户端,由后台进程程序进行拆包后,发送至本地缓存队列中,由对应的注册中心客户端客户端来进行读取。Specifically, when the registration center needs to notify the relevant registration center client to perform a task, it can aggregate information in batches, send the aggregated message package to the registration center client, unpack it by the background process program, and send it to the local cache queue , read by the corresponding registry client client.

比如,注册中心可能会发送消息,要求客户端重新获取注册中心这边最新的服务列表信息。此时,只需要发送一条通知消息,客户端接收后,向注册中心主动拉取服务列表信息,此时,注册中心也只需要发送一份最新服务列表信息至连接中即可。For example, the registration center may send a message requesting the client to reacquire the latest service list information from the registration center. At this time, it is only necessary to send a notification message. After receiving it, the client will actively pull the service list information from the registration center. At this time, the registration center only needs to send a copy of the latest service list information to the connection.

实施例三Embodiment three

请参照图2,一种基于分布式服务器的数据传输系统,包括应用实例、服务器以及注册中心;Please refer to Figure 2, a data transmission system based on distributed servers, including application instances, servers and registration centers;

应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列;The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client;

注册中心客户端判断应用实例所在服务器是否存在对应的后台进程程序,若是,则直接由所述后台进程程序与注册中心建立连接,否则,创建后台进程程序,并由所述后台进程程序与注册中心建立连接;其中,当存在多个注册中心时,由所述后台进程程序与注册中心建立连接,并为所述连接配置注册中心的唯一标识;The registration center client judges whether there is a corresponding background process program on the server where the application instance is located, and if so, directly establishes a connection between the background process program and the registration center; Establishing a connection; wherein, when there are multiple registration centers, the background process program establishes a connection with the registration center, and configures the unique identifier of the registration center for the connection;

应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心;The server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center;

注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier.

在一些实施例中,还包括:In some embodiments, also include:

注册中心向注册中心客户端发送任务时,根据所述应用实例的应用标识对待发送的第二数据进行配置,将配置后的第二数据聚合为第二数据包并发送至应用实例所在服务器;When the registration center sends a task to the registration center client, configure the second data to be sent according to the application identifier of the application instance, aggregate the configured second data into a second data packet and send it to the server where the application instance is located;

所述服务器通过对应的后台进程程序对所述第二数据包进行拆包,将拆包得到的第二数据按照所述应用标识发送至对应注册中心客户端的本地缓存队列中;The server unpacks the second data packet through a corresponding background process program, and sends the second data obtained by unpacking to the local cache queue of the corresponding registration center client according to the application identifier;

注册中心客户端从所述本地缓存队列中获取所述第二数据,并根据所述第二数据从所述注册中心拉取任务数据。The registration center client obtains the second data from the local cache queue, and pulls task data from the registration center according to the second data.

综上所述,本发明提供的一种基于分布式服务器的数据传输方法及系统,当应用实例需要进行数据传输时,为数据配置应用标识,并将其直接写入本地缓存队列中;应用实例所在的服务端的后台进程程序会定时的扫描本地缓存队列中的数据,将扫描到的数据聚合后发送至注册中心;注册中心接收到数据包后需要拆包,并根据应用标识得到各应用实例传输的数据。同理,当注册中心需要通知相关客户端进行任务时,也可以采用批量聚合信息的方式,发送聚合的消息包至客户端,由后台进程程序进行拆包后,发送至本地缓存队列中,由对应的客户端来进行读取。相较于现有技术中的每个应用实例都要与注册中心创建连接进行交互的方法,本发明的数据传输方法通过对一台服务器内,对于同一个注册中心的连接进行特殊管理,一台服务器上的应用实例只会与同一个注册中心创建一个连接,因此能够减少注册中心的连接数量,提高注册中心服务的实例数量以及服务性能与效率。In summary, the present invention provides a distributed server-based data transmission method and system. When an application instance needs to perform data transmission, an application identifier is configured for the data, and it is directly written into the local cache queue; the application instance The background process program of the server where it is located will regularly scan the data in the local cache queue, aggregate the scanned data and send it to the registration center; the registration center needs to unpack the data packet after receiving it, and obtain the transmission of each application instance according to the application identification The data. Similarly, when the registration center needs to notify the relevant clients to perform tasks, it can also use the method of batch aggregation information to send the aggregated message package to the client. After the background process program unpacks it, it sends it to the local cache queue. The corresponding client to read. Compared with the method in the prior art where each application instance needs to create a connection to interact with the registration center, the data transmission method of the present invention performs special management on the connection to the same registration center in one server, and one The application instance on the server will only create one connection with the same registry, so the number of connections to the registry can be reduced, and the number of instances of the registry service and service performance and efficiency can be increased.

以上所述仅为本发明的实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等同变换,或直接或间接运用在相关的技术领域,均同理包括在本发明的专利保护范围内。The above description is only an embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent transformations made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in related technical fields, are all included in the same principle. Within the scope of patent protection of the present invention.

Claims (10)

1.一种基于分布式服务器的数据传输方法,其特征在于,包括步骤:1. A data transmission method based on a distributed server, characterized in that, comprising steps: 应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列;The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client; 应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心;The server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center; 注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier. 2.根据权利要求1所述的一种基于分布式服务器的数据传输方法,其特征在于,还包括:2. A kind of data transmission method based on distributed server according to claim 1, is characterized in that, also comprises: 注册中心向注册中心客户端发送任务时,根据所述应用实例的应用标识对待发送的第二数据进行配置,将配置后的第二数据聚合为第二数据包并发送至应用实例所在服务器;When the registration center sends a task to the registration center client, configure the second data to be sent according to the application identifier of the application instance, aggregate the configured second data into a second data packet and send it to the server where the application instance is located; 所述服务器通过对应的后台进程程序对所述第二数据包进行拆包,将拆包得到的第二数据按照所述应用标识发送至对应注册中心客户端的本地缓存队列中。The server unpacks the second data packet through a corresponding background process program, and sends the unpacked second data to the local cache queue of the corresponding registration center client according to the application identifier. 3.根据权利要求2所述的一种基于分布式服务器的数据传输方法,其特征在于,将拆包得到的第二数据发送至对应注册中心客户端的本地缓存队列中,之后包括:3. A kind of data transmission method based on distributed server according to claim 2, it is characterized in that, the second data obtained by unpacking is sent to the local cache queue of corresponding registration center client, afterwards comprising: 注册中心客户端从所述本地缓存队列中获取所述第二数据,并根据所述第二数据从所述注册中心拉取任务数据。The registration center client obtains the second data from the local cache queue, and pulls task data from the registration center according to the second data. 4.根据权利要求1所述的一种基于分布式服务器的数据传输方法,其特征在于,应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,之前包括:4. The data transmission method based on a distributed server according to claim 1, wherein the server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, including : 注册中心客户端判断应用实例所在服务器是否存在对应的后台进程程序,若是,则直接由所述后台进程程序与注册中心建立连接,否则,创建后台进程程序,并由所述后台进程程序与注册中心建立连接。The registration center client judges whether there is a corresponding background process program on the server where the application instance is located, and if so, directly establishes a connection between the background process program and the registration center; establish connection. 5.根据权利要求4所述的一种基于分布式服务器的数据传输方法,其特征在于,由所述后台进程程序与注册中心建立连接包括:5. a kind of data transmission method based on distributed server according to claim 4, is characterized in that, setting up connection with registration center by described background process program comprises: 当存在多个注册中心时,由所述后台进程程序与注册中心建立连接,并为所述连接配置注册中心的唯一标识。When there are multiple registration centers, the background process program establishes a connection with the registration center, and configures the unique identifier of the registration center for the connection. 6.一种基于分布式服务器的数据传输系统,其特征在于,包括应用实例、服务器以及注册中心;6. A data transmission system based on a distributed server, comprising an application instance, a server and a registration center; 应用实例的注册中心客户端获取待传输的第一数据,为所述第一数据配置对应的应用标识得到待传输数据,将所述待传输数据写入注册中心客户端的本地缓存队列;The registry client of the application instance obtains the first data to be transmitted, configures the corresponding application identifier for the first data to obtain the data to be transmitted, and writes the data to be transmitted into the local cache queue of the registry client; 应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,将扫描到的数据聚合为第一数据包后,将所述第一数据包发送至注册中心;The server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, aggregates the scanned data into a first data packet, and sends the first data packet to the registration center; 注册中心对所述第一数据包进行拆包,按照所述应用标识得到各应用实例传输的所述第一数据。The registration center unpacks the first data packet, and obtains the first data transmitted by each application instance according to the application identifier. 7.根据权利要求6所述的一种基于分布式服务器的数据传输系统,其特征在于,还包括:7. A kind of data transmission system based on distributed server according to claim 6, is characterized in that, also comprises: 注册中心向注册中心客户端发送任务时,根据所述应用实例的应用标识对待发送的第二数据进行配置,将配置后的第二数据聚合为第二数据包并发送至应用实例所在服务器;When the registration center sends a task to the registration center client, configure the second data to be sent according to the application identifier of the application instance, aggregate the configured second data into a second data packet and send it to the server where the application instance is located; 所述服务器通过对应的后台进程程序对所述第二数据包进行拆包,将拆包得到的第二数据按照所述应用标识发送至对应注册中心客户端的本地缓存队列中。The server unpacks the second data packet through a corresponding background process program, and sends the unpacked second data to the local cache queue of the corresponding registration center client according to the application identifier. 8.根据权利要求7所述的一种基于分布式服务器的数据传输系统,其特征在于,将拆包得到的第二数据发送至对应注册中心客户端的本地缓存队列中,之后包括:8. A kind of data transmission system based on distributed server according to claim 7, it is characterized in that, the second data obtained by unpacking is sent to the local cache queue of the corresponding registration center client, and then includes: 注册中心客户端从所述本地缓存队列中获取所述第二数据,并根据所述第二数据从所述注册中心拉取任务数据。The registration center client obtains the second data from the local cache queue, and pulls task data from the registration center according to the second data. 9.根据权利要求6所述的一种基于分布式服务器的数据传输系统,其特征在于,应用实例所在服务器通过对应的后台进程程序定时扫描所述注册中心客户端的本地缓存队列的数据,之前包括:9. A distributed server-based data transmission system according to claim 6, wherein the server where the application instance is located regularly scans the data of the local cache queue of the registration center client through the corresponding background process program, including : 注册中心客户端判断应用实例所在服务器是否存在对应的后台进程程序,若是,则直接由所述后台进程程序与注册中心建立连接,否则,创建后台进程程序,并由所述后台进程程序与注册中心建立连接。The registration center client judges whether there is a corresponding background process program on the server where the application instance is located, and if so, directly establishes a connection between the background process program and the registration center; establish connection. 10.根据权利要求9所述的一种基于分布式服务器的数据传输系统,其特征在于,由所述后台进程程序与注册中心建立连接包括:10. A kind of data transmission system based on distributed server according to claim 9, is characterized in that, setting up connection with registration center by described background process program comprises: 当存在多个注册中心时,由所述后台进程程序与注册中心建立连接,并为所述连接配置注册中心的唯一标识。When there are multiple registration centers, the background process program establishes a connection with the registration center, and configures the unique identifier of the registration center for the connection.
CN202310773143.5A 2023-06-28 2023-06-28 A data transmission method and system based on a distributed server Pending CN116599962A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310773143.5A CN116599962A (en) 2023-06-28 2023-06-28 A data transmission method and system based on a distributed server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310773143.5A CN116599962A (en) 2023-06-28 2023-06-28 A data transmission method and system based on a distributed server

Publications (1)

Publication Number Publication Date
CN116599962A true CN116599962A (en) 2023-08-15

Family

ID=87595880

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310773143.5A Pending CN116599962A (en) 2023-06-28 2023-06-28 A data transmission method and system based on a distributed server

Country Status (1)

Country Link
CN (1) CN116599962A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109257440A (en) * 2018-10-29 2019-01-22 南京南瑞信息通信科技有限公司 A kind of service discovery and client load equalization methods based on service register center
WO2020237797A1 (en) * 2019-05-31 2020-12-03 烽火通信科技股份有限公司 Dynamic configuration management method and system in microservice framework
CN114629953A (en) * 2020-12-14 2022-06-14 电科云(北京)科技有限公司 Service cross-domain calling method and system based on proxy
CN115658244A (en) * 2022-11-10 2023-01-31 中国银行股份有限公司 Distributed batch processing method, system and registration center based on microservice

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109257440A (en) * 2018-10-29 2019-01-22 南京南瑞信息通信科技有限公司 A kind of service discovery and client load equalization methods based on service register center
WO2020237797A1 (en) * 2019-05-31 2020-12-03 烽火通信科技股份有限公司 Dynamic configuration management method and system in microservice framework
CN114629953A (en) * 2020-12-14 2022-06-14 电科云(北京)科技有限公司 Service cross-domain calling method and system based on proxy
CN115658244A (en) * 2022-11-10 2023-01-31 中国银行股份有限公司 Distributed batch processing method, system and registration center based on microservice

Similar Documents

Publication Publication Date Title
CN114124451B (en) A data processing method, system and computer storage medium of an Internet of Things device
JP6741853B2 (en) Subscription and notification services
CN102761864B (en) Data transmission method, system and device
CN105337961A (en) Method for communication with client side and server
CN107517227B (en) Session implementation method and device for distributed consistency system
CN108390950A (en) A kind of information push method, device and equipment
CN114650317B (en) A microservice system and a microservice registration, discovery and keep-alive method
KR101139836B1 (en) Method and system for two-phase mechanism for discovering web services based management service
CN116048538B (en) Service grid deployment method and device for DPU
CN103547339A (en) File uploading method, client side and server side
WO2011044786A1 (en) Unified message scheduling system, service message notification method and system
CN115225706A (en) Data transmission method, device, vehicle and storage medium
US20100306384A1 (en) Multi-directional secure common data transport system
WO2008103196A1 (en) Hanging request system and method for client/server communication
US20070016674A1 (en) Information exchange system, management server, and method for reducing network load used in the same
US20070016673A1 (en) Information exchange system and management server, terminal unit, and method for reducing network load used in the same
CN116599962A (en) A data transmission method and system based on a distributed server
CN104636210B (en) A kind of method and device for realizing Data Exchange
CN110519337B (en) Node state judging and collecting method, state decision device and state collector
US8060568B2 (en) Real time messaging framework hub to intercept and retransmit messages for a messaging facility
WO2025241347A1 (en) Bus communication method and apparatus, and computer device and readable storage medium
CN101510901B (en) Communication method, communication apparatus and system between distributed equipment
CN114363204B (en) Request monitoring method, network device and storage medium
CN115361271B (en) SSH server switching and connecting method, cloud server and storage medium
CN118018250A (en) Communication method and server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination