CN109981415B - State determination method, electronic device, system, and medium - Google Patents

State determination method, electronic device, system, and medium Download PDF

Info

Publication number
CN109981415B
CN109981415B CN201910272374.1A CN201910272374A CN109981415B CN 109981415 B CN109981415 B CN 109981415B CN 201910272374 A CN201910272374 A CN 201910272374A CN 109981415 B CN109981415 B CN 109981415B
Authority
CN
China
Prior art keywords
state
heartbeat
target
client
online
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
CN201910272374.1A
Other languages
Chinese (zh)
Other versions
CN109981415A (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.)
Shenzhen Onething Technology Co Ltd
Original Assignee
Shenzhen Onething Technology Co 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 Shenzhen Onething Technology Co Ltd filed Critical Shenzhen Onething Technology Co Ltd
Priority to CN201910272374.1A priority Critical patent/CN109981415B/en
Publication of CN109981415A publication Critical patent/CN109981415A/en
Application granted granted Critical
Publication of CN109981415B publication Critical patent/CN109981415B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/54Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Treatment And Welfare Office Work (AREA)

Abstract

The invention discloses a state judgment method, electronic equipment, a system and a medium, wherein the method comprises the following steps: when a heartbeat request is detected, adopting a hypertext transfer protocol and/or a hypertext transfer security protocol to accept the heartbeat request; acquiring heartbeat parameters from the heartbeat request; detecting a target mark value corresponding to the heartbeat parameter in a cache server to obtain a detection result; and judging the state of the target client corresponding to the heartbeat parameter according to the detection result. The invention can realize the effective judgment of the client state under the short connection protocol.

Description

State determination method, electronic device, system, and medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a state determination method, an electronic device, a system, and a medium.
Background
The HyperText Transfer Protocol (HTTP) and/or the HyperText Transfer Protocol Security (HTTPs) are the most widely used network communication protocols on the internet, and applications based on the browser Web (World Wide Web) end rely on the protocols to communicate with the server end. The protocol is based on a "client request-server response" mode, and therefore, the status of the client cannot be judged by the protocol. Although the server has a great number of mature open-source network servers capable of providing network services, the client initiates a request, and the server returns corresponding files, data, interface services and the like. In this mode, the internet application provider can quickly construct a set of network applications with extremely low development and development technology cost. However, since the protocol is a stateless short connection protocol, it will not meet the requirements when a persistent state like "online" needs to be implemented.
In the prior art, the long connection TCP (Transmission Control Protocol) technology based on a non-browser end or a long connection technology such as a WebSocket at a browser end is generally adopted. However, the above solutions also have certain disadvantages.
Under the widely used browser web application scene, the TCP protocol cannot be supported, and the use of the WebSocket long connection has the following problems:
(1) the technical research and development cost of the client and the server is improved;
(2) a large number of long connections may consume excessive server resources;
(3) the part of the browser end does not support the WebSocket protocol;
(4) in a non-browser scenario, for example, when a mobile application (App) side accesses a server side through a hypertext transfer protocol and/or a hypertext transfer security protocol, the WebSocket protocol cannot be directly used.
Disclosure of Invention
The invention mainly aims to provide a state judgment method, electronic equipment, a system and a medium, and aims to solve the problem of client state judgment when a hypertext transfer protocol and/or a hypertext transfer security protocol is/are adopted.
To achieve the above object, the present invention provides a state determination method, including:
when a heartbeat request is detected, adopting a hypertext transfer protocol and/or a hypertext transfer security protocol to accept the heartbeat request;
acquiring heartbeat parameters from the heartbeat request;
detecting a target mark value corresponding to the heartbeat parameter in a cache server to obtain a detection result;
and judging the state of the target client corresponding to the heartbeat parameter according to the detection result.
Preferably, the heartbeat parameter includes an identification of the target client, a type of the target client, and the method further includes:
acquiring all connectable clients;
determining the identification and the type of each client in all the clients;
establishing a marking value of each client according to the identification and the type of each client;
storing each tag value in the cache server;
and configuring a heartbeat period and a caching period for each mark value.
Preferably, the determining, according to the detection result, the state of the target client corresponding to the heartbeat parameter includes:
when the target mark value is detected to exist, determining that the target client is in an online state; or
When the target mark value is detected to be absent, determining that the target client is in an offline state.
Preferably, after determining the state of the target client corresponding to the heartbeat parameter according to the detection result, the method further includes:
acquiring a target heartbeat cycle and a target caching period of the target mark value from the caching server;
calculating a difference value between the target cache validity period and the target heartbeat period;
and constructing a misjudgment time range corresponding to the state of the target client by taking the difference value as a minimum value and the target heartbeat period as a maximum value.
Preferably, the method further comprises:
acquiring the number of times of failure in receiving the heartbeat request;
and when the times are less than or equal to the configuration value, continuously judging the state of the target client.
Preferably, after determining the state of the target client corresponding to the heartbeat parameter, the method further includes:
calculating the total time length of the target client in an online state within a preset time range; and/or
Calculating the number of online days of the target client in an online state in the preset time range, determining the total number of days included in the preset time range, and calculating the online rate of the target client in the preset time range according to the number of online days and the total number of days; and/or
And acquiring all the clients, judging the state of each client in all the clients, and determining the number of online clients in an online state and the number of offline clients in an offline state in all the clients according to the state of each client.
To achieve the above object, the present invention further provides an electronic device, comprising:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the state decision method.
Preferably, the electronic device is a node constituting a content distribution network or a blockchain network.
To achieve the above object, the present invention further provides a state determination system, comprising:
the receiving unit is used for receiving the heartbeat request by adopting a hypertext transfer protocol and/or a hypertext transfer security protocol when the heartbeat request is detected;
an obtaining unit, configured to obtain a heartbeat parameter from the heartbeat request;
the detection unit is used for detecting a target mark value corresponding to the heartbeat parameter in the cache server to obtain a detection result;
and the judging unit is used for judging the state of the target client corresponding to the heartbeat parameter according to the detection result.
Preferably, the heartbeat parameter includes an identifier of the target client, a type of the target client, and the obtaining unit is further configured to obtain all connectable clients;
the system further comprises:
a determining unit, configured to determine an identifier and a type of each client in all the clients;
the establishing unit is used for establishing a marking value of each client according to the identification and the type of each client;
the storage unit is used for storing each mark value into the cache server;
and the configuration unit is used for configuring a heartbeat cycle and a caching validity period for each mark value.
Preferably, the determining, according to the detection result, that determining the state of the target client corresponding to the heartbeat parameter includes:
when the target mark value is detected to exist, determining that the target client is in an online state; or
When the target mark value is detected to be absent, determining that the target client is in an offline state.
Preferably, the obtaining unit is further configured to obtain a target heartbeat cycle and a target cache validity period of the target marker value from the cache server after determining a state of a target client corresponding to the heartbeat parameter according to the detection result;
the system further comprises:
the calculating unit is used for calculating the difference value between the target cache validity period and the target heartbeat period;
and the construction unit is used for constructing a misjudgment time range corresponding to the state of the target client by taking the difference value as a minimum value and the target heartbeat period as a maximum value.
Preferably, the obtaining unit is further configured to obtain a number of times that the heartbeat request fails to be accepted;
and the judging unit is further used for continuously judging the state of the target client when the times are less than or equal to a configuration value.
Preferably, the calculating unit is further configured to calculate a total duration of the target client in an online state within a preset time range after determining the state of the target client corresponding to the heartbeat parameter; and/or
The computing unit is further configured to compute online days of the target client in an online state within the preset time range;
the determining unit is further configured to determine a total number of days included in the preset time range;
the computing unit is further configured to compute an online rate of the target client within the preset time range according to the online days and the total days; and/or
The acquiring unit is further configured to acquire all the clients;
the judging unit is further configured to judge a state of each of the clients;
the determining unit is further configured to determine, according to the state of each client, the number of online clients in an online state and the number of offline clients in an offline state in all the clients.
To achieve the above object, the present invention further provides a computer-readable storage medium having stored thereon a state determination program executable by one or more processors to implement the state determination method.
To achieve the above object, the present invention further provides a computer program product comprising computer instructions which, when run on a computer, make the computer execute the state decision method.
In summary, the present invention can adopt a hypertext transfer protocol and/or a hypertext transfer security protocol to accept a heartbeat request when the heartbeat request is detected, so as to establish a connection with a short connection protocol, obtain a heartbeat parameter from the heartbeat request, further detect a target flag value corresponding to the heartbeat parameter in a cache server, obtain a detection result, and determine a state of a target client corresponding to the heartbeat parameter according to the detection result, thereby implementing effective determination of a client state under the short connection protocol.
Drawings
FIG. 1 is a schematic flow chart of an embodiment of the present invention;
fig. 2 is a schematic diagram of an internal structure of an electronic device according to an embodiment of the disclosure;
FIG. 3 is a functional block diagram of a state determination system according to the present invention;
the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Description of the main elements
Figure BDA0002018837100000061
Figure BDA0002018837100000071
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the drawings described above, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that the description relating to "first", "second", etc. in the present invention is for descriptive purposes only and is not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
The invention provides a state determination method.
Referring to fig. 1, fig. 1 is a schematic flow chart according to an embodiment of the invention. The order of the steps in the flow diagram can be changed and some steps can be omitted according to different requirements.
The state determination method is applied to one or more electronic devices, which are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and the hardware of the electronic devices includes, but is not limited to, microprocessors, Application Specific Integrated Circuits (ASICs), Programmable Gate arrays (FPGAs), Digital Signal Processors (DSPs), embedded devices, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), an intelligent wearable device, and the like.
The electronic device may also include a network device and/or a user device. The network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network servers.
The Network where the electronic device is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
In one embodiment, the method comprises:
s10, when the heartbeat request is detected, using a HyperText Transfer Protocol (HTTP) and/or a HyperText Transfer security Protocol (HTTPs) to receive the heartbeat request.
In at least one embodiment of the present invention, the heartbeat request is based on a heartbeat mechanism, which is a mechanism that sends a self-defined structure (heartbeat packet, i.e. the heartbeat request) periodically to let the other side know that the other side is still alive, so as to ensure the validity of the connection.
Specifically, the heartbeat request is typically a very small packet or a null packet that includes only a header.
In at least one embodiment of the present invention, the hypertext transfer protocol and/or hypertext transfer security protocol is a short connection protocol. Moreover, when the hypertext transfer protocol and/or the hypertext transfer security protocol are/is used for connection, the online or offline state of the client cannot be acquired, and the statistical analysis of the user use state or the client connection state cannot be performed.
In at least one embodiment of the invention, the method further comprises:
the electronic equipment acquires all connectable clients and determines the identification and the type of each client in all the clients, furthermore, the electronic equipment establishes a mark value of each client according to the identification and the type of each client and stores each mark value into a Cache server (Cache server), and the electronic equipment configures a heartbeat cycle and a Cache validity period for each mark value.
For example: the flag value may be configured as a key and may be a value. At this time, if the identifier of a client is a and the type of the client is x, the flag value of the client is set to a _ x.
Specifically, the cache server refers to a server storing frequently accessed content. The cache server can automatically clear redundant data, and avoids causing the shortage of server resources and influencing the normal operation of the server.
Further, the client initiates the heartbeat request periodically according to the heartbeat cycle, and the heartbeat cycle can be configured by user, which is not limited in the present invention. For example: the heartbeat period may be 30 seconds, 1 minute, 3 minutes, etc., and the length of the heartbeat period will affect the throughput of the heartbeat request and the delay of the offline status update.
Accordingly, in order to more effectively determine the status of the client, the cache validity period is configured to be a value greater than the heartbeat cycle. For example: when the heartbeat period is 30 seconds, the cache validity period may be configured to be 60 seconds.
In at least one embodiment of the invention, the identification of each client may include, but is not limited to, a combination of one or more of the following:
(1) in a product in a user login state, a client generally has a token (token) indicating a login identity, and through the token, the electronic device can obtain a unique identifier such as a currently logged-in user id (identification) as an identifier of the client.
(2) In products without user login status, the configuration protocol is agreed, for example: for mobile devices such as mobile phones and tablet computers, the device number may be used as the identifier of the client, and for web browsers, the client IP (Internet Protocol Address) may be used as the identifier of the client.
In at least one embodiment of the present invention, since a user may be online on different types of devices such as a pc (personal computer) terminal, a Web browser (World Wide Web), a mobile phone app, a tablet app, and the like, when it is necessary to distinguish which terminal the user is online, the type of the client needs to be determined, and therefore, the electronic device establishes a tag value of each client with the type of the client as a parameter.
And S11, acquiring the heartbeat parameters from the heartbeat request.
In at least one embodiment of the present invention, the heartbeat parameter is included in the heartbeat request.
Further, the heartbeat parameter includes an identification of a target client and a type of the target client.
The target client is the client which is performing state judgment.
And S12, detecting the target mark value corresponding to the heartbeat parameter in the cache server to obtain a detection result.
In at least one embodiment of the present invention, the detection result includes, but is not limited to, any one of the following cases:
(1) the target tag value is present.
(2) The target flag value is not present.
It is understood that, for different detection results, the electronic device will make different judgments on the status of the target client.
And S13, judging the state of the target client corresponding to the heartbeat parameter according to the detection result.
In at least one embodiment of the present invention, the determining, by the electronic device according to the detection result, the state of the target client corresponding to the heartbeat parameter includes:
(1) when the target mark value is detected to exist, the electronic equipment determines that the target client is in an online state.
For example: when a key a _ x in the cache server exists, the electronic device determines that a is currently online and the online device type is x.
(2) When detecting that the target mark value does not exist, the electronic device determines that the target client is in an offline state.
For example: when the key a _ x in the cache server does not exist, the electronic device determines that a is in an offline state on device type x.
Through the embodiment, the electronic equipment can automatically judge the state of the client.
In at least one embodiment of the present invention, after determining, according to the detection result, a state of the target client corresponding to the heartbeat parameter, the method further includes:
and the electronic equipment acquires a target heartbeat cycle and a target caching validity period of the target mark value from the cache server, calculates a difference value between the target caching validity period and the target heartbeat cycle, and establishes a misjudgment time range corresponding to the state of the target client by taking the difference value as a minimum value and the target heartbeat cycle as a maximum value.
For example: after the target client is offline, a _ x in the cache server needs to wait for 60s (a heartbeat is sent just before offline) at the longest and expires after waiting for 30s (a heartbeat is ready to be sent just before offline) at the shortest, so that the target client is actually offline but is judged to be online in this period of time, a specific misjudgment time range m is related to the target heartbeat period t and the target cache validity period e, and the formula is as follows: e-t < m < e.
With the above embodiment, the electronic device can tolerate the delay of the offline state determination when the state determination of the client is performed.
In at least one embodiment of the invention, the method further comprises:
and the electronic equipment acquires the times of failure in receiving the heartbeat request, and when the times are less than or equal to a configuration value, the electronic equipment continues to judge the state of the target client.
It is understood that, if a certain heartbeat request process fails, the electronic device may determine the client as an offline state, and thus, in order to increase the fault tolerance of the heartbeat request failure to prevent misjudgment, the electronic device configures the number of times, that is, when the number of times is less than or equal to a configured value, the electronic device attempts to continue to determine the state of the target client, rather than directly determining the target client as the offline state.
For example: the number of times may be configured to be 2 or 3.
Specifically, the number of times may be configured as n ═ e/t-1, where e is the cache validity period and t is the heartbeat cycle.
Therefore, in order to increase the fault tolerance of the heartbeat request failure, a longer e may be configured, but the larger the value of e is, the larger n is, and the larger the false judgment range is. Over a large run of data, n can be configured to be 2 or 3, at which time e takes a minimum value.
For example: when t is 30s, when n is 2, e is 91 s; when n is 3, e is 121 s.
In at least one embodiment of the present invention, after determining the state of the target client corresponding to the heartbeat parameter, the method further includes:
(1) and calculating the total time length of the target client in the online state within a preset time range.
(2) And calculating the number of online days of the target client in an online state in the preset time range, determining the total number of days included in the preset time range, and calculating the online rate of the target client in the preset time range according to the number of online days and the total number of days.
(3) And acquiring all the clients, judging the state of each client in all the clients, and determining the number of online clients in an online state and the number of offline clients in an offline state in all the clients according to the state of each client.
Through the fact mode, the online time, the online rate, the online quantity and the like of a single user can be respectively counted, the online condition of the client side is conveniently analyzed, and the abnormal condition is conveniently maintained in time.
In summary, the present invention can adopt a hypertext transfer protocol and/or a hypertext transfer security protocol to accept a heartbeat request when the heartbeat request is detected, so as to establish a connection with a short connection protocol, obtain a heartbeat parameter from the heartbeat request, further detect a target flag value corresponding to the heartbeat parameter in a cache server, obtain a detection result, and determine a state of a target client corresponding to the heartbeat parameter according to the detection result, thereby implementing effective determination of a client state under the short connection protocol.
Referring to fig. 2, in the present embodiment, the electronic device 1 is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device 1 may also be, but not limited to, any electronic product that can perform human-Computer interaction with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device, for example, a Personal Computer (PC), a tablet Computer, a smart phone, a Personal Digital Assistant (PDA), a game console, an interactive web Television (IPTV), an intelligent wearable device, a palm Computer, a portable Computer, an intelligent router, an mining machine, a network storage device terminal device, a desktop Computer, a cloud server, or other computing devices.
The Network where the electronic device 1 is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
The electronic device 1 may be a node constituting a content distribution network or a blockchain network.
The electronic device 1 may comprise a memory 12, a processor 13 and a bus, and may further comprise a computer program, such as a state decision program, stored in the memory 12 and executable on the processor 13.
It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the electronic device 1, and does not constitute a limitation to the electronic device 1, and may comprise more or less components than those shown, or some components may be combined, or different components, for example, the electronic device 1 may further comprise an input output device, a network access device, etc.
The memory 12 includes at least one type of readable storage medium, which includes flash memory, a removable hard drive, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like. The memory 12 may in some embodiments be an internal storage unit of the electronic device 1, for example a removable hard disk of the electronic device 1. The memory 12 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk provided on the electronic device 1, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and so on. Further, the memory 12 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 12 may be used not only to store application software installed in the electronic apparatus 1 and various types of data such as codes of a state determination program, but also to temporarily store data that has been output or is to be output.
The processor 13 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data Processing chip in some embodiments, and is used for executing program codes or Processing data stored in the memory 12, such as executing status determination programs.
The processor 13 executes an operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application program to implement the steps in the above-described respective state determination method embodiments, such as the steps S10, S11, S12, S13 shown in fig. 1.
Alternatively, the processor 13, when executing the computer program, implements the functions of the modules/units in the above device embodiments, for example: when a heartbeat request is detected, adopting a hypertext transfer protocol and/or a hypertext transfer security protocol to accept the heartbeat request; acquiring heartbeat parameters from the heartbeat request; detecting a target mark value corresponding to the heartbeat parameter in a cache server to obtain a detection result; and judging the state of the target client corresponding to the heartbeat parameter according to the detection result.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one arrow is shown in FIG. 2, but this does not indicate only one bus or one type of bus.
Illustratively, the computer program may be divided into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into an accepting unit 110, an acquiring unit 111, a detecting unit 112, a determining unit 113, a determining unit 114, a creating unit 115, a storing unit 116, a configuring unit 117, a calculating unit 118, and a constructing unit 119.
Further, the electronic device may further include a network interface, which may optionally include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), and is generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, the user interface may comprise a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface may further comprise a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
Fig. 2 shows only the electronic device 1 with the components 12-13, and the state decision program, and it will be understood by those skilled in the art that the structure shown in fig. 2 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
In conjunction with fig. 1, the memory 12 in the electronic device 1 stores a plurality of instructions to implement a state determination method, and the processor 13 executes the plurality of instructions to implement: when a heartbeat request is detected, adopting a hypertext transfer protocol and/or a hypertext transfer security protocol to accept the heartbeat request; acquiring heartbeat parameters from the heartbeat request; detecting a target mark value corresponding to the heartbeat parameter in a cache server to obtain a detection result; and judging the state of the target client corresponding to the heartbeat parameter according to the detection result.
According to a preferred embodiment of the present invention, the heartbeat parameter includes an identification of the target client, a type of the target client, and the processor 13 further executes a plurality of instructions including:
acquiring all connectable clients;
determining the identification and the type of each client in all the clients;
establishing a marking value of each client according to the identification and the type of each client;
storing each tag value in the cache server;
and configuring a heartbeat period and a caching period for each mark value.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
when the target mark value is detected to exist, determining that the target client is in an online state; or
When the target mark value is detected to be absent, determining that the target client is in an offline state.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
acquiring a target heartbeat cycle and a target caching period of the target mark value from the caching server;
calculating a difference value between the target cache validity period and the target heartbeat period;
and constructing a misjudgment time range corresponding to the state of the target client by taking the difference value as a minimum value and the target heartbeat period as a maximum value.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
acquiring the number of times of failure in receiving the heartbeat request;
and when the times are less than or equal to the configuration value, continuously judging the state of the target client.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
calculating the total time length of the target client in an online state within a preset time range; and/or
Calculating the number of online days of the target client in an online state in the preset time range, determining the total number of days included in the preset time range, and calculating the online rate of the target client in the preset time range according to the number of online days and the total number of days; and/or
And acquiring all the clients, judging the state of each client in all the clients, and determining the number of online clients in an online state and the number of offline clients in an offline state in all the clients according to the state of each client.
Fig. 3 is a functional block diagram of the state determination system according to the present invention. The state determination system 11 includes an accepting unit 110, an acquiring unit 111, a detecting unit 112, a determining unit 113, a determining unit 114, a establishing unit 115, a storing unit 116, a configuring unit 117, a calculating unit 118, and a constructing unit 119. The module/unit referred to in the present invention refers to a series of computer program segments that can be executed by the processor 13 and that can perform a fixed function, and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
When a heartbeat request is detected, the receiving unit 110 receives the heartbeat request by using a HyperText Transfer Protocol (HTTP) and/or a HyperText Transfer Protocol Security (HTTPs).
In at least one embodiment of the present invention, the heartbeat request is based on a heartbeat mechanism, which is a mechanism that sends a self-defined structure (heartbeat packet, i.e. the heartbeat request) periodically to let the other side know that the other side is still alive, so as to ensure the validity of the connection.
Specifically, the heartbeat request is typically a very small packet or a null packet that includes only a header.
In at least one embodiment of the present invention, the hypertext transfer protocol and/or hypertext transfer security protocol is a short connection protocol. Moreover, when the hypertext transfer protocol and/or the hypertext transfer security protocol are/is used for connection, the online or offline state of the client cannot be acquired, and the statistical analysis of the user use state or the client connection state cannot be performed.
In at least one embodiment of the invention, the method further comprises:
the obtaining unit 111 obtains all connectable clients, the determining unit 114 determines an identifier and a type of each client in all the clients, further, the establishing unit 115 establishes a tag value of each client according to the identifier and the type of each client, the storage unit 116 stores each tag value into a Cache server (Cache server), and the configuring unit 117 configures a heartbeat cycle and a Cache validity period for each tag value.
For example: the flag value may be configured as a key and may be a value. At this time, if the identifier of a client is a and the type of the client is x, the flag value of the client is set to a _ x.
Specifically, the cache server refers to a server storing frequently accessed content. The cache server can automatically clear redundant data, and avoids causing the shortage of server resources and influencing the normal operation of the server.
Further, the client initiates the heartbeat request periodically according to the heartbeat cycle, and the heartbeat cycle can be configured by user, which is not limited in the present invention. For example: the heartbeat period may be 30 seconds, 1 minute, 3 minutes, etc., and the length of the heartbeat period will affect the throughput of the heartbeat request and the delay of the offline status update.
Accordingly, in order to more effectively determine the status of the client, the cache validity period is configured to be a value greater than the heartbeat cycle. For example: when the heartbeat period is 30 seconds, the cache validity period may be configured to be 60 seconds.
In at least one embodiment of the invention, the identification of each client may include, but is not limited to, a combination of one or more of the following:
(1) in a product in a user login state, a client generally has a token (token) indicating a login identity, and through the token, the obtaining unit 111 may obtain a unique identifier such as a currently logged-in user id (identification) as an identifier of the client.
(2) In products without user login status, the configuration protocol is agreed, for example: for mobile devices such as mobile phones and tablet computers, the device number may be used as the identifier of the client, and for web browsers, the client IP (Internet Protocol Address) may be used as the identifier of the client.
In at least one embodiment of the present invention, since a user may be online on different types of devices such as a pc (personal computer) side, a Web browser (World Wide Web), a mobile phone app, a tablet app, and the like, when it is necessary to distinguish which terminal the user is online, the type of the client needs to be determined, and therefore, the establishing unit 115 establishes the tag value of each client with the type of the client as a parameter.
The obtaining unit 111 obtains the heartbeat parameter from the heartbeat request.
In at least one embodiment of the present invention, the heartbeat parameter is included in the heartbeat request.
Further, the heartbeat parameter includes an identification of a target client and a type of the target client.
The target client is the client which is performing state judgment.
The detection unit 112 detects the target mark value corresponding to the heartbeat parameter in the cache server, and obtains a detection result.
In at least one embodiment of the present invention, the detection result includes, but is not limited to, any one of the following cases:
(1) the target tag value is present.
(2) The target flag value is not present.
It is understood that, for different detection results, different judgments will be made on the status of the target client.
Based on the detection result, determining section 113 determines the state of the target client corresponding to the heartbeat parameter.
In at least one embodiment of the present invention, the determining unit 113, according to the detection result, determining the state of the target client corresponding to the heartbeat parameter includes:
(1) when detecting that the target flag value exists, the determination unit 113 determines that the target client is in an online state.
For example: when the key a _ x in the cache server exists, the determining unit 113 determines that a is currently online and the online device type is x.
(2) When detecting that the target flag value does not exist, the determination unit 113 determines that the target client is in an offline state.
For example: when the key a _ x in the cache server does not exist, the determination unit 113 determines that a is in an offline state on the device type x.
With the above embodiment, the determination unit 113 can automatically determine the state of the client.
In at least one embodiment of the present invention, after determining, according to the detection result, a state of the target client corresponding to the heartbeat parameter, the method further includes:
the obtaining unit 111 obtains a target heartbeat cycle and a target cache validity period of the target mark value from the cache server, the calculating unit 118 calculates a difference between the target cache validity period and the target heartbeat cycle, and the constructing unit 119 constructs a misjudgment time range corresponding to the state of the target client by using the difference as a minimum value and the target heartbeat cycle as a maximum value.
For example: after the target client is offline, a _ x in the cache server needs to wait for 60s (a heartbeat is sent just before offline) at the longest and expires after waiting for 30s (a heartbeat is ready to be sent just before offline) at the shortest, so that the target client is actually offline but is judged to be online in this period of time, a specific misjudgment time range m is related to the target heartbeat period t and the target cache validity period e, and the formula is as follows: e-t < m < e.
With the above-described embodiment, the determination unit 113 can tolerate delay in determining the offline state when determining the state of the client.
In at least one embodiment of the invention, the method further comprises:
the obtaining unit 111 obtains the number of times of failure in receiving the heartbeat request, and when the number of times is less than or equal to a configuration value, the determining unit 113 continues to determine the state of the target client.
It is to be understood that, if a certain heartbeat request process fails, the determination unit 113 may determine the client as an offline state, and therefore, in order to increase the fault tolerance of the heartbeat request failure to prevent misjudgment, the configuration unit 117 configures the number of times, that is, when the number of times is less than or equal to a configured value, the determination unit 113 attempts to continue to determine the state of the target client, rather than directly determining the target client as an offline state.
For example: the number of times may be configured to be 2 or 3.
Specifically, the number of times may be configured as n ═ e/t-1, where e is the cache validity period and t is the heartbeat cycle.
Therefore, in order to increase the fault tolerance of the heartbeat request failure, a longer e may be configured, but the larger the value of e is, the larger n is, and the larger the false judgment range is. Over a large run of data, n can be configured to be 2 or 3, at which time e takes a minimum value.
For example: when t is 30s, when n is 2, e is 91 s; when n is 3, e is 121 s.
In at least one embodiment of the present invention, after determining the state of the target client corresponding to the heartbeat parameter, the method further includes:
(1) the calculating unit 118 calculates a total duration of time that the target client is in an online state within a preset time range.
(2) The calculating unit 118 calculates the number of online days in which the target client is online within the preset time range, the determining unit 114 determines the total number of days included in the preset time range, and the calculating unit 118 calculates the online rate of the target client within the preset time range according to the number of online days and the total number of days.
(3) The obtaining unit 111 obtains all the clients, the determining unit 113 determines a state of each of the clients, and the determining unit 114 determines the number of online clients in an online state and the number of offline clients in an offline state according to the state of each of the clients.
Through the fact mode, the online time, the online rate, the online quantity and the like of a single user can be respectively counted, the online condition of the client side is conveniently analyzed, and the abnormal condition is conveniently maintained in time.
In summary, the present invention can adopt a hypertext transfer protocol and/or a hypertext transfer security protocol to accept a heartbeat request when the heartbeat request is detected, so as to establish a connection with a short connection protocol, obtain a heartbeat parameter from the heartbeat request, further detect a target flag value corresponding to the heartbeat parameter in a cache server, obtain a detection result, and determine a state of a target client corresponding to the heartbeat parameter according to the detection result, thereby implementing effective determination of a client state under the short connection protocol.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, removable hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that the above-mentioned numbers of the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments. And the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (9)

1. A state determination method, characterized by comprising:
when a heartbeat request is detected, adopting a hypertext transfer protocol and/or a hypertext transfer security protocol to accept the heartbeat request;
acquiring heartbeat parameters from the heartbeat request;
detecting a target mark value corresponding to the heartbeat parameter in a cache server to obtain a detection result;
judging the state of a target client corresponding to the heartbeat parameter according to the detection result;
acquiring the number of times of failure in receiving the heartbeat request;
and when the times are less than or equal to the configuration value, continuously judging the state of the target client.
2. The state decision method of claim 1, wherein the heartbeat parameter includes an identification of the target client, a type of the target client, the method further comprising:
acquiring all connectable clients;
determining the identification and the type of each client in all the clients;
establishing a marking value of each client according to the identification and the type of each client;
storing each tag value in the cache server;
and configuring a heartbeat period and a caching period for each mark value.
3. The state determination method according to claim 1, wherein the determining, according to the detection result, the state of the target client corresponding to the heartbeat parameter includes:
when the target mark value is detected to exist, determining that the target client is in an online state; or
When the target mark value is detected to be absent, determining that the target client is in an offline state.
4. The state determination method according to claim 2, wherein after determining the state of the target client corresponding to the heartbeat parameter according to the detection result, the method further comprises:
acquiring a target heartbeat cycle and a target caching period of the target mark value from the caching server;
calculating a difference value between the target cache validity period and the target heartbeat period;
and constructing a misjudgment time range corresponding to the state of the target client by taking the difference value as a minimum value and the target heartbeat period as a maximum value.
5. A state decision method according to claim 2 or 3, wherein after deciding the state of the target client corresponding to the heartbeat parameter, the method further comprises:
calculating the total time length of the target client in an online state within a preset time range; and/or
Calculating the number of online days of the target client in an online state in the preset time range, determining the total number of days included in the preset time range, and calculating the online rate of the target client in the preset time range according to the number of online days and the total number of days; and/or
The method comprises the steps of obtaining all clients, judging the state of each client in all the clients, and determining the number of online clients in an online state and the number of offline clients in an offline state according to the state of each client.
6. An electronic device, characterized in that the electronic device comprises:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the state decision method of any one of claims 1 to 5.
7. The electronic device of claim 6, wherein the electronic device is a node that constitutes a content distribution network or a blockchain network.
8. A state determination system, characterized in that the system comprises:
the receiving unit is used for receiving the heartbeat request by adopting a hypertext transfer protocol and/or a hypertext transfer security protocol when the heartbeat request is detected;
an obtaining unit, configured to obtain a heartbeat parameter from the heartbeat request;
the detection unit is used for detecting a target mark value corresponding to the heartbeat parameter in the cache server to obtain a detection result;
the judging unit is used for judging the state of the target client corresponding to the heartbeat parameter according to the detection result;
the acquiring unit is further configured to acquire the number of times that the heartbeat request fails to be accepted;
and the judging unit is further used for continuously judging the state of the target client when the times are less than or equal to a configuration value.
9. A computer-readable storage medium having stored thereon a state decision program executable by one or more processors to implement the state decision method of any one of claims 1 to 5.
CN201910272374.1A 2019-04-04 2019-04-04 State determination method, electronic device, system, and medium Active CN109981415B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910272374.1A CN109981415B (en) 2019-04-04 2019-04-04 State determination method, electronic device, system, and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910272374.1A CN109981415B (en) 2019-04-04 2019-04-04 State determination method, electronic device, system, and medium

Publications (2)

Publication Number Publication Date
CN109981415A CN109981415A (en) 2019-07-05
CN109981415B true CN109981415B (en) 2021-08-06

Family

ID=67083063

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910272374.1A Active CN109981415B (en) 2019-04-04 2019-04-04 State determination method, electronic device, system, and medium

Country Status (1)

Country Link
CN (1) CN109981415B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112953786B (en) * 2019-12-11 2022-09-16 中国电信股份有限公司 Information processing method, device, system and computer readable storage medium
CN111988080B (en) * 2020-08-24 2022-05-31 深圳市青柠互动科技开发有限公司 Satellite communication system and method
CN112311629B (en) * 2020-10-30 2022-04-26 广州华多网络科技有限公司 Data processing method, device, server and computer readable storage medium
CN112804301B (en) * 2020-12-30 2023-02-28 成都佳华物链云科技有限公司 Method and device for determining equipment state, gateway and storage medium
CN113183916B (en) * 2021-04-28 2023-03-24 安徽江淮汽车集团股份有限公司 Remote vehicle locking and anti-dismantling method, device, equipment and storage medium
CN113360384B (en) * 2021-06-12 2022-08-02 四川虹美智能科技有限公司 App operation stability protection method and device and computer readable medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106330595A (en) * 2015-07-02 2017-01-11 阿里巴巴集团控股有限公司 Heartbeat detection method and apparatus of distributed platform
CN107645529A (en) * 2016-07-21 2018-01-30 腾讯科技(深圳)有限公司 Heartbeat packet transmission method and device
CN107995024A (en) * 2017-10-30 2018-05-04 北京奇虎科技有限公司 A kind of device management method, device, server and storage medium
CN108449239A (en) * 2018-06-19 2018-08-24 广州视源电子科技股份有限公司 Heartbeat packet method, apparatus, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106330595A (en) * 2015-07-02 2017-01-11 阿里巴巴集团控股有限公司 Heartbeat detection method and apparatus of distributed platform
CN107645529A (en) * 2016-07-21 2018-01-30 腾讯科技(深圳)有限公司 Heartbeat packet transmission method and device
CN107995024A (en) * 2017-10-30 2018-05-04 北京奇虎科技有限公司 A kind of device management method, device, server and storage medium
CN108449239A (en) * 2018-06-19 2018-08-24 广州视源电子科技股份有限公司 Heartbeat packet method, apparatus, equipment and storage medium

Also Published As

Publication number Publication date
CN109981415A (en) 2019-07-05

Similar Documents

Publication Publication Date Title
CN109981415B (en) State determination method, electronic device, system, and medium
CN106936793B (en) Information interception processing method and terminal
US10182324B2 (en) Contextual deep linking of applications
US9836317B2 (en) Controlling virtualization resource utilization based on network state
WO2017190641A1 (en) Crawler interception method and device, server terminal and computer readable medium
WO2018219076A1 (en) Processing method for preventing webpage hijacking, client, and server
RU2631769C2 (en) Method and device for determining objective of information processing
CN112838952B (en) Data transmission method of baseboard management controller, BMC, server and medium
US10404808B2 (en) Secure, anonymous browsing with a remote browsing server
US11017013B2 (en) Image cache collaboration between clients in remote desktop environments
CN106899549B (en) Network security detection method and device
CN106790291B (en) Intrusion detection prompting method and device
CN110417789B (en) Server connection method, electronic device, system and medium
CN111343048A (en) Pressure testing method and device, computer device and storage medium
CN107026758B (en) Information processing method, information processing system and server for CDN service update
CN110677493B (en) Service state determination method and device, computer device and storage medium
EP2488938A1 (en) Data update for website users based on preset conditions
CN114095567B (en) Data access request processing method and device, computer equipment and medium
CN109547449B (en) Safety detection method and related device
CN112165445A (en) Method, device, storage medium and computer equipment for detecting network attack
CN111343176B (en) Network attack countering device, method, storage medium and computer equipment
US20160028641A1 (en) Advanced notification of workload
CN111245948A (en) DHT network connection method, electronic device, and medium
CN110808967B (en) Detection method for challenging black hole attack and related device
CN112019377A (en) Method, system, electronic device and storage medium for network user role identification

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