CN115396444A - Access control method, server and client - Google Patents

Access control method, server and client Download PDF

Info

Publication number
CN115396444A
CN115396444A CN202210971673.6A CN202210971673A CN115396444A CN 115396444 A CN115396444 A CN 115396444A CN 202210971673 A CN202210971673 A CN 202210971673A CN 115396444 A CN115396444 A CN 115396444A
Authority
CN
China
Prior art keywords
node
client
server
connection
access request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210971673.6A
Other languages
Chinese (zh)
Inventor
段新光
鹿飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lenovo Beijing Ltd
Original Assignee
Lenovo Beijing 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 Lenovo Beijing Ltd filed Critical Lenovo Beijing Ltd
Priority to CN202210971673.6A priority Critical patent/CN115396444A/en
Publication of CN115396444A publication Critical patent/CN115396444A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0631Management of faults, events, alarms or notifications using root cause analysis; using analysis of correlation between notifications, alarms or events based on decision criteria, e.g. hierarchy, tree or time analysis
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session

Abstract

The application discloses an access control method, a server and a client. The method comprises the following steps: determining whether the server side meets a preset condition; if the server side meets the preset conditions, sending an offline notification to the client side; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification includes a node identifier of the first node, and the node identifier is used for reestablishing the first connection between the client and the first node after the first connection is disconnected.

Description

Access control method, server and client
Technical Field
The application relates to an access control method, a server and a client.
Background
Load balancing refers to balancing loads (work tasks) and distributing the loads to a plurality of nodes for execution, so that the work tasks are completed cooperatively, the bandwidth of a server and network equipment can be expanded, the network data processing capacity is enhanced, the throughput is increased, and the availability and the flexibility of a network are improved.
Conventional server load balancing schemes mainly perform load balancing operations for short links, and these load balancing schemes cannot solve the load balancing problem in long-connection service scenarios such as long-term translation. After the service is restarted or redeployed, the original long connection request under the node is transferred to other nodes. Other nodes inherently have many long connection requests, and the long connection requests transferred from other nodes cause high load. And the load of the restarted nodes is very low, and the balance can be realized only in a long time, so that the resource utilization of the server is insufficient.
Disclosure of Invention
The application provides an access control method, a server and a client, and the technical scheme adopted by the embodiment of the application is as follows:
an access control method is applied to a server and comprises the following steps:
determining whether the server side meets a preset condition;
if the server side meets the preset condition, sending an offline notification to the client side; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification includes a node identifier of the first node, where the node identifier is used for the client to reestablish the first connection with the first node after the first connection is disconnected.
In some embodiments, the sending the offline notification to the client when the server side meets the preset condition includes:
and under the condition that the server side meets a preset condition, sending an offline notification to the client side through a process running on the server side.
In some embodiments, the sending the offline notification to the client when the server side meets the preset condition includes:
and sending the offline notification to the client under the condition that the server is abnormal, one or more processes running on the first node are abnormal, the first node is down or the first node is about to restart.
In some embodiments, the method further comprises:
receiving a first access request sent by the client; wherein the first access request contains the node identification;
and controlling the first node to reestablish the first connection with the client based on the first access request.
In some embodiments, the receiving a first access request sent by the client includes:
receiving the first access request sent by the client based on first address information; the first address information comprises second address information and the node identification, the second address information is used for the client to send a second access request, and the second access request is used for requesting the server to select a node based on a load balancing rule to be connected with the client.
In some embodiments, the method further comprises:
receiving a second access request sent by the client, wherein the second access request does not contain the node identifier;
and selecting a node from a plurality of nodes of the server side to be connected with the client side based on a load balancing rule.
In some embodiments, the selecting a node from a plurality of nodes of the server to construct a connection with the client based on the load balancing rule includes:
determining a system idle rate for a plurality of the nodes;
and selecting the node with the maximum system idle rate from the plurality of nodes to be connected with the client.
An access control method is applied to a client and comprises the following steps:
acquiring an offline notification sent by a server; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification comprises a node identifier of the first node;
and after the first connection is disconnected, sending a first access request containing the node identifier to the server side to request to reestablish the first connection with the first node.
A server, comprising:
the first determining module is used for determining whether the server side meets a preset condition;
the first sending module is used for sending an offline notification to the client under the condition that the server meets a preset condition; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification includes a node identifier of the first node, where the node identifier is used for the client to reestablish the first connection with the first node after the first connection is disconnected.
A client, comprising:
the second receiving module is used for obtaining the offline notification sent by the server; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification comprises a node identifier of the first node;
and the second sending module is used for sending a first access request containing the node identifier to the server side after the first connection is disconnected so as to request to reestablish the first connection with the first node.
According to the access control method, whether the first connection between the client and the first node is disconnected or about to be disconnected is determined by determining whether the server meets the preset condition, if the server meets the preset condition, the first connection between the client and the first node is disconnected or about to be disconnected, and the offline notification comprising the node identification of the first node is sent to the client. And if the client needs to establish the first connection with the server within the preset time, sending an access request to the server based on the node identifier, and the server can reestablish the first connection between the client and the first node based on the node identifier. Therefore, the phenomenon that loads of all nodes of the server are unbalanced due to the fact that the loads of the first node are distributed to other nodes can be avoided, and the overall performance and the stability of the server are improved.
Drawings
Fig. 1 is a flowchart of an access control method according to a first embodiment of the present application;
fig. 2 is a flowchart of an access control method according to a second embodiment of the present application;
fig. 3 is a flowchart of step S220 in the access control method according to the second embodiment of the present application;
fig. 4 is a flowchart of an access control method according to a third embodiment of the present application;
fig. 5 is a block diagram of a server according to a fourth embodiment of the present application;
fig. 6 is a block diagram of a client according to a fifth embodiment of the present application.
Detailed Description
Various aspects and features of the present application are described herein with reference to the drawings.
It will be understood that various modifications may be made to the embodiments of the present application. Accordingly, the foregoing description should not be construed as limiting, but merely as exemplifications of embodiments. Those skilled in the art will envision other modifications within the scope and spirit of the application.
The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the application and, together with a general description of the application given above and the detailed description of the embodiments given below, serve to explain the principles of the application.
These and other characteristics of the present application will become apparent from the following description of preferred forms of embodiment, given as non-limiting examples, with reference to the attached drawings.
It should also be understood that, although the present application has been described with reference to some specific examples, a person of skill in the art shall certainly be able to achieve many other equivalent forms of application, having the characteristics as set forth in the claims and hence all coming within the field of protection defined thereby.
The above and other aspects, features and advantages of the present application will become more apparent in view of the following detailed description when taken in conjunction with the accompanying drawings.
Specific embodiments of the present application are described hereinafter with reference to the accompanying drawings; however, it is to be understood that the disclosed embodiments are merely exemplary of the application, which can be embodied in various forms. Well-known and/or repeated functions and constructions are not described in detail to avoid obscuring the application of unnecessary or unnecessary detail. Therefore, specific structural and functional details disclosed herein are not to be interpreted as limiting, but merely as a basis for the claims and as a representative basis for teaching one skilled in the art to variously employ the present application in virtually any appropriately detailed structure.
The specification may use the phrases "in one embodiment," "in another embodiment," "in yet another embodiment," or "in other embodiments," which may each refer to one or more of the same or different embodiments in accordance with the application.
A first embodiment of the present application provides an access control method, which is applied to a server, where the server may be hardware or software. When the server is hardware, the server can be implemented as a distributed server cluster formed by a plurality of servers, or can be implemented as a single server. When the server is software, it may be implemented as a plurality of software or software modules (for example, to provide distributed services), or may be implemented as a single software or software module, and is not limited in this respect.
Fig. 1 is a flowchart of an access control method according to a first embodiment of the present application, and referring to fig. 1, the access control method according to the embodiment of the present application may specifically include the following steps.
And S110, determining whether the server meets a preset condition.
Optionally, the server may set a plurality of nodes, where a node is actually a service node for providing a service to the client. After obtaining the access request, the server generally distributes the access request to each node, and responds to the client access request through the node. The nodes may be formed by physical devices, or may be formed by virtual devices such as virtual machines or containers. If multiple data transfers are required between the client and the node in a short time, a first connection, i.e. a long connection, may be established between the client and the node.
Optionally, the first node may be any one of a plurality of nodes, and if a first connection is established between the first node and the client, the client and the first node can transmit data in a plurality of ways based on the first connection. The preset condition may be used to characterize that the first connection between the client and the first node has been disconnected or is about to be disconnected. In specific implementation, the preset condition may include one or more conditions, and in a case that any one condition is triggered, the server may be considered to satisfy the preset condition.
Optionally, whether the server side is abnormal or not may be determined, and if it is determined that the server side is abnormal, it may be determined that the server side meets a preset condition. For example, it may be determined whether an exception occurs in hardware of the server, whether an exception occurs in software of the server, whether an exception occurs in a network connection of the server, and so on. For example, when the server is provided with a monitoring system for monitoring the running state, it is determined whether the monitoring system gives an abnormal alarm, and when the monitoring system gives an abnormal alarm, it is determined that the server is about to be abnormal or has been abnormal, and it is determined that the server meets the preset conditions.
It should be noted that the exception occurring at the server may include a burst exception behavior, and may also include a non-burst exception behavior such as a periodic operation and maintenance operation, a system update, and the like. For example, based on the operation and maintenance plan or the administrator instruction, it is determined that the server is about to perform system update and can cause disconnection of the first connection, and it is determined that the server is about to generate an abnormality, and it is determined that the server satisfies the preset condition.
Optionally, it may also be determined whether the first node is abnormal. Alternatively, it may be determined that one or more of the following actions exist: and if one or more of the behaviors exist, determining that the first node is abnormal, and determining that the server side meets the preset condition. For example, if it is determined that one or more processes related to the first connection in the first node are abnormally operated, it may be determined that the server satisfies a preset condition. For example, if the monitoring system determines that the first node has an operation failure and is down, it may be determined that the server satisfies the preset condition. For another example, based on an administrator instruction or an operation and maintenance plan, it is determined that the first node needs to perform system update and needs to be restarted, which may result in disconnection of the first connection, and it may be determined that the server side meets the preset condition.
S120, if the server side meets the preset condition, sending an offline notification to the client side.
Optionally, the offline notification includes a node identifier of the first node, where the node identifier is used to reestablish the first connection between the client and the first node after the first connection is disconnected. Optionally, the offline notification may be used to instruct the client to: and if the first connection is required to be reestablished with the server within the preset time, sending an access request to the server based on the node identification, so that the server reestablishes the first connection between the client and the first node based on the node identification.
Optionally, the node identification may be used to uniquely identify the identity of the first node. The node identification may include various information capable of uniquely identifying the first node, such as a node number, address information, device code, and the like. For example, the node code of the first node may be "a001", and in a case that it is determined that the server side satisfies the preset condition, "a001" may be sent to the client side as the node identifier.
According to the access control method, whether the first connection between the client and the first node is disconnected or about to be disconnected is determined by determining whether the server meets the preset condition, if the server meets the preset condition, the first connection between the client and the first node is disconnected or about to be disconnected, and the offline notification comprising the node identification of the first node is sent to the client. And if the client needs to establish the first connection with the server within the preset time, sending an access request to the server based on the node identifier, and the server can reestablish the first connection between the client and the first node based on the node identifier. Therefore, the phenomenon that loads of all nodes of the server are unbalanced due to the fact that the loads of the first node are distributed to other nodes can be avoided, and the overall performance and stability of the server are improved.
In some embodiments, in step 120, when the server side meets the preset condition, the offline notification is sent to the client side, which may specifically include the following steps.
And under the condition that the server side meets a preset condition, sending an offline notification to the client side through a process running on the server side.
Optionally, a daemon process, for example, may be run on the server to monitor the overall running state of the server, or monitor the running state of one or more nodes. In the case where the preset condition is not triggered, the daemon process is usually in a background running state. And when the server side meets the preset condition, sending an offline notification to the client side through the daemon process. Therefore, the access control method of the embodiment of the application can be realized under the condition of avoiding influencing the normal operation of the server as much as possible.
Optionally, the process may be executed on a load balancing module of the server, for example, or may be executed on each node. For example, a daemon process may run on the load balancing module to monitor each node identically. And running daemon processes on each node when each node is started so as to monitor the running state of the node through the daemon processes of the node.
In some embodiments, the method further comprises the following steps.
S130, receiving a first access request sent by the client; wherein the first access request contains the node identification.
S140, controlling the first node to reestablish the first connection with the client based on the first access request.
Optionally, the offline notification may be used to instruct the client to switch the access mode from the regular access mode to the offline reconnection mode, and maintain the offline reconnection mode within a preset time. In a normal access mode, a client side can send an access request without a node identifier, and a server side selects a node to respond to the access request of the client side based on a preset rule under the condition that the server side receives the access request. In the offline reconnection mode, if the client needs the server to establish the first connection, the client sends a first access request containing the node identifier to the server. And the server receives the first access request, calls a corresponding pair of first nodes based on the node identifiers if the first access request is identified to contain the node identifiers, and controls the first nodes and the client to reestablish the first connection. A feasible implementation mode is provided for the long connection reestablishment between the client and the first node, so that after the long connection is disconnected, the client can smoothly reestablish the long connection with the first node which is originally connected with the client, the load on the first node is prevented from being distributed to other nodes, and the phenomenon of load imbalance of the server is further avoided.
In some embodiments, the step S130 of receiving the first access request sent by the client may include the following steps.
Receiving the first access request sent by the client based on first address information; the first address information comprises second address information and the node identification, the second address information is used for the client to send a second access request, and the second access request is used for requesting the server to select a node based on a load balancing rule to be connected with the client.
Optionally, in the normal access mode, the client may send a second access request to the server based on the second address information, and request the server to provide a service. And under the condition that the server receives the second access request, selecting a node from a plurality of nodes of the server to establish connection with the client based on a load balancing rule. The second address information may include address information, such as a URL address, an IP address, a port number, etc., that can uniquely identify the server and the service type.
Optionally, in the offline reconnection mode, the client may form the first address information based on a combination of the second address information and the node identifier. Taking the second address information as a URL address as an example, the node identifier may be added in front of, in the middle of, or behind the URL address to form the first address information. Based on the first address information, a first access request can be sent to the server. For example, the second address information may be "https:// www.abcd.com/event", the node identification may be "a001", and the first address information may be "https:// www.abcd.com/event/a001". The method does not need to modify the protocol, is simple to operate and is easy to realize.
In some embodiments, the method may further comprise the following steps.
S150, receiving a second access request sent by the client, wherein the second access request does not contain the node identifier.
And S160, selecting a node from the plurality of nodes of the server to be connected with the client on the basis of a load balancing rule.
Optionally, in a normal state, the client may be configured to be in a normal access mode, and when the client accesses the server for the first time, the client may send, to the server, a second access request that does not include the node identifier based on the second address information. For example, the client may access the server directly based on this URL address of "https:// www.abcd.com/event". Or, after the client is switched to the offline reconnection mode, if the client does not access the server within the preset time or does not request the server to preset and establish the long connection, the client can automatically switch the access mode back to the conventional access mode. Thereafter, if the client requests access to the server, a second access request may be sent to the server based on the second address information.
Optionally, after receiving the second access request, if the node identifier is not identified in the second access request, the server may select a node from the multiple nodes to establish a connection with the client based on a load balancing rule. For example, the server may be provided with a load balancing module, and the load balancing module may be used for load distribution. After receiving the access request, the server detects whether the access request contains a node identifier in a preset format or not through the load balancing module, if the access request contains the node identifier, the corresponding node is controlled to be connected with the client again on the basis of the node identifier, and if the access request does not contain the node identifier, the node is reselected from a plurality of nodes on the basis of a load balancing rule to respond to the access request of the client and provide service for the client.
In some embodiments, the step S160 of selecting a node from the plurality of nodes of the server to establish a connection with the client based on the load balancing rule may include the following steps.
S161, determining the system idle rate of a plurality of nodes.
And S162, selecting the node with the maximum system idle rate from the plurality of nodes to establish connection with the client.
Optionally, the system idle rate is used to characterize the idle processing capability of the node. The system idle rate may include an idle usage rate of the processor or an idle rate of the memory, and the system idle rate may also include a ratio of a difference between an upper limit value of a connection number of the node and a current connection number to the upper limit value of the connection number of the node, or the system idle rate may also include a ratio of a difference between the upper limit value of a process number of the node and the current process number to the upper limit value of the process number of the node.
Optionally, the system idle rate of each node may be detected by the load balancing module. For example, the load balancing module may periodically poll the various nodes. For example, when the load balancing module allocates the access request to each node, the load balancing module may record the number of connections of each node, and determine the system idle rate of each node according to the number of connections.
Optionally, under the condition that the system idle rate of each node is determined, the node with the largest system idle rate is still selected from the nodes through the load balancing module to be connected with the client, so as to realize load balancing of the server. For example, the load balancing module sorts the nodes in a sequence from large to small based on the system idle rate, and selects one or more nodes at the top in the sequence to establish connection with the client. Therefore, a better load balancing effect can be realized.
The second embodiment of the present application further provides an access control method, which is applied to a client, where the client may be hardware or software. When the client is hardware, the client may be various electronic devices capable of establishing a long connection with the server, including but not limited to a smart phone, a tablet computer, a desktop computer, and the like. When the client is software, the client can be installed in the electronic device listed above. It may be implemented as a plurality of software or software modules, or may be implemented as a single software or software module, and is not particularly limited herein.
Fig. 2 is a flowchart of an access control method according to a second embodiment of the present application, and referring to fig. 2, the access control method according to the second embodiment of the present application may specifically include the following steps.
S210, obtaining the offline notification sent by the server. The client and the first node of the server can transmit data for multiple times through the first connection. The offline notification contains the node identification of the first node.
Optionally, the server may set a plurality of nodes, where a node is actually a service node for providing a service to the client. After obtaining the access request, the server generally distributes the access request to each node, and responds to the client access request through the node. The nodes may be formed by physical devices, or may be formed by virtual devices such as virtual machines or containers. If multiple data transfers are required between the client and the node in a short time, a first connection, i.e. a long connection, may be established between the client and the node. The first node may be any one of a plurality of nodes, and if a first connection is established between the first node and the client, the client and the first node are capable of transmitting data in a plurality of ways based on the first connection.
Optionally, the server may send an offline notification to the client when determining that the server meets the preset condition. The preset condition may be used to characterize that the first connection between the client and the first node has been disconnected or is about to be disconnected. Optionally, the offline notification may be used to instruct the client to: and if the first connection is required to be reestablished with the server within the preset time, sending an access request to the server based on the node identification, so that the server reestablishes the first connection between the client and the first node based on the node identification.
Optionally, the node identification may be used to uniquely identify the identity of the first node. The node identification may include various information capable of uniquely identifying the first node, such as a node number, address information, device code, and the like. For example, the node code of the first node may be "a001", and in a case that it is determined that the server satisfies the preset condition, the "a001" may be sent to the client as the node identifier.
S220, after the first connection is disconnected, sending a first access request containing the node identifier to the server to request to reestablish the first connection with the first node.
Optionally, the client acquires the offline notification, and if the first connection needs to be reestablished with the server within the preset time, the first access request may be sent to the server based on the node identifier in the offline notification. The first access request may include a node identifier to inform the server of a node identity for establishing the first connection with the client before the first connection is disconnected.
Optionally, the server receives the first access request, and if it is recognized that the first access request includes a node identifier, invokes a corresponding pair of first nodes based on the node identifier, and controls the first nodes to reestablish the first connection with the client.
According to the access control method, the client can establish the first connection with the first node in the server, and if the first connection is disconnected or is about to be disconnected, the client can obtain the offline notification sent by the server, wherein the offline notification comprises the node identification of the first node. After the first connection is disconnected, if the client needs to reestablish the first connection with the server, a first access request containing the node identifier may be sent to the server, so that the server can control the first node and the client to reestablish the first connection based on the node identifier. Therefore, the phenomenon that loads of all nodes of the server are unbalanced due to the fact that the loads of the first node are distributed to other nodes can be avoided, and the overall performance and stability of the server are improved.
As shown in fig. 3, in some embodiments, step S220 of sending a first access request including the node identifier to the server to request to reestablish the first connection with the first node may include the following steps.
And modifying the state information of the client based on the offline notification so as to switch the access mode of the client to an offline reconnection mode.
And in the offline reconnection mode, sending a first access request to the server based on the node identification so as to request to reconstruct a first connection with the first node.
Optionally, the offline notification may be used to instruct the client to switch the access mode from the regular access mode to the offline reconnection mode, and maintain the offline reconnection mode within a preset time. In a normal access mode, a client side can send an access request without a node identifier, and a server side selects a node to respond to the access request of the client side based on a preset rule under the condition that the server side receives the access request. In the offline reconnection mode, if the client needs the server to establish a first connection, a first access request containing the node identifier is sent to the server. And the server receives the first access request, calls a corresponding pair of first nodes based on the node identification if the node identification is identified to be contained in the first access request, and controls the first nodes and the client to reestablish the first connection. A feasible implementation mode is provided for the long connection reestablishment between the client and the first node, so that after the long connection is disconnected, the client can smoothly reestablish the long connection with the first node which is originally connected with the client, the load on the first node is prevented from being distributed to other nodes, and the phenomenon of load imbalance of the server is further avoided.
As shown in fig. 3, in some embodiments, in the offline reconnection mode, sending a first access request to the server based on the node identifier to request to reconstruct a long connection with the restarted first node, where the method may include the following steps.
And under the offline reconnection mode, determining whether the first connection needs to be reconstructed with the server side.
And if so, sending a first access request to the server based on the node identification to request to reconstruct a first connection with the first node.
Optionally, the client may determine whether the first connection needs to be reestablished with the server based on the currently executed operation. For example, based on the current service type of the client, it is determined whether data interaction with the server based on the long connection is required, if so, it is determined that the first connection needs to be reconstructed with the server, and if not, it is determined that the first connection does not need to be reconstructed with the server.
Optionally, the client may also determine, based on the history, whether the first access request has been sent to the server after receiving the offline notification, if so, determine that the first access request does not need to be repeatedly sent to the server, and if not, determine that the first connection needs to be reestablished with the server, and need to send the first access request to the server.
In some embodiments, step S220 of sending a first access request including the node identifier to the server to request to reestablish the first connection with the first node may include the following steps.
Generating first address information based on the node identification and the second address information; the second address information is used for sending a second access request, and the second access request is used for requesting the server to select a node and establish connection with the client based on a load balancing rule.
And sending the first access request containing the node identification to the server side based on the first address information.
Optionally, in the normal access mode, the client may send a second access request to the server based on the second address information, and request the server to provide a service. And under the condition that the server receives the second access request, selecting a node from a plurality of nodes of the server to establish connection with the client based on a load balancing rule. The second address information may include address information, such as a URL address, an IP address, a port number, etc., that can uniquely identify the server and the service type.
Optionally, in the offline reconnection mode, the client may form the first address information based on a combination of the second address information and the node identifier. Taking the second address information as a URL address as an example, the node identifier may be added in front of, in the middle of, or behind the URL address to form the first address information. Based on the first address information, a first access request can be sent to the server. For example, the second address information may be "https:// www.abcd.com/event", the node identification may be "a001", and the first address information may be "https:// www.abcd.com/event/a001". The method does not need to modify the protocol, is simple to operate and is easy to realize.
In some embodiments, the method may further comprise the following steps.
And S230, under the condition that the long connection between the client and the restarted first node is reestablished, or after the preset time of the offline notification is obtained, modifying the state information of the client to switch the access mode of the client to a conventional access mode.
In the normal access mode, the client can send a second access request which does not contain a node identifier to the server, and the second access request is used for requesting the server to select a node based on a load balancing rule to establish connection with the client.
Optionally, in a normal state, the client may be configured to be in a normal access mode, and when the client accesses the server for the first time, the client may send, to the server, a second access request that does not include the node identifier based on the second address information. For example, the client may access the server directly based on this URL address of "https:// www.abcd.com/event". Or, after the client is switched to the offline reconnection mode, if the client does not access the server within the preset time or does not request the server to preset and establish the long connection, the client may automatically switch the access mode back to the normal access mode. Thereafter, if the client requests access to the server, a second access request may be sent to the server based on the second address information.
Optionally, after receiving the second access request, if the node identifier is not identified in the second access request, the server may select a node from the multiple nodes to establish a connection with the client based on a load balancing rule. For example, the server may be provided with a load balancing module, and the load balancing module may be used for load distribution. After receiving the access request, the server detects whether the access request contains a node identifier in a preset format or not through the load balancing module, if the access request contains the node identifier, the corresponding node is controlled to be connected with the client again on the basis of the node identifier, and if the access request does not contain the node identifier, the node is reselected from a plurality of nodes on the basis of the load balancing rule to respond to the access request of the client and provide service for the client.
Referring to fig. 4, a third embodiment of the present application further provides an access control method, which is applied to a client and a server.
S301, the client sends a second access request to the server based on the second address information, wherein the second access request does not contain node information for identifying the node of the server.
Optionally, the client may have two access modes, a normal access mode and a down reconnection mode, and the client may default to the normal access mode. In the normal access mode, the client can send a second access request which does not contain a node identifier to the server based on second address information, and the second access request is used for requesting the server to select a node based on a load balancing rule to establish connection with the client. For example, the client may access the server directly based on this URL address of "https:// www.abcd.com/event".
S302, the server selects a first node from the plurality of nodes based on a load balancing rule to establish a first connection with the client. Wherein the client and the first node are capable of transmitting data multiple times over the first connection.
Optionally, after receiving the second access request, if the node identifier is not identified in the second access request, the server may select a node from the multiple nodes to establish a connection with the client based on a load balancing rule. For example, the server may be provided with a load balancing module, and the load balancing module may be used for load distribution. After receiving the access request, the server detects whether the access request contains a node identifier in a preset format or not through the load balancing module, if the access request contains the node identifier, the corresponding node is controlled to be connected with the client again on the basis of the node identifier, and if the access request does not contain the node identifier, the node is reselected from a plurality of nodes on the basis of a load balancing rule to respond to the access request of the client and provide service for the client.
S303, the server determines whether the server meets the preset condition.
Optionally, the preset condition may be used to characterize that the first connection between the client and the first node has been disconnected or is about to be disconnected. In specific implementation, the preset condition may include one or more conditions, and in a case that any one condition is triggered, the server may be considered to satisfy the preset condition.
Optionally, whether the server side is abnormal or not may be determined, and if it is determined that the server side is abnormal, it may be determined that the server side meets a preset condition. For example, it may be determined whether an exception occurs in hardware of the server, whether an exception occurs in software of the server, whether an exception occurs in a network connection of the server, and so on. For example, when the server is provided with a monitoring system, whether the monitoring system gives an abnormal alarm or not is determined, and when the monitoring system gives an abnormal alarm, the server can be determined to be abnormal or already abnormal, and the server is determined to meet the preset condition.
Note that the abnormal occurrence at the server may include a burst abnormal behavior, and may also include a non-burst abnormal behavior such as a periodic operation and maintenance operation and a system update. For example, based on the operation and maintenance plan or the administrator instruction, it is determined that the server is about to perform system update and can cause disconnection of the first connection, and it is determined that the server is about to generate an abnormality, and it is determined that the server satisfies the preset condition.
Optionally, it may also be determined whether the first node is abnormal. Alternatively, it may be determined that one or more of the following actions exist: and if one or more of the behaviors exist, determining that the first node is abnormal, and determining that the server side meets the preset condition. For example, if it is determined that one or more processes related to the first connection in the first node are abnormally operated, it may be determined that the server side satisfies a preset condition. For example, if the monitoring system determines that the first node has an operation failure and is down, it may be determined that the server satisfies the preset condition. For another example, based on an administrator instruction or an operation and maintenance plan, it is determined that the first node needs to perform system update and needs to be restarted, which may result in disconnection of the first connection, and it may be determined that the server side meets the preset condition.
S304, if the server side determines that the server side meets the preset condition, sending an offline notification to the client side; wherein the logout notification comprises a node identifier of the first node.
Optionally, the offline notification includes a node identifier of the first node, where the node identifier is used to reestablish the first connection between the client and the first node after the first connection is disconnected. Optionally, the offline notification may be used to instruct the client to: and if the first connection is required to be reestablished with the server within the preset time, sending an access request to the server based on the node identification, so that the server reestablishes the first connection between the client and the first node based on the node identification.
Optionally, the node identification may be used to uniquely identify the identity of the first node. The node identification may include various information capable of uniquely identifying the first node, such as a node number, address information, device code, and the like. For example, the node code of the first node may be "a001", and in a case that it is determined that the server side satisfies the preset condition, "a001" may be sent to the client side as the node identifier.
S305, the client modifies the state information of the client based on the offline notification so as to switch the access mode of the client to an offline reconnection mode.
Optionally, the offline notification may be used to instruct the client to switch the access mode from the regular access mode to the offline reconnection mode, and maintain the offline reconnection mode within a preset time. In a normal access mode, a client side can send an access request without a node identifier, and a server side selects a node to respond to the access request of the client side based on a preset rule under the condition that the server side receives the access request. In the offline reconnection mode, if the client needs the server to establish the first connection, the client sends a first access request containing the node identifier to the server.
S306, the client sends a first access request to the server based on the node identification in the offline reconnection mode so as to request to reconstruct a first connection with the first node.
Optionally, the client may determine whether to reconstruct the first connection with the server in the offline reconnection mode. And if so, sending a first access request to the server based on the node identification to request to reconstruct a first connection with the first node. For example, the client may determine whether the first connection needs to be reestablished with the server based on the currently performed operation. And if the data needs to be interacted with the server side based on the long connection, determining that the first connection needs to be reconstructed with the server side, and if the data does not need to be reconstructed with the server side, determining that the first connection does not need to be reconstructed with the server side. For another example, the client may also determine, based on the history, whether the first access request has been sent to the server after receiving the offline notification, and if so, determine that the first access request does not need to be repeatedly sent to the server, and if not, determine that the first connection needs to be reestablished with the server, and need to send the first access request to the server.
S307, the server controls the first node and the client to reestablish the first connection based on the first access request.
Optionally, the server receives the first access request, and if it is recognized that the first access request includes the node identifier, calls a corresponding pair of first nodes based on the node identifier, and controls the first nodes and the client to reestablish the first connection.
S308, modifying the state information of the client side to switch the access mode of the client side to a conventional access mode under the condition that the long connection between the client side and the restarted first node is reestablished or after the preset time of the offline notification is obtained.
According to the access control method, the client can establish the first connection with the first node in the server, and if the first connection is disconnected or is about to be disconnected, the client can obtain the offline notification sent by the server, wherein the offline notification comprises the node identification of the first node. After the first connection is disconnected, if the client needs to reestablish the first connection with the server, a first access request containing the node identifier may be sent to the server, so that the server can control the first node and the client to reestablish the first connection based on the node identifier. Therefore, the phenomenon that loads of all nodes of the server are unbalanced due to the fact that the loads of the first node are distributed to other nodes can be avoided, and the overall performance and stability of the server are improved.
Referring to fig. 5, a fourth embodiment of the present application provides a server, including:
a first determining module 401, configured to determine whether a server meets a preset condition;
a first sending module 402, configured to send an offline notification to a client when the server meets a preset condition; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification includes a node identifier of the first node, where the node identifier is used for the client to reestablish the first connection with the first node after the first connection is disconnected.
In some embodiments, the first sending module 402 is specifically configured to:
and under the condition that the server side meets a preset condition, sending an offline notification to the client side through a process running on the server side.
In some embodiments, the first sending module 402 is specifically configured to:
and sending the offline notification to the client under the condition that the server is abnormal, one or more processes running on the first node are abnormal, the first node is down or the first node is about to restart.
In some embodiments, the server further comprises:
the first receiving module is used for receiving a first access request sent by the client; wherein the first access request contains the node identification;
and the load balancing module is used for controlling the first node and the client to reestablish the first connection based on the first access request.
In some embodiments, the first receiving module is specifically configured to:
receiving the first access request sent by the client based on first address information; the first address information comprises second address information and the node identification, the second address information is used for the client to send a second access request, and the second access request is used for requesting the server to select a node based on a load balancing rule to establish connection with the client.
In some embodiments, the server further comprises:
a first receiving module, configured to receive a second access request sent by the client, where the second access request does not include the node identifier;
and the load balancing module is used for selecting a node from the plurality of nodes of the server side to be connected with the client side based on a load balancing rule.
In some embodiments, the load balancing module is specifically configured to:
determining a system idle rate for a plurality of the nodes;
and selecting the node with the maximum system idle rate from the plurality of nodes to be connected with the client.
Referring to fig. 6, a fifth embodiment of the present application provides a client, including:
a second receiving module 501, configured to obtain an offline notification sent by a server; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification comprises a node identifier of the first node;
a second sending module 502, configured to send a first access request including the node identifier to the server after the first connection is disconnected, so as to request to reestablish the first connection with the first node.
In some embodiments, the second sending module 502 is specifically configured to:
modifying the state information of the client based on the offline notification to switch the access mode of the client to an offline reconnection mode;
and in the offline reconnection mode, sending a first access request to the server based on the node identification so as to request to reconstruct a first connection with the first node.
In some embodiments, the second sending module 502 is specifically configured to:
determining whether a first connection needs to be reconstructed with a server side in the offline reconnection mode;
and if so, sending a first access request to the server based on the node identification to request to reconstruct a first connection with the first node.
In some embodiments, the second sending module 502 is specifically configured to:
generating first address information based on the node identification and the second address information; the second address information is used for sending a second access request, and the second access request is used for requesting the server to select a node and establish connection with the client based on a load balancing rule;
and sending the first access request containing the node identification to the server side based on the first address information.
In some embodiments, the second sending module 502 is further configured to:
and modifying the state information of the client side to switch the access mode of the client side to a conventional access mode under the condition that the long connection between the client side and the restarted first node is reestablished or after the preset time of the offline notification is obtained.
The above embodiments are only exemplary embodiments of the present application, and are not intended to limit the present application, and the protection scope of the present application is defined by the claims. Various modifications and equivalents may be made by those skilled in the art within the spirit and scope of the present application and such modifications and equivalents should also be considered to be within the scope of the present application.

Claims (10)

1. An access control method is applied to a server and comprises the following steps:
determining whether the server side meets a preset condition;
if the server side meets the preset condition, sending an offline notification to a client side; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification includes a node identifier of the first node, where the node identifier is used for the client to reestablish the first connection with the first node after the first connection is disconnected.
2. The access control method according to claim 1, wherein the sending a logoff notification to the client when the server side meets a preset condition includes:
and under the condition that the server side meets a preset condition, sending an offline notification to the client side through a process running on the server side.
3. The access control method according to claim 1, wherein the sending a logoff notification to the client when the server side meets a preset condition includes:
and sending the offline notification to the client when the server is determined to be abnormal, one or more processes running on the first node are abnormal, the first node is down or the first node is about to restart.
4. The access control method of claim 1, the method further comprising:
receiving a first access request sent by the client; wherein the first access request contains the node identification;
and controlling the first node to reestablish the first connection with the client based on the first access request.
5. The access control method of claim 4, wherein the receiving a first access request sent by the client comprises:
receiving the first access request sent by the client based on first address information; the first address information comprises second address information and the node identification, the second address information is used for the client to send a second access request, and the second access request is used for requesting the server to select a node based on a load balancing rule to establish connection with the client.
6. The access control method of claim 1, the method further comprising:
receiving a second access request sent by the client, wherein the second access request does not contain the node identification;
and selecting a node from a plurality of nodes of the server side to be connected with the client side based on a load balancing rule.
7. The access control method according to claim 6, wherein the selecting a node from the plurality of nodes of the server to establish a connection with the client based on the load balancing rule comprises:
determining a system idle rate for a plurality of the nodes;
and selecting the node with the maximum system idle rate from the plurality of nodes to be connected with the client.
8. An access control method is applied to a client and comprises the following steps:
acquiring an offline notification sent by a server; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification comprises a node identifier of the first node;
and after the first connection is disconnected, sending a first access request containing the node identifier to the server side to request to reestablish the first connection with the first node.
9. A server, comprising:
the first determining module is used for determining whether the server meets a preset condition;
the first sending module is used for sending an offline notification to the client under the condition that the server meets a preset condition; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification includes a node identifier of the first node, where the node identifier is used for the client to reestablish the first connection with the first node after the first connection is disconnected.
10. A client, comprising:
the second receiving module is used for obtaining an offline notification sent by the server; the method comprises the steps that a first connection is established between a client and a first node of a server, and the client and the first node can transmit data for multiple times through the first connection; the offline notification comprises a node identifier of the first node;
and the second sending module is used for sending a first access request containing the node identifier to the server side after the first connection is disconnected so as to request to reestablish the first connection with the first node.
CN202210971673.6A 2022-08-12 2022-08-12 Access control method, server and client Pending CN115396444A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210971673.6A CN115396444A (en) 2022-08-12 2022-08-12 Access control method, server and client

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210971673.6A CN115396444A (en) 2022-08-12 2022-08-12 Access control method, server and client

Publications (1)

Publication Number Publication Date
CN115396444A true CN115396444A (en) 2022-11-25

Family

ID=84119035

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210971673.6A Pending CN115396444A (en) 2022-08-12 2022-08-12 Access control method, server and client

Country Status (1)

Country Link
CN (1) CN115396444A (en)

Similar Documents

Publication Publication Date Title
US9262287B2 (en) Computer information system and dynamic disaster recovery method therefor
US7225356B2 (en) System for managing operational failure occurrences in processing devices
EP3435627A1 (en) Method of controlling service traffic between data centers, device, and system
CN112398689B (en) Network recovery method and device, storage medium and electronic equipment
KR20050065346A (en) System and method for managing protocol network failures in a cluster system
CN110166524B (en) Data center switching method, device, equipment and storage medium
CN106254814B (en) Conference recovery method, service management center and system
CN112631756A (en) Distributed regulation and control method and device applied to space flight measurement and control software
CN106534758B (en) Conference backup method and device
CN108632355B (en) Routing method for household appliance network, control terminal, readable storage medium and equipment
CN115396444A (en) Access control method, server and client
CN110661836B (en) Message routing method, device and system, and storage medium
CN113301103B (en) Data processing system, method and device
CN111064636B (en) Control method, device and system for connection of front-end processor and computer equipment
CN111586110B (en) Optimization processing method for raft in point-to-point fault
KR20120128031A (en) System and method for providing push service
CN110166506B (en) Method for connecting hypertext transfer protocol Http and node equipment
CN110890989A (en) Channel connection method and device
CN111786840A (en) Gateway switching method and device based on network access platform
CN115643237B (en) Data processing system for conference
JPH10116257A (en) Decentralized media processing server, and communication network using the same
CN114095759B (en) Stream media redirection method and related device
CN115086219B (en) Virtual router determining method, device and computer readable storage medium
CN111371573B (en) Message interaction method and device
CN111385323B (en) EJB service processing method, device, equipment and medium

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