WO2015184921A1 - 实现心跳通信的方法、注册中心、服务端和客户端 - Google Patents

实现心跳通信的方法、注册中心、服务端和客户端 Download PDF

Info

Publication number
WO2015184921A1
WO2015184921A1 PCT/CN2015/075965 CN2015075965W WO2015184921A1 WO 2015184921 A1 WO2015184921 A1 WO 2015184921A1 CN 2015075965 W CN2015075965 W CN 2015075965W WO 2015184921 A1 WO2015184921 A1 WO 2015184921A1
Authority
WO
WIPO (PCT)
Prior art keywords
heartbeat
server
timeout
registration center
information set
Prior art date
Application number
PCT/CN2015/075965
Other languages
English (en)
French (fr)
Inventor
刘德洪
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015184921A1 publication Critical patent/WO2015184921A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/28Timers or timing mechanisms used in protocols
    • 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/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session

Definitions

  • the present invention relates to the field of distributed communications, and in particular, to a method, a registration center, a server, and a client for implementing heartbeat communication.
  • the process of the server registration service includes: the server sends a registration message to the registration center; the registration center adds the identity of the server in the registration message according to the received registration message and Service Name.
  • the process of heartbeat communication between the registration center and the server and the client includes: the registration center respectively follows the preset first heartbeat period and the second heartbeat period to each server and each The client sends a heartbeat message; if the registration center does not receive the response message of the heartbeat message from the server within the preset first timeout period, the registry deletes the identity of the server and the corresponding service name from the service information set; The registration center receives the response message of the heartbeat message from the client in the second timeout period, and returns each identity identifier corresponding to the service name in the service information set; each client updates according to each returned identity identifier.
  • Corresponding list of services to be updated wherein the service list corresponds to the service name, and includes each identity identifier of the server that provides the network service represented by the corresponding service name.
  • the process for the client to obtain the network service includes: when the client needs to obtain the network service, according to the service list corresponding to the service name of the network service, determine a service list according to the preset selection policy. The identity of the identity, and request the network service from the server represented by the identified identity.
  • the registration center communicates with the server and the client through a Transmission Control Protocol (TCP) link.
  • TCP Transmission Control Protocol
  • the registration center sends the heartbeat message to each server and each client according to a preset period, according to the link between the registration center maintained by the registration center and each server and each client.
  • the registry needs to be with many servers. Communicate with the client, so the registry needs to maintain many links of heartbeat communication, and initiate heartbeat communication according to each link, which increases the load of the registry and reduces the service capability of the registry, that is, the high quality service of the registry. The total number of servers and clients is reduced, which affects the user experience of the distributed service management system.
  • the present invention provides a method for implementing a heartbeat communication, a registration center, a server, and a client, which can reduce the load of the registration center, thereby improving the service capability of the registration center.
  • a method of implementing heartbeat communication comprising:
  • the registration center updates the heartbeat information set according to the received heartbeat messages from each server;
  • the registration center determines whether there is a heartbeat timeout server according to the heartbeat information set according to a preset detection period.
  • the heartbeat message from each server is sent by the each server to the registration center according to a preset first heartbeat period.
  • the heartbeat information set includes an identity identifier and a heartbeat time of each server; the heartbeat time is a time when the heartbeat message is last received;
  • the updated heartbeat information set includes:
  • the heartbeat time corresponding to the extracted identity information is updated to the time when the heartbeat message is received.
  • the server that determines whether a heartbeat timeout exists according to the heartbeat information set includes:
  • the server When it is not found, it is determined that the server does not have a heartbeat timeout; when it is found, the server represented by the identity corresponding to the found heartbeat time is determined as the server of the heartbeat timeout.
  • the method further includes: when determining that the server has a heartbeat timeout, the registry deletes the identity of the server and the corresponding service name of the heartbeat timeout from the service information set.
  • the method further includes:
  • Each client sends a service name corresponding to the service list to be updated to the registration center according to a preset second heartbeat period
  • the registration center When receiving the service name, the registration center returns each identity identifier corresponding to the service name in the service information set;
  • Each client updates the service list to be updated according to each returned identity identifier.
  • the registration center communicates with the server and the client by means of a hypertext transfer protocol HTTP link.
  • a registry that implements heartbeat communications including:
  • a maintenance unit configured to update the heartbeat information set according to the received heartbeat message from each server
  • the timeout unit is configured to determine whether there is a heartbeat timeout server according to the heartbeat information set according to a preset detection period.
  • the heartbeat information set includes an identity of the server and a heartbeat time, where the heartbeat time is the time when the heartbeat message was last received;
  • the maintenance unit updates the heartbeat information set to:
  • the maintenance unit extracts the identity identifier in the heartbeat message, and updates the heartbeat time corresponding to the extracted identity identifier to the time when the heartbeat message is received.
  • the timeout unit determines, according to the heartbeat information set, whether the server that has a heartbeat timeout refers to:
  • the timeout unit searches for a heartbeat time in which the difference between the current time and the current time is greater than or equal to a preset timeout threshold in the heartbeat information set; when it is not found, it determines that the server does not have a heartbeat timeout; when found, it will The server that the identified heartbeat time corresponds to is identified by the server. The server that is designated as the heartbeat timeout.
  • the maintenance unit is further configured to: when determining that the server has a heartbeat timeout, delete the identity of the server and the corresponding service name of the heartbeat timeout from the service information set.
  • the registration center further includes:
  • the response unit is configured to, when receiving the service name from the client, return each identity identifier corresponding to the service name in the service information set.
  • the registration center further includes:
  • the communication unit is configured to communicate with the server and the client via a hypertext transfer protocol HTTP link.
  • a server that implements heartbeat communication including:
  • the heartbeat initiating unit is configured to send a heartbeat message to the registration center through the communication unit according to a preset first heartbeat period.
  • the technical solution of the embodiment of the present invention includes: the registration center updates the heartbeat information set according to the received heartbeat message from each server; and the registration center determines whether the heartbeat exists according to the heartbeat information set according to the preset detection period. Timeout server.
  • the server initiates heartbeat communication, avoids the link between the registration center maintaining heartbeat communication with the server end and the heartbeat communication between the originating server and the server end, thereby reducing the registration center's
  • the load improves the service capabilities of the registry, thereby improving the user experience of the distributed service management system.
  • FIG. 1 is a flowchart of a method for implementing heartbeat communication according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of a registration center, a server, and a client for implementing heartbeat communication according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a method for implementing heartbeat communication according to an embodiment of the present invention. As shown in FIG. 1, the method includes:
  • Step 101 The registration center updates the heartbeat information set according to the received heartbeat message from each server.
  • the heartbeat message from each server is sent by the each server to the registration center according to a preset first heartbeat period.
  • the first heartbeat period may be a minute time, such as 1 minute, 10 minutes, or 30 minutes.
  • the heartbeat information set in step 101 includes an identity identifier and a heartbeat time of each server, where the heartbeat time is the time when the heartbeat message was last received.
  • the updated heartbeat information set in step 101 includes:
  • Extracting the identity identifier in the heartbeat message ; updating the heartbeat time corresponding to the extracted identity identifier in the heartbeat information set to the time when the heartbeat message is received.
  • Step 102 The registration center determines, according to the heartbeat information set, whether the server has a heartbeat timeout according to a preset detection period.
  • the detection period may be a minute time, such as 30 minutes, 45 minutes, or 60 minutes.
  • the server that determines whether a heartbeat timeout exists according to the heartbeat information set includes:
  • the heartbeat information set searching for a heartbeat time that is greater than or equal to a preset timeout threshold by a difference between the current time and the current time;
  • the server When it is not found, it is determined that the server does not have a heartbeat timeout; when it is found, the server represented by the identity corresponding to the found heartbeat time is determined as the server of the heartbeat timeout.
  • the timeout threshold may be a minute time, such as 20 minutes, 30 minutes, or 45 minutes.
  • the method further includes: when determining that the server has a heartbeat timeout, the registry deletes the identity of the server that is out of timeout and the corresponding service name from the service information set. When it does not exist, no processing is performed.
  • the method further includes: each client sending a service name corresponding to the service list to be updated to the registration center according to the preset second heartbeat period, to request to update the service list to be updated; the registration center receives When the service name is returned, each identity identifier corresponding to the service name is returned in the service information set; each client updates the service list to be updated according to each returned identity identifier.
  • the second heartbeat period may be a minute time, such as 1 minute, 10 minutes, or 30 minutes.
  • the heartbeat communication between the registration center and the client in the embodiment of the present invention is performed in a manner that the client sends the service name corresponding to the service list to be updated to the registration center, thereby avoiding the maintenance of the registration center.
  • Linking with the client's heartbeat communication and initiating heartbeat communication with the client which reduces the load on the registry, improves the service capability of the registry, and further improves the user experience of the distributed service management system.
  • the registration center communicates with the server and the client by using a Hypertext Transfer Protocol (HTTP) link.
  • HTTP Hypertext Transfer Protocol
  • the registration center uses the HTTP link instead of the existing TCP link to communicate with the server and the client.
  • each TCP link needs to be used.
  • a port that occupies a TCP protocol, and multiple HTTP links can occupy only one port of the TCP protocol. Therefore, the present invention communicates by means of HTTP linking, which reduces the number of ports occupied by the registration center and improves the service capability of the registry.
  • the heartbeat communication between the registration center and the server and the client is performed by using a short HTTP link.
  • connection duration refers to the time period during which the link is established to delete the connection.
  • the HTTP short link used in the embodiment of the present invention can be released faster because the connection duration is short, so that the embodiment of the present invention performs the HTTP short link.
  • Heartbeat communication reduces the number of ports occupied by the registry and further increases the service capabilities of the registry.
  • FIG. 2 is a schematic structural diagram of a registration center, a server, and a client for implementing heartbeat communication according to an embodiment of the present invention, as shown in FIG. 2,
  • the registration center includes a maintenance unit and a timeout unit, wherein
  • a maintenance unit configured to update the heartbeat information set according to the received heartbeat message of the respective server
  • the timeout unit is configured to determine whether there is a heartbeat timeout server according to the heartbeat information set according to a preset detection period.
  • the server includes:
  • a heartbeat initiating unit configured to pass the communication list according to a preset first heartbeat period
  • the element sends a heartbeat message to the registration center.
  • the server includes one or more.
  • the client may include a request unit and an update unit, where the client includes one or more. among them,
  • a requesting unit configured to send, according to a preset second heartbeat period, a service name corresponding to the service list to be updated to the registration center, to request to update the service list to be updated;
  • an updating unit configured to update the service list to be updated according to each identity identifier returned by the registration center.
  • the heartbeat information set in the registry includes an identity of the server and a heartbeat time, where the heartbeat time is the time when the heartbeat message was last received.
  • the updating the heartbeat information set by the maintenance unit in the registration center refers to:
  • the maintenance unit extracts the identity identifier in the heartbeat message; extracts the identity identifier in the heartbeat message; and updates the heartbeat time corresponding to the extracted identity identifier to the time when the heartbeat message is received.
  • the timeout unit in the registration center determines, according to the heartbeat information set, whether the server that has a heartbeat timeout refers to:
  • the timeout unit searches for a heartbeat time in which the difference between the current time and the current time is greater than or equal to a preset timeout threshold in the heartbeat information set; when it is not found, it determines that the server does not have a heartbeat timeout; when found, it will The server represented by the identified identity corresponding to the heartbeat time is determined to be the server of the heartbeat timeout.
  • the maintenance unit in the registration center is further configured to: when determining that the server has a heartbeat timeout, delete the identity of the server of the heartbeat timeout and the corresponding service name from the service information set; The identity of the server of the heartbeat timeout comes from the timeout unit in the registry.
  • the registration center may further include:
  • the response unit is configured to, when receiving the service name from the client, return each identity identifier corresponding to the service name in the service information set.
  • the registration center may further include:
  • the communication unit is configured to communicate with the server and the client via a hypertext transfer protocol HTTP link.
  • the registration center communicates with the server and the client by means of a hypertext transfer protocol HTTP link.
  • the solution of the embodiment of the present invention implements the heartbeat communication initiated by the server, avoids the link between the registration center and the heartbeat communication between the server and the heartbeat communication between the server and the server, which reduces the The load on the registry improves the service capabilities of the registry, thereby improving the user experience of the distributed service management system.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

一种实现心跳通信的方法、注册中心、服务端和客户端,方法包括:注册中心根据接收到的来自各服务端的心跳消息,更新心跳信息集(101);注册中心按照预先设置的检测周期,根据心跳信息集确定是否存在心跳超时的服务端(102)。本发明实施例的技术方案减小了注册中心的负荷,提高了注册中心的服务能力,从而改善了分布式服务管理系统的用户体验。

Description

实现心跳通信的方法、注册中心、服务端和客户端 技术领域
本发明涉及分布式通信领域,尤其涉及一种实现心跳通信的方法、注册中心、服务端和客户端。
背景技术
随着淘宝、微博等大型网络服务的广泛应用,用于实现这些大型网络服务的分布式服务管理系统成为互联网的研究热点。
在现有分布式服务管理系统中,服务端注册服务的流程包括:服务端向注册中心发送注册消息;注册中心根据接收到的注册消息,在服务信息集中增加注册消息中的服务端的身份标识和服务名。在现有分布式服务管理系统中,注册中心与服务端和客户端之间的心跳通信的流程包括:注册中心按照预先设置的第一心跳周期和第二心跳周期,分别向各服务端和各客户端发送心跳消息;如果注册中心在预先设置的第一超时时间段内没有接收到来自服务端的心跳消息的应答消息,注册中心从服务信息集中删除该服务端的身份标识和对应的服务名;如果注册中心在第二超时时间段内接收到来自客户端的心跳消息的应答消息,返回服务信息集中与该应答消息中的服务名对应的各身份标识;各客户端根据返回的各身份标识,分别更新对应的待更新的服务列表;其中,服务列表对应于服务名,包括提供对应的服务名代表的网络服务的服务端的各身份标识。在现有分布式服务管理系统中,客户端获取网络服务的流程包括:当客户端需要获得网络服务时,根据该网络服务的服务名对应的服务列表,按照预先设置的选择策略确定一个服务列表的身份标识,并向确定出的身份标识代表的服务端请求网络服务。在上述3个现有流程中,注册中心与所述服务端和客户端之间均通过传输控制协(TCP,Transmission Control Protocol)链接的方式进行通信。
在现有心跳通信的流程中,注册中心按照预先设置的周期,分别向各服务端和各客户端发送心跳消息是根据注册中心维护的注册中心与各服务端和各客户端之间的链接进行的,由于通常情况下注册中心需要与很多个服务端 和客户端进行通信,因此注册中心需要维护很多条心跳通信的链接,并根据各条链接发起心跳通信,这样增加了注册中心的负荷,降低了注册中心的服务能力,即使得注册中心高质量服务服务端和客户端的总数量减少,从而影响了分布式服务管理系统的用户体验。
发明内容
为了解决上述技术问题,本发明提供了一种实现心跳通信方法、注册中心、服务端和客户端,能够减小注册中心的负荷,从而提高注册中心的服务能力。
为了达到上述目的,采用如下技术方案:
一种实现心跳通信的方法,包括:
注册中心根据接收到的来自各服务端的心跳消息,更新心跳信息集;
注册中心按照预先设置的检测周期,根据心跳信息集确定是否存在心跳超时的服务端。
可选地,所述来自各服务端的心跳消息由所述各服务端按照预先设置的第一心跳周期,分别向注册中心发送。
可选地,所述心跳信息集包括所述各服务端的身份标识和心跳时间;所述心跳时间为最近一次接收到所述心跳消息的时间;
所述更新心跳信息集包括:
提取所述心跳消息中的身份标识;
将所述心跳信息集中与提取出的身份标识对应的心跳时间更新为接收到所述心跳消息的时间。
可选地,所述根据心跳信息集确定是否存在心跳超时的服务端包括:
在所述心跳信息集中查找与当前时间的差值大于或等于预先设置的超时时间阈值的心跳时间;
当查找不到时确定不存在心跳超时的服务端;当查找到时,将所查找到的心跳时间对应的身份标识代表的服务端确定为心跳超时的服务端。
可选地,所述的方法还包括:当确定存在心跳超时的服务端时,所述注册中心从服务信息集中删除所述心跳超时的服务端的身份标识和对应的服务名。
可选地,所述的方法还包括:
各客户端按照预先设置的第二心跳周期,分别向所述注册中心发送待更新的服务列表对应的服务名;
注册中心接收到服务名时,返回所述服务信息集中与所述服务名对应的各身份标识;
各客户端根据返回的各身份标识,分别更新所述待更新的服务列表。
可选地,所述注册中心与所述服务端和客户端之间均通过超文本传送协议HTTP链接的方式进行通信。
一种实现心跳通信的注册中心,包括:
维护单元,设置成根据接收到的来自各服务端的心跳消息,更新心跳信息集;
超时单元,设置成按照预先设置的检测周期,根据所述心跳信息集确定是否存在心跳超时的服务端。
可选地,所述心跳信息集包括所述服务端的身份标识和心跳时间,所述心跳时间为最近一次接收到所述心跳消息的时间;
所述维护单元更新心跳信息集是指:
所述维护单元提取所述心跳消息中的身份标识;将所述心跳信息集中与提取出的身份标识对应的心跳时间更新为接收到所述心跳消息的时间。
可选地,所述超时单元根据心跳信息集确定是否存在心跳超时的服务端是指:
所述超时单元在所述心跳信息集中查找与当前时间的差值大于或等于预先设置的超时时间阈值的心跳时间;当查找不到时确定不存在心跳超时的服务端;当查找到时,将所查找到的心跳时间对应的身份标识代表的服务端确 定为心跳超时的服务端。
可选地,所述维护单元还设置成:当确定存在心跳超时的服务端时,从服务信息集中删除所述心跳超时的服务端的身份标识和对应的服务名。
可选地,所述的注册中心还包括:
响应单元,设置成接收到来自客户端的服务名时,返回所述服务信息集中与所述服务名对应的各身份标识。
可选地,所述的注册中心还包括:
通信单元,设置成与所述服务端、客户端之间通过超文本传送协议HTTP链接的方式进行通信。
一种实现心跳通信的服务端,包括:
通信单元;
心跳发起单元,设置成按照预先设置的第一心跳周期,通过所述通信单元向注册中心发送心跳消息。
与相关技术相比,本发明实施例的技术方案包括:注册中心根据接收到的来自各服务端的心跳消息,更新心跳信息集;注册中心按照预先设置的检测周期,根据心跳信息集确定是否存在心跳超时的服务端。通过本发明实施例的技术方案,实现了服务端发起心跳通信,避免了注册中心维护与服务端之间的心跳通信的链接和发起与服务端之间的心跳通信,这样减小了注册中心的负荷,提高了注册中心的服务能力,从而改善了分布式服务管理系统的用户体验。
本发明实施例的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明实施例而了解。本发明实施例的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。
附图概述
下面对本发明实施例中的附图进行说明,实施例中的附图是用于对本发明实施例的进一步理解,与说明书一起用于解释本发明实施例,并不构成对本发明实施例保护范围的限制。
图1为本发明实施例实现心跳通信的方法的流程图;
图2为本发明实施例实现心跳通信的注册中心、服务端和客户端的组成结构示意图。
本发明的较佳实施方式
为了便于本领域技术人员的理解,下面结合附图对本发明实施例作进一步的描述,并不能用来限制本发明实施例的保护范围。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的各种方式可以相互组合。
在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行。并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
图1为本发明实施例实现心跳通信的方法的流程图,如图1所示,包括:
步骤101:注册中心根据接收到的来自各服务端的心跳消息,更新心跳信息集。
可选地,所述来自各服务端的心跳消息由所述各服务端按照预先设置的第一心跳周期,分别向注册中心发送。
其中,第一心跳周期可以为分钟级时间,例如1分钟、10分钟或30分钟等。
可选地,步骤101中的心跳信息集包括各服务端的身份标识和心跳时间,其中,心跳时间为最近一次接收到心跳消息的时间。相应地,步骤101中的更新心跳信息集包括:
提取所述心跳消息中的身份标识;将所述心跳信息集中与提取出的身份标识对应的心跳时间更新为接收到所述心跳消息的时间。
其中,如何从消息中提取信息的具体实现,属于本领域技术人员的惯用 技术手段,不用于限定本发明的保护范围,此处不再赘述。
步骤102:注册中心按照预先设置的检测周期,根据心跳信息集确定是否存在心跳超时的服务端。
其中,检测周期可以为分钟级时间,例如30分钟、45分钟或60分钟等。
可选地,所述根据心跳信息集确定是否存在心跳超时的服务端包括:
在所述心跳信息集中,查找与当前时间的差值大于或等于预先设置的超时时间阈值的心跳时间;
当查找不到时确定不存在心跳超时的服务端;当查找到时,将所查找到的心跳时间对应的身份标识代表的服务端确定为心跳超时的服务端。
其中,超时时间阈值可以为分钟级时间,例如20分钟,30分钟或45分钟等。
可选地,所述方法还包括:当确定存在心跳超时的服务端时,所述注册中心从服务信息集中删除所述心跳超时的服务端的身份标识和对应的服务名。当不存在时则不进行处理。
可选地,所述方法还包括:各客户端按照预先设置的第二心跳周期,分别向注册中心发送待更新的服务列表对应的服务名,以请求更新待更新的服务列表;注册中心接收到服务名时,返回服务信息集中与所述服务名对应的各身份标识;各客户端根据返回的各身份标识,分别更新所述待更新的服务列表。其中,第二心跳周期可以为分钟级时间,例如1分钟、10分钟或30分钟等。
与相关技术中的心跳通信相比,本发明实施例里注册中心与客户端之间的心跳通信以客户端向注册中心发送待更新的服务列表对应的服务名的方式进行,避免了注册中心维护与客户端的心跳通信的链接和发起与客户端之间的心跳通信,这样减小了注册中心的负荷,提高了注册中心的服务能力,进一步改善了分布式服务管理系统的用户体验。
可选地,所述注册中心与所述服务端和所述客户端之间均通过超文本传送协议(HTTP,Hypertext transfer protocol)链接的方式进行通信。
其中,如何通过HTTP链接的方式进行通信的具体实现,属于本领域技术人员的惯用技术手段,不用于限定本发明的保护范围,此处不再赘述。
与相关技术相比,本发明实施例里注册中心与服务端和客户端之间均采用HTTP链接的方式代替现有TCP链接的方式进行通信,由于对于注册中心而言,每个TCP链接都需要占用一个TCP协议的端口,而多个HTTP链接可以只占用一个TCP协议的端口,因此本发明以HTTP链接的方式进行通信减少了注册中心同时占用端口的数量,提高了注册中心的服务能力。
可选地,所述注册中心与服务端、客户端之间进行的心跳通信均是通过HTTP短链接的方式进行的。
其中,如何通过HTTP短链接的方式进行通信的具体实现,属于本领域技术人员的惯用技术手段,不用于限定本发明的保护范围,此处不再赘述。
需要说明的是,现有心跳通信是通过TCP长链接的方式进行的。短链接指的是链接持续的时间比较短,而长链接指的是连接持续的时间比较长。这里,连接持续时间指的是建立链接到删除连接的时间段。
与相关技术中的心跳通信相比,本发明实施例采用的HTTP短链接由于连接持续时间较短,因此其占用的TCP端口资源可以较快释放,这样本发明实施例以HTTP短链接的方式进行心跳通信减少了注册中心同时占用端口的数量,从而进一步提高了注册中心的服务能力。
图2为本发明实施例实现心跳通信的注册中心、服务端和客户端的组成结构示意图,如图2所示,
注册中心包括维护单元和超时单元,其中,
维护单元,设置成根据接收到的来各自服务端的心跳消息,更新心跳信息集;
超时单元,设置成按照预先设置的检测周期,根据所述心跳信息集确定是否存在心跳超时的服务端。
其中,所述服务端包括:
通信单元;
心跳发起单元,设置成按照预先设置的第一心跳周期,通过所述通信单 元向所述注册中心发送心跳消息。这里,服务端包括一个或一个以上。
客户端可以包括请求单元和更新单元,这里,客户端包括一个或一个以上。其中,
请求单元,设置成按照预先设置的第二心跳周期,向所述注册中心发送待更新的服务列表对应的服务名,以请求更新待更新的服务列表;
更新单元,用于根据所述注册中心返回的各身份标识,更新所述待更新的服务列表。
可选地,所述注册中心中的心跳信息集包括服务端的身份标识和心跳时间,其中,心跳时间为最近一次接收到心跳消息的时间。
可选地,所述注册中心中的所述维护单元更新心跳信息集是指:
所述维护单元提取心跳消息中的身份标识;提取心跳消息中的身份标识;将心跳信息集中与提取出的身份标识对应的心跳时间更新为接收到心跳消息的时间。
可选地,所述注册中心中的所述超时单元根据心跳信息集确定是否存在心跳超时的服务端是指:
所述超时单元在所述心跳信息集中查找与当前时间的差值大于或等于预先设置的超时时间阈值的心跳时间;当查找不到时确定不存在心跳超时的服务端;当查找到时,将所查找到的心跳时间对应的身份标识代表的服务端确定为心跳超时的服务端。
可选地,所述注册中心中的所述维护单元还设置成:当确定存在心跳超时的服务端时,从服务信息集中删除所述心跳超时的服务端的身份标识和对应的服务名;其中,心跳超时的服务端的身份标识来自所述注册中心中的所述超时单元。
可选地,所述注册中心还可以包括:
响应单元,设置成接收到来自客户端的服务名时,返回服务信息集中与所述服务名对应的各身份标识。
可选地,所述注册中心还可以包括:
通信单元,设置成与所述服务端、客户端之间通过超文本传送协议HTTP链接的方式进行通信。
即:所述注册中心与所述服务端和所述客户端之间均通过超文本传送协议HTTP链接的方式进行通信。
工业实用性
与相关技术相比,本发明实施例的方案实现了服务端发起心跳通信,避免了注册中心维护与服务端之间的心跳通信的链接和发起与服务端之间的心跳通信,这样减小了注册中心的负荷,提高了注册中心的服务能力,从而改善了分布式服务管理系统的用户体验。

Claims (14)

  1. 一种实现心跳通信的方法,包括:
    注册中心根据接收到的来自各服务端的心跳消息,更新心跳信息集;
    注册中心按照预先设置的检测周期,根据心跳信息集确定是否存在心跳超时的服务端。
  2. 根据权利要求1所述的方法,其中:所述来自各服务端的心跳消息由所述各服务端按照预先设置的第一心跳周期,分别向注册中心发送。
  3. 根据权利要求1所述的方法,其中:
    所述心跳信息集包括所述各服务端的身份标识和心跳时间;所述心跳时间为最近一次接收到所述心跳消息的时间;
    所述更新心跳信息集包括:
    提取所述心跳消息中的身份标识;
    将所述心跳信息集中与提取出的身份标识对应的心跳时间更新为接收到所述心跳消息的时间。
  4. 根据权利要求3所述的方法,其中,所述根据心跳信息集确定是否存在心跳超时的服务端包括:
    在所述心跳信息集中查找与当前时间的差值大于或等于预先设置的超时时间阈值的心跳时间;
    当查找不到时确定不存在心跳超时的服务端;当查找到时,将所查找到的心跳时间对应的身份标识代表的服务端确定为心跳超时的服务端。
  5. 根据权利要求1所述的方法,还包括:当确定存在心跳超时的服务端时,所述注册中心从服务信息集中删除所述心跳超时的服务端的身份标识和对应的服务名。
  6. 根据权利要求1所述的方法,还包括:
    各客户端按照预先设置的第二心跳周期,分别向所述注册中心发送待更新的服务列表对应的服务名;
    注册中心接收到服务名时,返回所述服务信息集中与所述服务名对应的各身份标识;
    各客户端根据返回的各身份标识,分别更新所述待更新的服务列表。
  7. 根据权利要求1~6任一项所述的方法,其中,所述注册中心与所述服务端和客户端之间均通过超文本传送协议HTTP链接的方式进行通信。
  8. 一种实现心跳通信的注册中心,包括:
    维护单元,设置成根据接收到的来自各服务端的心跳消息,更新心跳信息集;
    超时单元,设置成按照预先设置的检测周期,根据所述心跳信息集确定是否存在心跳超时的服务端。
  9. 根据权利要求8所述的注册中心,其中,所述心跳信息集包括所述服务端的身份标识和心跳时间,所述心跳时间为最近一次接收到所述心跳消息的时间;
    所述维护单元更新心跳信息集是指:
    所述维护单元提取所述心跳消息中的身份标识;将所述心跳信息集中与提取出的身份标识对应的心跳时间更新为接收到所述心跳消息的时间。
  10. 根据权利要求8所述的注册中心,其中,所述超时单元根据心跳信息集确定是否存在心跳超时的服务端是指:
    所述超时单元在所述心跳信息集中查找与当前时间的差值大于或等于预先设置的超时时间阈值的心跳时间;当查找不到时确定不存在心跳超时的服务端;当查找到时,将所查找到的心跳时间对应的身份标识代表的服务端确定为心跳超时的服务端。
  11. 根据权利要求8所述的注册中心,其中,所述维护单元还设置成:当确定存在心跳超时的服务端时,从服务信息集中删除所述心跳超时的服务端的身份标识和对应的服务名。
  12. 根据权利要求8所述的注册中心,还包括:
    响应单元,设置成接收到来自客户端的服务名时,返回所述服务信息集 中与所述服务名对应的各身份标识。
  13. 根据权利要求8所述的注册中心,还包括:
    通信单元,设置成与所述服务端、客户端之间通过超文本传送协议HTTP链接的方式进行通信。
  14. 一种实现心跳通信的服务端,包括:
    通信单元;
    心跳发起单元,设置成按照预先设置的第一心跳周期,通过所述通信单元向注册中心发送心跳消息。
PCT/CN2015/075965 2014-11-28 2015-04-07 实现心跳通信的方法、注册中心、服务端和客户端 WO2015184921A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410709282.2A CN105704107A (zh) 2014-11-28 2014-11-28 实现心跳通信的方法、注册中心、服务端和客户端
CN201410709282.2 2014-11-28

Publications (1)

Publication Number Publication Date
WO2015184921A1 true WO2015184921A1 (zh) 2015-12-10

Family

ID=54766141

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/075965 WO2015184921A1 (zh) 2014-11-28 2015-04-07 实现心跳通信的方法、注册中心、服务端和客户端

Country Status (2)

Country Link
CN (1) CN105704107A (zh)
WO (1) WO2015184921A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10656985B2 (en) 2018-01-26 2020-05-19 International Business Machines Corporation Heartbeat failure detection
CN112311869A (zh) * 2020-10-28 2021-02-02 苏州万店掌网络科技有限公司 多类型微服务注册中心管理系统及方法
CN113422780A (zh) * 2021-07-02 2021-09-21 的卢技术有限公司 基于tcp协议长连接的心跳间隔调整方法、装置

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106571973A (zh) * 2016-09-28 2017-04-19 杭州鸿雁智能科技有限公司 心跳包超时管理方法及系统
CN109218421B (zh) * 2018-09-11 2020-12-15 南京臻融软件科技有限公司 一种dds发现协议扩展方法及系统
CN109725999A (zh) * 2018-12-26 2019-05-07 亚信科技(中国)有限公司 一种调度进程的管理方法和装置
CN113726595B (zh) * 2021-08-06 2024-03-19 视联动力信息技术股份有限公司 超时客户端的检测方法、装置、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070250608A1 (en) * 2001-11-08 2007-10-25 Watt Charles T System and method for dynamic server allocation and provisioning
US20080282134A1 (en) * 2007-05-11 2008-11-13 Stuart Owen Goldman Methods and Apparatus for Detection of Performance Conditions in Processing System
CN102984029A (zh) * 2012-11-30 2013-03-20 福建星网锐捷网络有限公司 应用于分布式系统的心跳检测装置和方法、网络设备
CN103957231A (zh) * 2014-03-18 2014-07-30 成都盛思睿信息技术有限公司 一种云计算平台下的虚拟机分布式任务调度方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070250608A1 (en) * 2001-11-08 2007-10-25 Watt Charles T System and method for dynamic server allocation and provisioning
US20080282134A1 (en) * 2007-05-11 2008-11-13 Stuart Owen Goldman Methods and Apparatus for Detection of Performance Conditions in Processing System
CN102984029A (zh) * 2012-11-30 2013-03-20 福建星网锐捷网络有限公司 应用于分布式系统的心跳检测装置和方法、网络设备
CN103957231A (zh) * 2014-03-18 2014-07-30 成都盛思睿信息技术有限公司 一种云计算平台下的虚拟机分布式任务调度方法

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10656985B2 (en) 2018-01-26 2020-05-19 International Business Machines Corporation Heartbeat failure detection
CN112311869A (zh) * 2020-10-28 2021-02-02 苏州万店掌网络科技有限公司 多类型微服务注册中心管理系统及方法
CN112311869B (zh) * 2020-10-28 2022-04-05 苏州万店掌网络科技有限公司 多类型微服务注册中心管理系统及方法
CN113422780A (zh) * 2021-07-02 2021-09-21 的卢技术有限公司 基于tcp协议长连接的心跳间隔调整方法、装置

Also Published As

Publication number Publication date
CN105704107A (zh) 2016-06-22

Similar Documents

Publication Publication Date Title
WO2015184921A1 (zh) 实现心跳通信的方法、注册中心、服务端和客户端
US11451510B2 (en) Method and apparatus for processing service request
US8392717B2 (en) Authentication method, system, server, and client
US10637794B2 (en) Resource subscription method, resource subscription apparatus, and resource subscription system
US9800593B2 (en) Controller for software defined networking and method of detecting attacker
WO2016197727A1 (zh) 一种数据传输方法及装置
CN107529229B (zh) 数据传输的方法,装置及系统
WO2019120160A1 (zh) 一种数据存储的方法、装置和分布式存储系统
US20180295151A1 (en) Methods for mitigating network attacks through client partitioning and devices thereof
US20080208959A1 (en) Hanging request system and method for client/server communication
CN108886533B (zh) 加速与主机服务器的连接
EP2981043B1 (en) Method for managing portal device, and portal device and system
US10268532B2 (en) Application message processing system, method, and application device
US20140201376A1 (en) Method and system for the handling of redundant long poll
JP6476319B2 (ja) 移動無線通信ネットワークに移動端末の接続を確立するための方法、及び無線アクセスネットワーク構成要素
WO2013159492A1 (zh) 信息上报与下载的方法及系统
EP2890086B1 (en) Method and farm load balancing device for establishing a bi-directional server to server communication and computer program thereof
US10834065B1 (en) Methods for SSL protected NTLM re-authentication and devices thereof
US20160381147A1 (en) Information transmission method and apparatus
KR100597405B1 (ko) 소켓 어플리케이션 프로그램을 이용한 데이터 중계 시스템및 데이터 중계 방법
US20230011348A1 (en) System And Method For Subscriber Awareness In A 5G Network
US10382274B2 (en) System and method for wide area zero-configuration network auto configuration
CN107968825B (zh) 一种报文转发控制方法及装置
CN102624759A (zh) 一种实现会话中数据迁移的方法和节点
US11228609B1 (en) Methods for managing HTTP requests using extended SYN cookie and devices thereof

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15803548

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15803548

Country of ref document: EP

Kind code of ref document: A1