CN109602413B - Heartbeat detection method, heartbeat detection device, storage medium and server - Google Patents

Heartbeat detection method, heartbeat detection device, storage medium and server Download PDF

Info

Publication number
CN109602413B
CN109602413B CN201811489458.2A CN201811489458A CN109602413B CN 109602413 B CN109602413 B CN 109602413B CN 201811489458 A CN201811489458 A CN 201811489458A CN 109602413 B CN109602413 B CN 109602413B
Authority
CN
China
Prior art keywords
client
target storage
heartbeat detection
connection
server
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.)
Active
Application number
CN201811489458.2A
Other languages
Chinese (zh)
Other versions
CN109602413A (en
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.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp 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 Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201811489458.2A priority Critical patent/CN109602413B/en
Publication of CN109602413A publication Critical patent/CN109602413A/en
Application granted granted Critical
Publication of CN109602413B publication Critical patent/CN109602413B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A61MEDICAL OR VETERINARY SCIENCE; HYGIENE
    • A61BDIAGNOSIS; SURGERY; IDENTIFICATION
    • A61B5/00Measuring for diagnostic purposes; Identification of persons
    • A61B5/02Detecting, measuring or recording pulse, heart rate, blood pressure or blood flow; Combined pulse/heart-rate/blood pressure determination; Evaluating a cardiovascular condition not otherwise provided for, e.g. using combinations of techniques provided for in this group with electrocardiography or electroauscultation; Heart catheters for measuring blood pressure
    • A61B5/024Detecting, measuring or recording pulse rate or heart rate

Abstract

The embodiment of the application discloses a heartbeat detection method, a heartbeat detection device, a storage medium and a server. The method comprises the following steps: acquiring a request identification ID corresponding to a client and connection time for establishing connection between the client and the server; determining a target storage ring corresponding to the client according to the request identifier ID; according to the connection time, determining a target storage area corresponding to the client from a storage area contained in the target storage ring; the target storage area is used for storing key information of the client; and when the heartbeat detection event is triggered, carrying out heartbeat detection on the clients corresponding to the storage areas in parallel. By the technical scheme provided by the embodiment of the application, the fast and timely heartbeat detection can be carried out on each client connected with the server, the connection state of each client can be accurately determined, and the resource occupation of the client with abnormal connection state to the server can be reduced.

Description

Heartbeat detection method, heartbeat detection device, storage medium and server
Technical Field
The embodiment of the application relates to the technical field of communication, in particular to a heartbeat detection method, a heartbeat detection device, a heartbeat detection storage medium and a heartbeat detection server.
Background
The heartbeat detection mechanism is widely applied to various modern electronic devices, and plays an indispensable role in judging the running state of the client and the connection state between the client and the server.
Because the heartbeat information needs to be sent periodically, the efficiency of heartbeat detection is very important, and especially, the abnormal state of the client can be found in time so as to reduce the occupation of the invalid client to the bandwidth and the resources. Therefore, an efficient heartbeat detection mechanism becomes crucial.
Disclosure of Invention
The embodiment of the application provides a heartbeat detection method, a heartbeat detection device, a storage medium and a server, which can optimize the existing heartbeat detection mechanism.
In a first aspect, an embodiment of the present application provides a heartbeat detection method, including:
acquiring a request identification ID corresponding to a client and connection time for establishing connection between the client and the server;
determining a target storage ring corresponding to the client according to the request identifier ID;
according to the connection time, determining a target storage area corresponding to the client from a storage area contained in the target storage ring; the target storage area is used for storing key information of the client;
and when the heartbeat detection event is triggered, carrying out heartbeat detection on the clients corresponding to the storage areas in parallel.
In a second aspect, an embodiment of the present application provides a heartbeat detection device, including:
the client information acquisition module is used for acquiring a request identification ID corresponding to a client and connection time for establishing connection between the client and the server;
a target storage ring determining module, configured to determine a target storage ring corresponding to the client according to the request identifier ID;
a target storage area determining module, configured to determine, according to the connection time, a target storage area corresponding to the client from a storage area included in the target storage ring; the target storage area is used for storing key information of the client;
and the heartbeat detection module is used for carrying out heartbeat detection on the clients corresponding to the storage areas in parallel when the heartbeat detection event is triggered.
In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the heartbeat detection method according to the first aspect of the embodiment of the present application.
In a fourth aspect, an embodiment of the present application provides a server, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement the heartbeat detection method according to the first aspect of the embodiment of the present application.
According to the heartbeat detection scheme provided by the embodiment of the application, the request identification ID corresponding to the client and the connection time of the client and the server are obtained, the target storage ring corresponding to the client is determined according to the request identification ID, then the target storage area corresponding to the client is determined from the storage area contained in the target storage ring according to the connection time, wherein the target storage area is used for storing the key information of the client, and when a heartbeat detection event is triggered, the heartbeat detection is performed on the client corresponding to each storage area in parallel. By adopting the technical scheme, the heartbeat detection can be rapidly and timely carried out on each client connected with the server, the connection state of each client can be accurately determined, and the resource occupation of the client with abnormal connection state to the server can be favorably reduced.
Drawings
Fig. 1 is a schematic flowchart of a heartbeat detection method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of another heartbeat detection method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a heartbeat detecting device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed Description
The technical scheme of the application is further explained by the specific implementation mode in combination with the attached drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting of the application. It should be further noted that, for the convenience of description, only some of the structures related to the present application are shown in the drawings, not all of the structures.
Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the steps as a sequential process, many of the steps can be performed in parallel, concurrently or simultaneously. In addition, the order of the steps may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Common heartbeat detection mechanisms include both passive and polling modes. The passive mode is that the detected party regularly sends a self-defined heartbeat IP (Internet Protocol) data packet to enable the detected party to sense whether the detected party still operates normally, and if the detected party does not receive the heartbeat IP data packet sent by the detected party within a certain time interval, the detected party is considered to be down. The polling mode is that the detecting party regularly sends a status inquiry IP data packet to the detected party, the detected party generally returns the status information thereof, and if the detecting party does not receive the returned information sent by the detecting method or returns error and failure information within a certain time interval, the detected party is considered to be down.
In the heartbeat detection scheme based on the polling mode, all the related information of the detected party establishing a connection relationship with the detected party is usually placed in a list, and when the heartbeat detection is required, a timer is started for performing timed polling detection. However, when the number of detected parties establishing a connection with a detecting party is large, that is, when the list is large, the polling time is easily too long, and the heartbeat detection cannot be performed on the detected party at the end of the list in time. Based on this, the improvement scheme to the scheme is proposed: according to the number of detected parties establishing connection with the detecting parties, relevant information of the detected parties is placed in a plurality of lists, each list is independently provided with a timer, and when heartbeat detection is needed, each list independently starts the corresponding timer to respectively perform polling detection on the corresponding detected parties in the list. According to the improved scheme, the problem that the number of detected parties connected with the detecting parties is large can be effectively solved, however, when the detected parties are placed in the same list, if the time interval between the two detected parties and the detecting parties is large, the problem that heartbeat detection aiming at individual detected parties is not timely easily occurs. Based on the above considerations, the following heartbeat detection scheme is now provided.
Fig. 1 is a schematic flowchart of a heartbeat detection method provided in an embodiment of the present application, where the method may be executed by a heartbeat detection device, where the device may be implemented by software and/or hardware, and may be generally integrated in a server. As shown in fig. 1, the method includes:
step 101, acquiring a request identification ID corresponding to a client and connection time for establishing connection between the client and a server.
In the embodiment of the present application, after the client establishes a connection with the server, each client has a unique identification information, that is, a request identification ID, for identifying the identity information of the client. Of course, when the client and the server establish a connection, different clients and different servers can have different connection time. Therefore, the request identification ID corresponding to the client and the connection time for establishing the connection between the client and the server can be obtained.
Optionally, the obtaining of the request identifier ID corresponding to the client and the connection time for establishing the connection between the client and the server includes: when a connection request sent by a client is received, distributing identification information for the client, and recording the corresponding time when the connection request is received; and taking the identification information as a request identification ID corresponding to the client, and taking the time corresponding to the connection request as the connection time for establishing connection between the client and the server. In the embodiment of the application, after the plurality of clients establish connection with the server, the plurality of clients acquire corresponding services from the server. When the client establishes connection with the server, the client sends a connection request to the server, and when the server receives the connection request sent by the client, the server allocates corresponding identification information to the client, and uses the identification information as a request identification ID corresponding to the client. And taking the time when the server receives the connection request sent by the client as the connection time when the client and the server establish connection.
And step 102, determining a target storage ring corresponding to the client according to the request identification ID.
In the embodiment of the application, a target storage ring corresponding to a client is determined according to a request identification ID corresponding to the client, where the target storage ring may be understood as a storage container for storing client key information. Illustratively, the number of storage rings preset by the server is obtained, and a target storage ring corresponding to the client is determined according to the number of storage rings and the request identifier ID of the client and a preset rule. For example, if the number of the preset storage rings is 2, obtaining a numerical value corresponding to the request identifier ID of the client (if the request identifier ID is a character string, performing hash operation on the request identifier ID to obtain the corresponding numerical value), and when the numerical value corresponding to the request identifier ID of the client is an odd number, placing the client in a first storage ring, that is, taking the first storage ring as a target storage ring of the client; and when the numerical value corresponding to the request identifier ID corresponding to the client is an even number, putting the client into a second storage ring, namely taking the second storage ring as a target storage ring of the client. For another example, the number of the preset storage rings is 3, a numerical value corresponding to the request identifier ID of the client is obtained, and when the numerical value corresponding to the request identifier ID of the client is smaller than a first preset threshold, the first storage ring may be used as the target storage ring of the client; when the value corresponding to the request identifier ID of the client is greater than or equal to a first preset threshold and smaller than a second preset threshold, the second storage ring can be used as a target storage ring of the client; and when the value corresponding to the request identifier ID of the client is greater than or equal to a second preset threshold value, taking the third storage ring as the target storage ring of the client.
Optionally, determining the target storage ring corresponding to the client according to the request identifier ID includes: performing modular operation on the request identifier ID to obtain a first modular operation result; and determining a target storage ring corresponding to the client according to the first modular operation result. For example, if the number of the storage rings preset by the server is 4, a modulo operation may be performed on the request identifier ID, for example, a modulo operation is performed on the request identifier ID based on the number of the storage rings preset by the server, so as to obtain a first modulo operation result. For example, if the request ID of a certain client is 5 (or the value corresponding to the request ID is 5), the request ID is modulo 4, and the obtained first modulo operation result is 5 mod 4 ═ 1, then the second storage ring can be used as the target storage ring of the client; when the request identifier ID of the client is 4, modulo the request identifier ID of the client by 4, and the obtained first modulo operation result is 4 mod 4 ═ 0, then the first storage ring can be used as the target storage ring of the client; when the request identifier ID of the client is 10, modulo 4 the request identifier ID of the client, and the obtained first modulo operation result is 10 mod 4 ═ 2, then the third storage ring can be used as the target storage ring of the client; when the request identifier ID of the client is 7, the request identifier ID of the client is modulo-4, and the obtained first modulo operation result is 7 mod 4 ═ 3, so that the fourth storage ring can be used as the target storage ring of the client. It can be understood that, for a client that requests the identifier ID to modulo 4, the result of the first modulo operation is 0, the first memory ring is its target memory ring; for the client with the request identification ID modulo 4 and the first modulo operation result of 1, the second storage ring is the target storage ring; for the client with the request identification ID modulo 4 and the first modulo operation result of 2, the third storage ring is the target storage ring; for the client with the request identification ID modulo 4 and the first modulo operation result of 3, the fourth storage ring is its target storage ring.
It should be noted that, in the embodiment of the present application, a specific manner of determining the target storage ring corresponding to the client according to the request identifier ID of the client is not limited.
And 103, determining a target storage area corresponding to the client from the storage areas contained in the target storage ring according to the connection time.
The target storage area is used for storing key information of the client.
In the embodiment of the application, the target storage ring may include a plurality of storage areas, and after the target storage ring corresponding to the client is determined according to the request identifier ID corresponding to the client, the specific target storage area of the client in the target storage ring may be further determined according to the connection time for establishing the connection between the client and the server. The target storage area is used for storing key information of the client, wherein the key information may include at least one of a request identification ID of the client, a name of the client, a type of a service invoked by the client, and a connection time for establishing a connection between the client and the server.
For example, the target storage ring is divided into 3 storage areas, each storage area can independently store key information of different clients, and then the target storage area corresponding to a client can be determined from the 3 storage areas in the target storage ring according to the connection time for establishing connection between the client and the server. For example, the connection time for establishing the connection between the client and the server only concerns seconds, that is, which second the connection time between the client and the server is specifically, the key information of the client whose connection time for establishing the connection between the client and the server is less than 20 seconds may be stored in the first storage area in the target storage ring, that is, the first storage area is used as the target storage area of the client in the target storage ring; when the connection time for establishing connection between the client and the server is more than or equal to 20 seconds and less than 40 seconds, storing the key information of the client in a second storage area in the target storage ring, namely taking the second storage area as the target storage area of the client in the target storage ring; when the connection time for establishing the connection between the client and the server is greater than or equal to 40 seconds and less than or equal to 60 seconds, the key information of the client can be stored in a third storage area in the target storage ring, that is, the third storage area is used as the target storage area of the client in the target storage ring.
Optionally, before determining the target storage area corresponding to the client from the storage area included in the target storage ring according to the connection time, the method further includes: acquiring a preset heartbeat detection duration threshold; determining a second number of storage areas contained in the target storage ring according to the heartbeat detection duration threshold; determining a target storage area corresponding to the client from the storage areas contained in the target storage ring according to the connection time, wherein the method comprises the following steps: and determining a target storage area corresponding to the client from a second number of storage areas contained in the target storage ring according to the connection time and the heartbeat detection time threshold. The method has the advantages that the number of the storage areas contained in the target storage ring can be accurately determined according to the heartbeat detection time threshold value, so that the target storage area of the client in the target storage ring can be reasonably determined according to the connection time between the client and the server and the heartbeat detection time threshold value.
Illustratively, the preset heartbeat detection time threshold is 20 seconds, that is, when the heartbeat data packet sent by the client is not received within 20 seconds, it is considered that the connection between the client and the server is abnormal. Because the preset heartbeat detection time threshold is 20 seconds, the connection time for establishing the connection between the client and the server only needs to pay attention to seconds, the whole target storage region can be understood as a storage region capable of performing heartbeat detection with the time duration of 60 seconds, the storage region capable of performing heartbeat detection with the time duration of 60 seconds can be divided into 3 storage regions, and the time duration capable of performing heartbeat detection corresponding to each storage region is 20 seconds.
Optionally, determining, according to the connection time and the heartbeat detection time threshold, a target storage area corresponding to the client from a second number of storage areas included in the target storage ring includes: carrying out summation operation on the connection time and the heartbeat detection duration threshold to obtain a summation result; calculating an integral division result of the summation result by the heartbeat detection time length threshold; performing modular operation on the integer division result based on the second number of the storage areas to obtain a second modular operation result; and determining a target storage area corresponding to the client from a second number of storage areas contained in the target storage ring according to the second modular operation result. The advantage of setting up like this lies in, can save the client that the connection time is more close between client and the server in a memory ring, is favorable to carrying out heartbeat detection to each client fast, in time like this, can further avoid carrying out the condition emergence of examining to individual client.
Illustratively, the connection time for establishing connection between the client and the server is summed with the heartbeat detection time threshold, and the heartbeat detection time threshold is divided by the summation result to obtain an integral division result. For example, if the heartbeat detection time threshold is 15 seconds and the connection time is 20 seconds, the obtained integer division result is 2. And performing modular operation on the integer division result based on the second number of the storage areas to obtain a second modular operation result, and determining the target storage area of the client in the target storage ring according to the second modular operation result. For example, if the second number of storage areas is 4, that is, the target storage ring includes 4 storage areas, and the obtained second modulo operation result is 2 mod 4 — 2, the third storage area may be used as the target storage area of the client.
And step 104, when the heartbeat detection event is triggered, performing heartbeat detection on the clients corresponding to the storage areas in parallel.
For example, a timing task may be preset, and when the time of the timing task arrives, a heartbeat detection event may be triggered. The timing task may be specifically set according to actual conditions, and for example, may be set to 30 seconds, 10 minutes, half an hour or 1 hour, that is, every 30 seconds, every 10 minutes, every half an hour or every 1 hour, for heartbeat detection. Optionally, the heartbeat detection time threshold may be set to a timing time corresponding to the timing task. And when the heartbeat detection event is triggered, carrying out heartbeat detection on the clients corresponding to the storage areas in parallel. Illustratively, when a heartbeat detection event is triggered, heartbeat detection is performed on corresponding clients in each storage area in a target storage ring simultaneously or in parallel, that is, for each storage area, heartbeat detection is performed on each client in parallel, that is, a heartbeat data packet is sent to a first client in each storage area simultaneously, whether heartbeat feedback information of the client is received within a heartbeat detection time threshold is judged, for each storage area, after the heartbeat detection of the first client is completed, heartbeat detection is performed on a second client, and so on until the heartbeat detection of all the clients included in the storage area is completed.
According to the heartbeat detection method provided by the embodiment of the application, a request identification ID corresponding to a client and connection time for establishing connection between the client and a server are obtained, a target storage ring corresponding to the client is determined according to the request identification ID, then a target storage area corresponding to the client is determined from a storage area contained in the target storage ring according to the connection time, wherein the target storage area is used for storing key information of the client, and when a heartbeat detection event is triggered, heartbeat detection is performed on the client corresponding to each storage area in parallel. By adopting the technical scheme, the heartbeat detection can be rapidly and timely carried out on each client connected with the server, the connection state of each client can be accurately determined, and the resource occupation of the client with abnormal connection state to the server can be favorably reduced.
Fig. 2 is a schematic flow chart of a heartbeat detection method provided in an embodiment of the present application, and as shown in fig. 2, the method includes:
step 201, obtaining a request identification ID corresponding to a client and connection time for establishing connection between the client and the server.
Step 202, determining a first number of storage rings according to the configuration information of the server.
In the embodiment of the application, the configuration information of the server is obtained, and the first number of the storage rings is determined according to the configuration information. The configuration information of the server may include the maximum number of the clients to which the server can connect, and may also include the memory size of the client capable of storing the key information of the client. Illustratively, the configuration information of the server includes that the maximum number of the servers capable of connecting to the clients is 100, and in order to reduce the heartbeat detection duration of the clients included in each storage ring, 4 storage rings may be set for storing the key information of the clients. Of course, 2 storage rings can be set for storing the key information of the client. It should be noted that, in the embodiment of the present application, a specific manner of determining the first number of storage rings according to the configuration information of the server is not limited.
Step 203, determine whether the first number is greater than 1, if yes, execute step 204, otherwise, execute step 213.
And 204, performing modular operation on the request identifier ID based on the first number of the storage rings to obtain a first modular operation result.
When the number of the storage rings is greater than 1, that is, the server side includes a plurality of storage rings, performing modular operation on the request identifier ID based on the first number of the storage rings, so that in the subsequent step, according to a result of the first modular operation, a target storage ring in which the client key information is specifically stored is reasonably determined from the plurality of storage rings.
Step 205, according to the first modulo operation result, determining a target storage ring corresponding to the client from the first number of storage rings.
Illustratively, the first number of the storage rings is 2, that is, the server includes 2 storage rings, and then a modulo operation is performed on the request identifier ID corresponding to the client based on the first number 2 of the storage rings. For example, if the request ID corresponding to a certain client is 3, the request ID is modulo-2, and the obtained first modulo operation result is 3 mod 2 ═ 1, the key information of the client can be stored in the second storage ring, that is, the second storage ring can be used as the target storage ring of the client. For example, if the request ID corresponding to a certain client is 6, the request ID is modulo-2, and the obtained first modulo operation result is 6 mod 2 ═ 0, the key information of the client can be stored in the first memory ring, that is, the first memory ring can be the target memory ring of the client.
And step 206, acquiring a preset heartbeat detection time threshold.
Illustratively, the preset heartbeat detection time length is 15 seconds, that is, when a heartbeat data packet sent by the client is not received within 15 seconds, it is considered that the connection between the client and the server is abnormal.
And step 207, determining a second number of storage areas contained in the target storage ring according to the heartbeat detection duration threshold.
In the embodiment of the application, the time when the client establishes the connection with the server specifically concerns the time, minute or second, and is related to the heartbeat detection duration threshold. If the heartbeat detection time length threshold is less than 60 seconds, the connection time between the client and the server is only second; if the heartbeat detection time length threshold is greater than 60 seconds and less than or equal to 60 minutes, the connection time between the client and the server is only divided; and if the heartbeat detection time length threshold is greater than 60 minutes, the connection time between the client and the server is only taken. For example, if the heartbeat detection time threshold is 15 seconds, the second number of storage regions included in the target storage ring is 60 ÷ 15 ═ 4, that is, the target storage ring may be divided into 4 storage regions.
And 208, performing summation operation on the connection time and the heartbeat detection time threshold to obtain a summation result.
And 209, calculating an integral division result of the summation result by the heartbeat detection time length threshold.
For example, the connection time for the connection between the client and the server may be represented by T, and the heartbeat detection duration threshold may be represented by T, then the summation result of the connection time T and the heartbeat detection duration threshold T, and the integer division result J of the integer division of the heartbeat detection duration threshold T may be represented as: j ═ T + T)/T. For example, in the embodiment of the present application, if the heartbeat detection duration threshold is 15 seconds, J ═ t + 15)/15. If the connection time for the client to establish the connection with the server is 20s, J ═ 20+15)/15 ═ 2.
And 210, performing modular operation on the integer division result based on the second number of the storage areas to obtain a second modular operation result.
In the embodiment of the present application, the integer division result is subjected to a modulo operation based on the second number of the storage area, that is, the integer division result is subjected to a modulo operation on the second number. For example, the second number of memory regions is denoted by M, and the second modulo operation result S can be expressed as: j mod M ═ T + T/T mod M. For example, M is 4, J is 2, and S is 2 mod 4 is 2.
Step 211, according to the second modulo operation result, determining a target storage area corresponding to the client from a second number of storage areas included in the target storage ring.
For example, 4 storage areas are included in the target storage ring, and if the second modulo operation result S is 2, the third storage area may be determined as the target storage area of the client. For another example, when S is 0, the first storage area may be determined as the target storage area of the client; if S is 1, the second storage area may be determined as the target storage area of the client; and if S is 3, the fourth storage area can be determined as the target storage area of the client.
And step 212, when the heartbeat detection event is triggered, performing heartbeat detection on the clients corresponding to the storage areas in parallel.
And step 213, directly determining the storage ring as the target storage ring of the client.
In the embodiment of the present application, when the number of storage rings is not greater than 1, that is, the number of storage rings is only 1, the storage ring may be directly determined as the target storage ring of the client, and step 206 is performed.
The heartbeat detection method provided in the embodiment of the application obtains a request identification ID corresponding to a client and connection time for establishing connection between the client and a server, determines a first number of storage rings according to configuration information of the server, performs modulo operation on the request identification ID based on the first number of storage rings to obtain a first modulo operation result when the first number is greater than 1, determines a target storage ring corresponding to the client from the first number of storage rings according to the first modulo operation result, then obtains a preset heartbeat detection duration threshold, determines a second number of storage regions contained in the target storage ring according to the heartbeat detection duration threshold, performs summation operation on the connection time and the heartbeat detection duration threshold to obtain a summation result, calculates an integer division result of the summation result and the heartbeat detection duration threshold, and performs modulo operation on the integer division result based on the second number of the storage regions, and obtaining a second modular operation result, determining a target storage area corresponding to the client from a second number of storage areas contained in the target storage ring according to the second modular operation result, and finally performing heartbeat detection on the client corresponding to each storage area in parallel when a heartbeat detection event is triggered. By adopting the technical scheme, the fast and timely heartbeat detection can be further realized for each client connected with the server, the condition that the detection of a certain client is missed can be further effectively avoided, the connection state of each client can be accurately determined, and the resource occupation of the client with the abnormal connection state to the server can be favorably reduced.
Fig. 3 is a schematic structural diagram of a heartbeat detection device provided in an embodiment of the present application, where the device may be implemented by software and/or hardware, and is generally integrated in a server, and can perform heartbeat detection on a client connected to the server by executing a heartbeat detection method. As shown in fig. 3, the apparatus includes:
a client information obtaining module 301, configured to obtain a request identifier ID corresponding to a client and connection time for establishing a connection between the client and the server;
a target storage ring determining module 302, configured to determine, according to the request identifier ID, a target storage ring corresponding to the client;
a target storage area determining module 303, configured to determine, according to the connection time, a target storage area corresponding to the client from a storage area included in the target storage ring; the target storage area is used for storing key information of the client;
and the heartbeat detection module 304 is configured to perform heartbeat detection on the clients corresponding to the storage regions in parallel when a heartbeat detection event is triggered.
The heartbeat detection device provided in the embodiment of the application obtains a request identification ID corresponding to a client and connection time for establishing connection between the client and a server, determines a target storage ring corresponding to the client according to the request identification ID, and then determines a target storage area corresponding to the client from a storage area contained in the target storage ring according to the connection time, wherein the target storage area is used for storing key information of the client, and when a heartbeat detection event is triggered, heartbeat detection is performed on the client corresponding to each storage area in parallel. By adopting the technical scheme, the heartbeat detection can be rapidly and timely carried out on each client connected with the server, the connection state of each client can be accurately determined, and the resource occupation of the client with abnormal connection state to the server can be favorably reduced.
Optionally, the target storage ring determining module includes:
the first modular operation unit is used for carrying out modular operation on the request identification ID to obtain a first modular operation result;
and the target storage ring determining unit is used for determining the target storage ring corresponding to the client according to the first modular operation result.
Optionally, the apparatus further comprises:
a first quantity determining module, configured to determine a first quantity of storage rings according to configuration information of the server before performing a modular operation on the request identifier ID to obtain a first modular operation result;
the first modulo operation unit is configured to:
performing modular operation on the request identification ID based on the first number of the storage rings to obtain a first modular operation result;
the target storage ring determination unit includes:
and the target storage ring determining subunit is configured to determine, according to the first modulo operation result, a target storage ring corresponding to the client from the first number of storage rings.
Optionally, the apparatus further comprises:
the judging module is used for judging whether the first quantity is greater than 1 or not before performing modular operation on the request identification ID based on the first quantity of the storage rings to obtain a first modular operation result;
the target storage ring determining subunit is configured to:
and when the first number is larger than 1, performing modular operation on the request identification ID based on the first number of the storage rings to obtain a first modular operation result.
Optionally, the apparatus further comprises:
a heartbeat detection threshold value obtaining module, configured to obtain a preset heartbeat detection duration threshold value before determining, according to the connection time, a target storage region corresponding to the client from a storage region included in the target storage ring;
a second quantity determining module, configured to determine, according to the heartbeat detection duration threshold, a second quantity of storage regions included in the target storage ring;
a target storage area determination module comprising:
and the target storage area determining unit is used for determining a target storage area corresponding to the client from a second number of storage areas contained in the target storage ring according to the connection time and the heartbeat detection time threshold.
Optionally, the target storage area determining unit is configured to:
carrying out summation operation on the connection time and the heartbeat detection duration threshold to obtain a summation result;
calculating an integral division result of the summation result by the heartbeat detection time length threshold;
performing modular operation on the integer division result based on the second number of the storage areas to obtain a second modular operation result;
and determining a target storage area corresponding to the client from a second number of storage areas contained in the target storage ring according to the second modular operation result.
Optionally, the client information obtaining module is configured to:
when a connection request sent by a client is received, distributing identification information for the client, and recording the corresponding time when the connection request is received;
and taking the identification information as a request identification ID corresponding to the client, and taking the time corresponding to the connection request as the connection time for establishing connection between the client and the server.
Embodiments of the present application also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a method for heartbeat detection, the method including:
acquiring a request identification ID corresponding to a client and connection time for establishing connection between the client and the server;
determining a target storage ring corresponding to the client according to the request identifier ID;
according to the connection time, determining a target storage area corresponding to the client from a storage area contained in the target storage ring; the target storage area is used for storing key information of the client;
and when the heartbeat detection event is triggered, carrying out heartbeat detection on the clients corresponding to the storage areas in parallel.
Storage medium-any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk, or tape devices; computer system memory or random access memory such as DRAM, DDRRAM, SRAM, EDORAM, Lanbas (Rambus) RAM, etc.; non-volatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a different second computer system connected to the first computer system through a network (such as the internet). The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations, such as in different computer systems that are connected by a network. The storage medium may store program instructions (e.g., embodied as a computer program) that are executable by one or more processors.
Of course, the storage medium provided in the embodiments of the present application and containing the computer-executable instructions is not limited to the above-described heartbeat detection operation, and may also perform related operations in the heartbeat detection method provided in any embodiments of the present application.
The embodiment of the application provides a server, and the heartbeat detection device provided by the embodiment of the application can be integrated in the server. Fig. 4 is a schematic structural diagram of a server according to an embodiment of the present application. The server 400 may include: a memory 401, a processor 402 and a computer program stored on the memory and executable on the processor, wherein the processor 402 implements the heartbeat detection method according to the embodiment of the present application when executing the computer program.
The server provided by the embodiment of the application can realize quick and timely heartbeat detection on each client connected with the server, accurately determine the connection state of each client, and is favorable for reducing the resource occupation of the client with abnormal connection state on the server.
The heartbeat detection device, the storage medium and the server provided in the above embodiments can execute the heartbeat detection method provided in any embodiment of the present application, and have corresponding functional modules and beneficial effects for executing the method. For technical details that are not described in detail in the above embodiments, reference may be made to the heartbeat detection method provided in any embodiments of the present application.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present application and the technical principles employed. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present application is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims (7)

1. A heartbeat detection method is applied to a server side and is characterized by comprising the following steps:
acquiring a request identification ID corresponding to a client and connection time for establishing connection between the client and the server; the connection time is the time when the server receives the connection request sent by the client; determining a target storage ring corresponding to the client according to the request identifier ID;
according to the connection time, determining a target storage area corresponding to the client from a storage area contained in the target storage ring; the target storage area is used for storing key information of the client;
when the heartbeat detection event is triggered, carrying out heartbeat detection on the clients corresponding to the storage areas in parallel;
the acquiring the request identifier ID corresponding to the client and the connection time for establishing the connection between the client and the server comprises the following steps:
when a connection request sent by a client is received, distributing identification information for the client, and recording the corresponding time when the connection request is received;
taking the identification information as a request identification ID corresponding to the client, and taking the time corresponding to the connection request as the connection time for establishing connection between the client and the server;
before determining a target storage area corresponding to the client from the storage areas included in the target storage ring according to the connection time, the method further includes:
acquiring a preset heartbeat detection duration threshold;
determining a second number of storage areas contained in the target storage ring according to the heartbeat detection duration threshold;
determining a target storage area corresponding to the client from the storage areas contained in the target storage ring according to the connection time, wherein the method comprises the following steps:
carrying out summation operation on the connection time and the heartbeat detection duration threshold to obtain a summation result;
calculating an integral division result of the summation result by the heartbeat detection time length threshold;
performing modular operation on the integer division result based on the second number of the storage areas to obtain a second modular operation result;
and determining a target storage area corresponding to the client from a second number of storage areas contained in the target storage ring according to the second modular operation result.
2. The method of claim 1, wherein determining the target storage ring corresponding to the client according to the request identifier ID comprises:
performing modular operation on the request identifier ID to obtain a first modular operation result;
and determining a target storage ring corresponding to the client according to the first modular operation result.
3. The method of claim 2, wherein before performing a modulo operation on the request identification ID to obtain a first modulo operation result, further comprising:
determining a first number of storage rings according to the configuration information of the server;
performing a modular operation on the request identifier ID to obtain a first modular operation result, including:
performing modular operation on the request identification ID based on the first number of the storage rings to obtain a first modular operation result;
determining a target storage ring corresponding to the client according to the first modular operation result, including:
and determining a target storage ring corresponding to the client from the first number of storage rings according to the first modular operation result.
4. The method of claim 3, further comprising, prior to performing a modulo operation on the request identification ID based on the first number of memory rings to obtain a first modulo operation result:
judging whether the first number is larger than 1;
performing a modular operation on the request identifier ID based on the first number of storage rings to obtain a first modular operation result, including:
and when the first number is larger than 1, performing modular operation on the request identification ID based on the first number of the storage rings to obtain a first modular operation result.
5. The utility model provides a heartbeat detection device, is applied to the server side, its characterized in that includes:
the client information acquisition module is used for acquiring a request identification ID corresponding to a client and connection time for establishing connection between the client and the server; the connection time is the time when the server receives the connection request sent by the client;
a target storage ring determining module, configured to determine a target storage ring corresponding to the client according to the request identifier ID;
a target storage area determining module, configured to determine, according to the connection time, a target storage area corresponding to the client from a storage area included in the target storage ring; the target storage area is used for storing key information of the client;
the heartbeat detection module is used for carrying out heartbeat detection on the clients corresponding to the storage areas in parallel when a heartbeat detection event is triggered;
the client information acquisition module is used for:
when a connection request sent by a client is received, distributing identification information for the client, and recording the corresponding time when the connection request is received;
taking the identification information as a request identification ID corresponding to the client, and taking the time corresponding to the connection request as the connection time for establishing connection between the client and the server;
the target storage area determination module includes:
the target storage area determining unit is used for carrying out summation operation on the connection time and the heartbeat detection duration threshold value to obtain a summation result;
calculating an integral division result of the summation result by the heartbeat detection time length threshold;
performing modular operation on the integer division result based on the second number of the storage areas to obtain a second modular operation result;
and determining a target storage area corresponding to the client from a second number of storage areas contained in the target storage ring according to the second modular operation result.
6. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the heartbeat detection method as claimed in any one of claims 1 to 4.
7. A server, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the heartbeat detection method as claimed in any one of claims 1 to 4 when executing the computer program.
CN201811489458.2A 2018-12-06 2018-12-06 Heartbeat detection method, heartbeat detection device, storage medium and server Active CN109602413B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811489458.2A CN109602413B (en) 2018-12-06 2018-12-06 Heartbeat detection method, heartbeat detection device, storage medium and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811489458.2A CN109602413B (en) 2018-12-06 2018-12-06 Heartbeat detection method, heartbeat detection device, storage medium and server

Publications (2)

Publication Number Publication Date
CN109602413A CN109602413A (en) 2019-04-12
CN109602413B true CN109602413B (en) 2022-01-18

Family

ID=66007393

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811489458.2A Active CN109602413B (en) 2018-12-06 2018-12-06 Heartbeat detection method, heartbeat detection device, storage medium and server

Country Status (1)

Country Link
CN (1) CN109602413B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116450055B (en) * 2023-06-15 2023-10-27 支付宝(杭州)信息技术有限公司 Method and system for distributing storage area between multi-processing cards

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101013958A (en) * 2006-12-22 2007-08-08 华为技术有限公司 Method and system, module for realizing heartbeat
CN102148722A (en) * 2011-01-20 2011-08-10 深圳市同洲电子股份有限公司 Method and system for detecting data interaction state by using heartbeats, and proxy server
CN102685768A (en) * 2011-03-08 2012-09-19 华为技术有限公司 Processing method of heartbeat message, acquisition method of heartbeat period and access network equipment
CN102790776A (en) * 2012-08-03 2012-11-21 中国联合网络通信集团有限公司 Heartbeat connection normalizing processing method, terminal, server and communication system
CN103518342A (en) * 2013-04-26 2014-01-15 华为技术有限公司 Transmitting control method and device for heartbeat signal
CN104166589A (en) * 2013-05-17 2014-11-26 阿里巴巴集团控股有限公司 Heartbeat package processing method and device
CN105335513A (en) * 2015-10-30 2016-02-17 迈普通信技术股份有限公司 Distributed file system and file storage method
CN106961364A (en) * 2017-04-24 2017-07-18 努比亚技术有限公司 Heartbeat detecting method and application server
CN107819642A (en) * 2017-09-15 2018-03-20 中国科学院计算技术研究所 Based on distributed adaptive heartbeat method and system
CN108173709A (en) * 2017-12-19 2018-06-15 广州视源电子科技股份有限公司 The long connection method of keep-alive, device, terminal device and storage medium
CN108449239A (en) * 2018-06-19 2018-08-24 广州视源电子科技股份有限公司 Heartbeat packet method, apparatus, equipment and storage medium
CN108768791A (en) * 2018-07-04 2018-11-06 山东汇贸电子口岸有限公司 A kind of information collection configuration management system and method
CN108900370A (en) * 2018-06-08 2018-11-27 努比亚技术有限公司 It is long to connect multiple overtime judgment method, device and computer readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060120291A1 (en) * 2004-12-03 2006-06-08 Chao-Hung Wu System structure for increasing the performance of data transmission on the internet

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101013958A (en) * 2006-12-22 2007-08-08 华为技术有限公司 Method and system, module for realizing heartbeat
CN102148722A (en) * 2011-01-20 2011-08-10 深圳市同洲电子股份有限公司 Method and system for detecting data interaction state by using heartbeats, and proxy server
CN102685768A (en) * 2011-03-08 2012-09-19 华为技术有限公司 Processing method of heartbeat message, acquisition method of heartbeat period and access network equipment
CN102790776A (en) * 2012-08-03 2012-11-21 中国联合网络通信集团有限公司 Heartbeat connection normalizing processing method, terminal, server and communication system
CN103518342A (en) * 2013-04-26 2014-01-15 华为技术有限公司 Transmitting control method and device for heartbeat signal
CN104166589A (en) * 2013-05-17 2014-11-26 阿里巴巴集团控股有限公司 Heartbeat package processing method and device
CN105335513A (en) * 2015-10-30 2016-02-17 迈普通信技术股份有限公司 Distributed file system and file storage method
CN106961364A (en) * 2017-04-24 2017-07-18 努比亚技术有限公司 Heartbeat detecting method and application server
CN107819642A (en) * 2017-09-15 2018-03-20 中国科学院计算技术研究所 Based on distributed adaptive heartbeat method and system
CN108173709A (en) * 2017-12-19 2018-06-15 广州视源电子科技股份有限公司 The long connection method of keep-alive, device, terminal device and storage medium
CN108900370A (en) * 2018-06-08 2018-11-27 努比亚技术有限公司 It is long to connect multiple overtime judgment method, device and computer readable storage medium
CN108449239A (en) * 2018-06-19 2018-08-24 广州视源电子科技股份有限公司 Heartbeat packet method, apparatus, equipment and storage medium
CN108768791A (en) * 2018-07-04 2018-11-06 山东汇贸电子口岸有限公司 A kind of information collection configuration management system and method

Also Published As

Publication number Publication date
CN109602413A (en) 2019-04-12

Similar Documents

Publication Publication Date Title
CN104601702B (en) Cluster remote procedure calling (PRC) method and system
JP7326443B2 (en) NF service consumer restart detection using direct signaling between NFs
KR102167613B1 (en) Message push method and device
CN107872396B (en) Communication method with timeout control, processing device, terminal device and server
CN110768873B (en) Distributed heartbeat detection method, system and device and computer equipment
CN111343237A (en) Server cluster communication method, communication device and computer storage medium
CN112463318A (en) Timed task processing method, device and system
CN109602413B (en) Heartbeat detection method, heartbeat detection device, storage medium and server
CN113452770B (en) Data synchronization method, device, computer equipment and storage medium
CN111901386B (en) Method, system, equipment and readable storage medium for processing remote files
CN107918877B (en) Data acquisition method and device
US20220182305A1 (en) Request Processing System and Method Thereof
CN108429703B (en) DHCP client-side online method and device
US11638134B2 (en) Methods, systems, and computer readable media for resource cleanup in communications networks
US11496528B2 (en) P-CSCF discovery through NRF
TW202333534A (en) System of transferring data in mobile edge computing, method and computer readable medium thereof
CN113094074A (en) Service cluster updating method and device
US20180063005A1 (en) Non-blocking request processing method and device
CN110650259B (en) Call request response method, device, server, terminal and storage medium
JP4284349B2 (en) SIP trunk gateway device
CN111310130A (en) Authorization authentication processing method, device, storage medium and electronic device
CN113315875B (en) Call information synchronization method and device, call information synchronization equipment and storage medium
CN115914152B (en) Receipt information pushing method, system and storage medium
CN112948337B (en) File sharing duration statistical method, system, device and medium
CN117411926A (en) Connection establishment method and device of server, storage medium and electronic equipment

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
GR01 Patent grant
GR01 Patent grant