CN110769019A - Session processing method, device and system - Google Patents

Session processing method, device and system Download PDF

Info

Publication number
CN110769019A
CN110769019A CN201810847805.8A CN201810847805A CN110769019A CN 110769019 A CN110769019 A CN 110769019A CN 201810847805 A CN201810847805 A CN 201810847805A CN 110769019 A CN110769019 A CN 110769019A
Authority
CN
China
Prior art keywords
session
server
state
cluster
session state
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.)
Granted
Application number
CN201810847805.8A
Other languages
Chinese (zh)
Other versions
CN110769019B (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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201810847805.8A priority Critical patent/CN110769019B/en
Publication of CN110769019A publication Critical patent/CN110769019A/en
Application granted granted Critical
Publication of CN110769019B publication Critical patent/CN110769019B/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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/148Migration or transfer of 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/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1034Reaction to server failures by a load balancer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Abstract

The invention discloses a session processing method, a session processing device and a session processing system. Wherein, the method comprises the following steps: receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data; and determining a synchronous mode of the session state according to the size relation between the life cycle of the session and the broadcast time threshold. The invention solves the technical problem of resource waste caused by the existing broadcast session state synchronization mechanism.

Description

Session processing method, device and system
Technical Field
The present invention relates to the field of communications, and in particular, to a session processing method, apparatus, and system.
Background
In order to improve performance, scalability, and reliability of a service system, a plurality of servers may be combined to obtain a Server cluster, and fig. 1 shows a network topology of an existing Load balancing Server (i.e., SLB) cluster. In fig. 1, CSR-1 and CSR-2 are routers, LSW-1 and LSW-2 are switches, and the routers and switches form network devices in a network topology of an SLB cluster, where traffic of the SLB cluster can enter the SLB cluster through the network devices. The LVS1, the LVS2, the LVS3 and the LVS4 are four servers in the SLB cluster, the T1 and the T2 are ports of the servers, and the ladder is a port address corresponding to a port of the server.
Specifically, for a specific session, the network device first determines, from the SLB cluster, a server a that receives packets of the session according to routing information issued by the server, or determines, according to a routing technique of ECMP (Equal-Cost multipath), the server a, and forwards all packets of the session to the server a (for example, select LVS1 in fig. 1 as server a). If the entire network has not changed, for example, the topology shown in fig. 1 has changed due to a downtime of a server, a switch, or a router, all the packets are forwarded to the server a in the lifetime of the session. The above process is called a sticky session (session tack).
When server a goes down, the upstream switch or server may sense that the network to which server a is connected is disconnected, and at this time, the network device forwards the packet previously sent to server a to other servers in the cluster, for example, server LVS 2. In order to ensure the availability of the system under abnormal behaviors such as server downtime, the SLB cluster synchronizes the session state to all servers in the cluster through the session state synchronization mechanism, and when the session state changes, for example, is created, changed in state, or destroyed, the server handling the session state change may broadcast the session state to the cluster through the session synchronization mechanism.
The current session synchronization mechanism is implemented based on network broadcast, for example, by means of UDP (User datagram protocol) multicast. As shown in fig. 2, when the SLB cluster starts, the SLB cluster may join the UDP multicast group and broadcast the session status update message in the form of UDP multicast to all servers in the SLB cluster. However, in existing networks, most sessions are short connections, which are typically less than 30s in duration, and there is a small probability that a node in the cluster goes down. Under normal conditions, because the health state of the cluster is not changed, all data packets of a certain session are pasted on one server, and the session state synchronized to other servers is not used, so that the waste of network bandwidth and the waste of a server system memory are caused.
In view of the above problem of resource waste caused by the existing broadcast session state synchronization mechanism, no effective solution is proposed at present.
Disclosure of Invention
The embodiment of the invention provides a session processing method, a session processing device and a session processing system, which are used for at least solving the technical problem of resource waste caused by the existing broadcast session state synchronization mechanism.
According to an aspect of an embodiment of the present invention, there is provided a session processing method, including: receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data; and determining a synchronous mode of the session state according to the size relation between the life cycle of the session and the broadcast time threshold.
According to another aspect of the embodiments of the present invention, there is also provided a session processing method, including: detecting that the server is abnormal; determining a session state processing mode of a cluster according to whether the abnormal server causes session state redistribution of all servers in the cluster, wherein the cluster comprises: the server and the backup server corresponding to the session state processed by the server.
According to another aspect of the embodiments of the present invention, there is also provided a session processing system, including: the first server is used for generating a corresponding session state according to session data corresponding to a current session to be processed, and determining a synchronization mode of the session state according to the size relationship between the life cycle of the session and a broadcast time threshold; and the at least one second server is used for determining whether all other servers in the cluster to which the first server belongs redistribute the session flow due to the abnormal state when the abnormal state of the first server is detected, and forming a processing mode of the cluster for the session state according to a determination result, wherein the cluster comprises the first server and the at least one second server.
According to another aspect of the embodiments of the present invention, there is also provided a session processing apparatus, including: the generation module is used for receiving session data corresponding to the current session to be processed and generating a corresponding session state according to the session data; and the first determining module is used for determining the synchronous mode of the session state according to the size relation between the life cycle of the session and the broadcast time threshold.
According to another aspect of the embodiments of the present invention, there is also provided a session processing apparatus, including: the second determining module is used for determining whether all other servers in the cluster to which the server belongs redistribute the session flow due to the abnormal state when the server which generates the session state at present is detected to have the abnormal state; and the forming module is used for forming a processing mode of the cluster to the session state according to the determined result.
According to another aspect of the embodiments of the present invention, there is also provided a storage medium including a stored program, wherein when the program is executed, the apparatus on which the storage medium is located is controlled to perform the following steps: receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data; and determining a synchronous mode of the session state according to the size relation between the life cycle of the session and the broadcast time threshold.
According to another aspect of the embodiments of the present invention, there is also provided a computing device, including a processor, configured to execute a program, where the program executes to perform the following steps: receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data; and determining a synchronous mode of the session state according to the size relation between the life cycle of the session and the broadcast time threshold.
According to another aspect of the embodiments of the present invention, there is also provided a storage medium including a stored program, wherein when the program is executed, the apparatus on which the storage medium is located is controlled to perform the following steps: if the server which generates the session state at present is detected to have an abnormal state, determining whether all other servers in the cluster to which the server belongs redistribute the session flow due to the abnormal state; and forming a processing mode of the cluster to the session state according to the determined result.
According to another aspect of the embodiments of the present invention, there is also provided a computing device, including a processor, configured to execute a program, where the program executes to perform the following steps: if the server which generates the session state at present is detected to have an abnormal state, determining whether all other servers in the cluster to which the server belongs redistribute the session flow due to the abnormal state; and forming a processing mode of the cluster to the session state according to the determined result.
In the embodiment of the invention, a multi-level state synchronization mode is adopted, after session data corresponding to a current session to be processed is received, a server which currently generates a session state generates a corresponding session state according to the session data, and the synchronization mode of the session state is determined according to the size relationship between the life cycle of the session and the broadcast time threshold. It is easy to note that, in the above process, the server currently generating the session state does not synchronize the session state to all servers in the cluster, but determines the synchronization mode of the session state according to the comparison result of the life cycle of the session and the preset threshold, and for short connections, the session state synchronization mode may adopt a unicast mode, thereby achieving the purpose of reducing resource waste, achieving the technical effects of optimizing the utilization rate of network bandwidth, reducing the memory occupied by the backup session state, and further solving the technical problem of resource waste caused by the existing broadcast session state synchronization mechanism.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a schematic diagram of a network topology of a cluster of load balancing servers according to the prior art;
FIG. 2 is a schematic diagram of a session synchronization mechanism according to the prior art;
FIG. 3 is a block diagram of a session processing system according to an embodiment of the present invention;
fig. 4 is a block diagram of a hardware structure of an alternative computer terminal for implementing a session processing method according to an embodiment of the present invention;
FIG. 5 is a flow diagram of a method of session processing according to an embodiment of the present invention;
FIG. 6 is a flow diagram of a method of session processing according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a session processing apparatus according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a session processing apparatus according to an embodiment of the present invention; and
FIG. 9 is a block diagram of a computing device, according to an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. 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.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those 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.
First, some terms or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
SLB/LB, Server Load Balancer/Load Balancer, i.e. Load balancing Server, is used to implement Load balancing among multiple servers.
The cluster is a server cluster composed of a plurality of load balancing servers, and the server cluster can improve the performance, the expandability and the reliability of the whole service system.
The connection refers to a connection between network protocols in this application, and specifically refers to a channel established by using a transport layer, for example, TCP (Transmission Control Protocol) or UDP (User datagram Protocol). Among these, TCP provides a connection-oriented, reliable byte stream service, while UDP provides a simple datagram-oriented transport layer protocol, and it provides a protocol that is not reliable.
In the present application, a session may be a connection of each layer in an OSI (Open System Interconnection, i.e., Open System Interconnection reference model) model, or may be a connection of each layer in a TCP/IP (transmission control Protocol/Internet Protocol, i.e., transmission control Protocol/Internet Protocol) model.
Example 1
Before describing further details of embodiments of the present application, one suitable session processing system that may be used to implement the principles of the present application will be described with reference to FIG. 3.
Fig. 3 is a schematic diagram of a session processing system according to an embodiment of the present application, and the depicted architecture is only one example of a suitable environment for description purposes and is not intended to suggest any limitation as to the scope of use or functionality of the application and should not be interpreted as having any dependency or requirement relating to any one or combination of components illustrated in fig. 3.
The system embodiment provided in embodiment 1 of the present application can be widely applied to the field of computer networks, including but not limited to various applications that need cluster state synchronization. In order to improve the performance, expandability and reliability of the service system, a plurality of servers can be combined in a server cluster mode. However, in order to ensure the availability of the service system under abnormal behavior such as server down, in the network topology of the server cluster, the session state needs to be synchronized to all servers in the cluster through a session state synchronization mechanism. But this solution causes a waste of network bandwidth and a waste of server system memory. The session processing system provided by the application synchronizes the session state to the server for backing up the session state determined according to the selection policy, wherein the session state is backed up in a unicast mode. In addition, the scheme provided by the application judges the life cycle of the session, updates the session state with the life cycle smaller than the broadcast threshold value, and updates the session state to the server for backing up the session state. Therefore, compared with the prior art, the session processing system provided by the application can save network bandwidth and optimize system memory.
Specifically, as shown in fig. 3, the session processing system may include: a first server 301 and at least one second server 303. The first server 301 is configured to generate a corresponding session state according to session data corresponding to a current session to be processed, and determine a synchronization mode of the session state according to a size relationship between a life cycle of the session and a broadcast time threshold; the second server 303 is configured to, when detecting that the first server is in the abnormal state, determine whether all other servers in the cluster to which the first server belongs redistribute the session traffic due to the abnormal state, and form a processing manner of the cluster for the session state according to a determination result, where the cluster includes the first server and at least one second server.
It should be noted that the first server is a server that generates a session state, the second server is a server that backs up the session state, and the first server and the second server may be, but are not limited to, a load balancing server (i.e., an SLB). The second server is any one of the servers except the first server in the first server attribution cluster, for example, the first server a belongs to the server cluster S, and the server cluster S includes 4 servers, which are respectively the server a, the server B, the server C, and the server D, wherein the first server is the server a, and the at least one second server includes the server B, the server C, and the server D, and for the current session state, the first server may be a primary server, and the second server is a standby server. Further, the above-mentioned session state includes at least the following: session initialization time (born _ time), broadcast time threshold (broadcast _ threshold), original server identification (source _ server), exception status flag (source _ down), backup server identification (backup _ server).
In addition, the synchronization modes of the session states at least include the following two modes: a first synchronization mode that synchronizes the session state to a second server within the cluster, and a second synchronization mode that synchronizes the session state to all remaining servers within the cluster. Specifically, if the lifetime of the session is less than the broadcast time threshold, the first server continuously synchronizes the session state to the second server within the lifetime, that is, the first server synchronizes the session state in a unicast manner; if the lifetime of the session is greater than or equal to the airtime threshold, the first server continues to synchronize the session state to the remaining servers in the cluster for the lifetime, i.e., the first server synchronizes the session state in all servers in an airtime manner.
It should be noted that, in the above process, the broadcast time threshold is a time length greater than an average lifetime of the short connection of the session.
Optionally, when the first server generating the session is abnormal (for example, down), all the servers in the server cluster may detect the first server abnormal event, and determine whether all other servers in the cluster to which the first server belongs redistribute the session traffic due to the abnormal state. If the first server is abnormal, the session flow of all other servers in the cluster to which the first server belongs is redistributed, the second server for backing up the session state searches the local session table to obtain the session with the session life cycle smaller than the broadcast time threshold, and further judges whether the original server identifier in the searched session state corresponds to the first server, if the original server identifier corresponds to the first server, the session state corresponding to the session is updated, and the searched session state corresponding to the session (including the session state in which the original server identifier does not correspond to the first server) is synchronized to all other servers in the cluster. And if the first server is abnormal and the session flow of all other servers in the cluster to which the first server belongs cannot be redistributed, the second server for backing up the session state searches the session table for the session with the original server identifier in the session state corresponding to the first server, the life cycle of the session is less than the broadcast time threshold, and the session state corresponding to the searched session is updated and then synchronized to all other servers in the cluster.
Therefore, when the first server generating the session state is abnormal, the integrity of the session can be ensured through the process, and the performance and the reliability of the server cluster system are further improved.
As can be seen from the above, after receiving session data corresponding to a current session to be processed, a first server generates a session state, and determines a synchronization mode of the session state according to a size relationship between a life cycle of the session and a broadcast time threshold, when at least one second server detects that the first server is in an abnormal state, the at least one second server determines whether session traffic is redistributed due to the abnormal state in all other servers in a cluster to which the first server belongs, and forms a processing mode of the session state by a cluster according to a determination result, where the cluster includes the first server and the at least one second server.
It is easily noted that the scheme provided by the present application can perform multi-level synchronization of session states, wherein the first level synchronization uses only unicast mode to synchronize the session states to one server (e.g., server a), and the second level synchronization uses broadcast mode. For short connections (connections with session connection less than the preset time), the state synchronization only needs to be performed at the first level, so that compared with the prior art, the method and the device can save network bandwidth and optimize system memory. In addition, different backup servers are selected according to different session characteristics, so that the backup session states are evenly distributed on different servers, and the backup burden of a single-node server is reduced.
Therefore, the session processing system achieves the purpose of reducing resource waste, achieves the technical effects of optimizing the network bandwidth utilization rate and reducing the memory occupied by the backup session state, and further solves the technical problem of resource waste caused by the existing broadcast session state synchronization mechanism.
In an optional scheme, the session data includes first packet data and non-first packet data, where the first server performs different processing on the session state according to the received session data, and specifically, in a case of receiving the first packet data corresponding to the session, the first server initializes the session state corresponding to the session according to the first packet data; and under the condition of receiving the non-first packet data corresponding to the session, the first server correspondingly updates the session state according to the non-first packet data.
In addition, the first packet data corresponding to the session may be, but is not limited to, data of a syn (synchronization) packet of TCP, where syn is a handshake signal used when the TCP/IP establishes a connection. Specifically, after the network device determines the first server, the first server performs conventional SLB processing (i.e., load balancing processing) on the first packet data, and initializes the session state. The first server can determine the session initialization time, namely the starting time point of the session, according to the current time point of the system; configuring a broadcast time threshold according to the service characteristics of the session, wherein the broadcast time thresholds corresponding to different service characteristics may be different; setting an original server generating a session state as a first server, and setting an original server identifier; setting an abnormal state mark, namely setting indication information of whether the first server is abnormal to be abnormal, wherein the first server is not abnormal when the attribute value corresponding to source _ down is false or 0, and the first server is abnormal when the attribute value corresponding to source _ down is true or 1; and determining a server selected from a cluster to which the first server belongs as a backup server of the first server, and setting a backup server identifier, wherein the backup server can be selected according to different strategies, for example, a server closest to the first server is selected as a server in a backup session state.
It should be noted that, after the session state session is generated, the first server synchronizes the session state to the selected second server in the cluster. After receiving the message of the session, the first server updates the session state according to the message of the session, and performs load balancing on the updated session state. Specifically, if the life cycle of the session is less than the broadcast time threshold, the session state is synchronized to the associated servers in the cluster within the life cycle to complete the backup; and if the life cycle of the session is greater than the broadcast time threshold, synchronizing the session state to all other servers in the cluster in the life cycle, wherein the rest servers in the cluster are other servers in the cluster except the first server.
In addition, in the above process, the first server determines the number of the session streams to be backed up, and evenly distributes the session states of the session streams to be backed up on the plurality of second servers according to the number of the session streams, so that the session states are continuously synchronized to the second servers in the life cycle. For example, there are 10 session streams to be backed up, and the first server allocates 10 session streams to be backed up to 5 second servers, then the first server allocates 2 session streams to be backed up to each second server.
In an alternative scheme, after determining the synchronization mode of the session state according to the size relationship between the session state and the broadcast time threshold, the first server further detects whether the session state is deleted from the first server, wherein if the session state is determined to be deleted from the first server, the first server instructs the servers in the cluster which synchronize the session state to delete the session state. Specifically, it is determined that the session state is deleted from the first server, and when the life cycle is smaller than the broadcast time threshold, the first server sends a deletion instruction to the second server to instruct the second server to delete the session, for example, if the second server is B, the server B deletes the session state in the server B that is synchronous with the first server; when the lifetime is greater than the airtime threshold, the first server deletes the session state from all remaining servers. Likewise, the remaining servers within the cluster are servers in the cluster other than the first server.
It should be noted that, the first server may further detect whether the second server is abnormal (for example, down), and when it is detected that the second server a is abnormal and the lifecycle is less than the broadcast time threshold, the first server selects the second server B from the cluster, then synchronizes the session state to the second server B, and sets the second server B as a standby server of the first server, so as to backup the session state. The second server a and the second server B are servers in a cluster. Optionally, the server set in the cluster includes a plurality of second servers, which may include, but are not limited to, the second server a and the second server B described above.
In an optional scheme, when the first server detects that the second server is abnormal, if the first server further detects that the life cycle of the session state is greater than or equal to the broadcast time threshold, since the remaining servers in the cluster except the first server and the second server already back up the session state of the first server, the first server does not need to synchronize the session state to the remaining servers in the cluster except the first server and the second server.
It should be noted that, the first server may detect whether the second server is abnormal through a heartbeat protocol, and similarly, the second server may also detect whether the first server is abnormal through the heartbeat protocol. When the second server detects that the first server is abnormal, the second server determines a processing mode of the session traffic of the cluster according to whether the abnormality of the first server causes the session traffic of all the servers in the cluster to be redistributed.
Specifically, if all other servers in the cluster to which the server belongs do not redistribute the session traffic due to the abnormal state, at this time, the second server searches the session state in the local session table to satisfy the session in the first state, updates the session state corresponding to the searched session and synchronizes the session state to all other servers in the cluster, where the first state condition is that the original server identifier in the session state corresponds to the server, and the life cycle of the session is less than the broadcast time threshold. For example, the second server searches for a session with source _ server a and lifetime less than broadcast _ threshold from the session table, sets an abnormal state flag source _ down of whether the first server in the session is abnormal to 1, and then broadcasts the session to all servers in the cluster.
It should be noted that each server has a hash table storing all session information, and the table is a session table of the server.
In another optional scheme, when the first server is abnormal and session traffic of all other servers in the cluster is redistributed, the second server instructs all other servers in the cluster to search for sessions meeting a second state condition in the local session table, and determines whether an original server identifier in a session state corresponding to the found session corresponds to the first server, if so, the session state corresponding to the session is updated, and the session state corresponding to the found session is synchronized to all other servers in the cluster, wherein the second state condition is that a life cycle of the session is smaller than a broadcast time threshold. For example, the second server searches the session with the life cycle less than the broadcast time threshold value broadcast _ threshold from the session table, and if the first server source _ server of the searched session is a, sets the abnormal state flag source _ down of the first server in the session to 1, and then broadcasts the session to all servers in the cluster.
It should be noted that the lifetime of the session is the difference between the current time and the session initialization time born _ time.
In addition, if the server which generates the session state at present is detected to have an abnormal state, all other servers in the cluster are instructed to search the session of which the session state meets the third state condition in the local session table, and after the session state corresponding to the searched session is updated, the session state corresponding to the searched session is synchronized to the server which is reselected from the cluster and used for backing up the session state corresponding to the searched session. In the above process, the third state condition is that the backup server identifier in the session state corresponds to a server, and the life cycle of the session is less than the broadcast time threshold. For example, when it is detected that the second server a is abnormal and the life cycle is less than the broadcast time threshold, the first server selects the second server B from the cluster. The session state is then synchronized to the second server B and the second server B is set as the server of the backup session state of the first server.
In addition, the scheme provided by the application can also set different broadcast thresholds according to different session characteristics, so that the scheme provided by the application can adapt to the requirements of different applications.
Example 2
There is also provided, in accordance with an embodiment of the present invention, a method embodiment of a session processing method, it should be noted that the steps illustrated in the flowchart of the accompanying drawings may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than that herein.
The method provided by the second embodiment of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Fig. 4 shows a hardware configuration block diagram of a computer terminal (or mobile device) for implementing the session processing method. As shown in fig. 4, the computer terminal 40 (or mobile device 40) may include one or more (shown as 402a, 402b, … …, 402 n) processors 402 (the processors 402 may include, but are not limited to, a microprocessor mcu (microcontroller unit) or a Programmable logic device FPGA (Field-Programmable Gate Array) or other processing device), a memory 404 for storing data, and a transmission module 406 for communication functions. Besides, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 4 is only an illustration and is not intended to limit the structure of the electronic device. For example, the computer terminal 40 may also include more or fewer components than shown in FIG. 4, or have a different configuration than shown in FIG. 4.
It should be noted that the one or more processors 402 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuit may be a single stand-alone processing module, or incorporated in whole or in part into any of the other elements in the computer terminal 40 (or mobile device). As referred to in the embodiments of the application, the data processing circuit acts as a processor control (e.g. selection of a variable resistance termination path connected to the interface).
The memory 404 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the session processing method in the embodiment of the present invention, and the processor 402 executes various functional applications and data processing by running the software programs and modules stored in the memory 404, that is, implementing the session processing method of the application program. The memory 404 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 404 may further include memory located remotely from the processor 402, which may be connected to the computer terminal 40 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 406 is used for receiving or sending data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal 40. In one example, the transmission device 406 includes a Network adapter (NIC) that can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 406 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The Display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the computer terminal 40 (or mobile device).
In a runtime environment, the present application provides a session handling method as shown in fig. 5. It should be noted that, in the embodiment of the session processing method provided in the embodiment of the present application, the application scenario and the technical scenario may be, but are not limited to, the same as those described in embodiment 1.
Fig. 5 is a flowchart of a session processing method according to an embodiment of the present application, and as shown in fig. 5, the method further includes the following method steps:
step S502, receiving the session data corresponding to the current session to be processed, and generating a corresponding session state according to the session data.
It should be noted that the execution subject in this embodiment may be the first server 301 in fig. 3, where the first server is a server that generates a session state, and may be, but is not limited to, a load balancing server (i.e., an SLB). Additionally, an upstream network device (e.g., router, switch) may select a server from the cluster of servers as the first server and forward session data corresponding to the session to the first server.
In addition, in step S502, the session data includes first packet data and non-first packet data, where the first packet data may be, but is not limited to, data of a syn packet in a TCP protocol, the syn packet is a handshake signal used when a connection is established in a TCP/IP, and the first server performs load balancing processing on the session data to generate a session state. Wherein the session state includes at least one of: session initialization time (born _ time), broadcast time threshold (broadcast _ threshold), original server identification (source _ server), exception status flag source _ down), backup server identification (backup _ server).
Step S504, according to the relationship between the life cycle of the conversation and the broadcast time threshold, the synchronization mode of the conversation state is determined.
In step S504, the life cycle of the session is the time difference between the current time and the starting time point at which the session is created (i.e., the session initialization time). The synchronization modes of the session state at least include the following two modes: a first synchronization mode for synchronizing the session state to at least one second server in the cluster, and a second synchronization mode for synchronizing the session state to all remaining servers in the cluster. And the at least one second server is used for backing up the session in the first server. Likewise, the at least one second server may be, but is not limited to, a server capable of load balancing.
In addition, the other servers in the second synchronization mode are all the servers in the server cluster except the first server, including the second server in the first synchronization mode. The airtime threshold is a length of time greater than the average lifetime of the short connection of the session. Therefore, in the first synchronization mode, that is, in the short connection mode, the first server does not synchronize the session state to all the servers in the server cluster in a broadcast mode, but synchronizes the session state to at least one second server only in a unicast mode, so that the waste of system resources is reduced.
Based on the schemes defined in steps S502 to S504, it can be known that, after receiving session data corresponding to a current session to be processed, a corresponding session state is generated according to the session data, and a synchronization mode of the session state is determined according to a size relationship between a life cycle of the session and a broadcast time threshold.
It is easy to note that, in the solution provided in the present application, the server that generates the session state does not synchronize the session state to all servers in the cluster, but determines the synchronization mode of the session state according to the comparison result between the life cycle of the session and the preset threshold, that is, different backup servers are selected according to different session characteristics, so that the backup session state is evenly distributed on different servers, thereby reducing the backup burden of the single-node server. For short connection, the session state synchronization mode can adopt a unicast mode, so that the aim of reducing resource waste is fulfilled, the network bandwidth utilization rate is optimized, and the technical effects of reducing the memory occupied by the backup session state are achieved.
Therefore, the session processing method provided by the application can solve the technical problem of resource waste caused by the existing broadcast session state synchronization mechanism.
In an optional scheme, the first server performs different processing on the session state according to the received session data, specifically, in a case of receiving the first packet data corresponding to the session, the first server initializes the session state corresponding to the session according to the first packet data; and under the condition of receiving the non-first packet data corresponding to the session, the first server correspondingly updates the session state according to the non-first packet data. Specifically, first, a first server determines session initialization time according to a current time point of a system; configuring a broadcast time threshold according to the service characteristics of the session, wherein the broadcast time thresholds corresponding to different service characteristics may be different; setting an original server generating a session state as a first server, and setting an original server identifier; setting an abnormal state mark, namely setting indication information of whether the first server is abnormal to be abnormal, wherein the first server is not abnormal when the attribute value corresponding to source _ down is false or 0, and the first server is abnormal when the attribute value corresponding to source _ down is true or 1; and determining a server selected from a cluster to which the first server belongs as a backup server of the first server, and setting a backup server identifier, wherein the backup server can be selected according to different strategies, for example, a server closest to the first server is selected as the backup server.
In an optional scheme, after the session state is generated, the first server further determines a synchronization mode of the session state according to a size relationship between the session state and the broadcast time threshold. When the life cycle of the session is smaller than the broadcast time threshold, synchronizing the session state to a related server (i.e. a second server) in the cluster in the life cycle to complete backup, and synchronizing the session state only to a preset second server in the server cluster by the first server, wherein the number of the second servers may be one or more; and when the life cycle of the session is greater than the broadcast time threshold, synchronizing the session state to all other servers in the cluster in the life cycle, wherein the rest servers in the cluster refer to all servers except the first server in the server cluster.
In an alternative, when the lifetime is less than the preset threshold, the method for the first server to continuously synchronize the session state to the second server during the lifetime may include:
step S5020, determining the number of the session streams to be backed up on the first server;
step S5022, evenly distributing the session states of the session streams to be backed up on at least one second server according to the number of the session streams.
Specifically, the first server has the session streams to be backed up, and before the session streams to be backed up are backed up, the first server counts the local session streams to be backed up to obtain the number of the session streams to be backed up. Then, the first server evenly distributes the session states of the session streams to be backed up to the second servers according to the number of the session streams, for example, there are 10 session streams to be backed up, the first server allocates the 10 session streams to be backed up to 5 second servers, and then the first server allocates 2 session streams to be backed up to each second server. And after receiving the session stream to be backed up, the second server backs up the session stream to be backed up.
Similarly, for the case that the session state is continuously synchronized to the rest of the servers in the cluster during the lifetime, the session state of the session stream to be backed up may also be evenly distributed on the servers according to the number of the session streams to be backed up on the first server, and the specific distribution method may include, but is not limited to, even distribution, and distribution according to the load condition of the servers.
Further, after determining the synchronization mode of the session state according to the magnitude relation between the session state and the broadcast time threshold, the first server further detects whether the session state has been deleted, and processes the session state in other servers in the cluster under the condition that the session state is determined to have been deleted. Specifically, the first server determines whether the session state is deleted; and if so, indicating the server in the cluster with the session state synchronously to delete the session state.
Specifically, the first server determines whether the session state has been deleted from the first server by detecting whether the session state exists. For example, the first server detects whether the session state is deleted at preset time intervals, and if the session state a is detected at a first time, but the session state a is detected at a second time, the first server may determine that the session state a has been deleted from the first server, where a time difference between the second time and the first time is one preset time interval or a plurality of preset time intervals. After determining that the session state has been deleted from the first server, the first server further compares a lifetime of the deleted session state with a broadcast time threshold, and the first server performs different processing on different servers within the cluster according to different comparison results.
Specifically, when it is determined that the session state is deleted from the first server and when the life cycle is smaller than a preset threshold, the first server deletes the session state synchronized in the second server, for example, if the second server is B, the first server deletes the session state synchronized with the first server in the second server B; when the lifecycle is greater than the airtime threshold, the first server deletes the session state synchronized among the remaining servers within the cluster.
In an optional scheme, after determining the synchronization mode of the session state according to the comparison result of the lifecycle and the broadcast time threshold, the first server may further select the second server according to whether the second server is abnormal, where the specific method is as follows:
step S5080, when the second server A is detected to be abnormal and the life cycle is smaller than the broadcast time threshold, selecting a second server B from the cluster;
in step S5082, the session status is synchronized to the second server B, and the second server B is set as a backup server of the first server.
Specifically, the first server may determine whether the second server a is abnormal by detecting a heartbeat protocol between the first server and the second server a. And if the first server detects that the second server A is abnormal, further detecting whether the life cycle of the session state is less than the broadcast time threshold. And if the life cycle of the session state is less than the broadcast time threshold, the first server selects a second server B from the server cluster as a standby server of the first server so as to back up the session state of the first server.
It should be noted that, the first server may detect whether the second server is abnormal through a heartbeat protocol, and similarly, the second server may also detect whether the first server is abnormal through the heartbeat protocol. When the second server detects that the first server is abnormal, the second server determines a session state processing mode of the cluster according to whether the abnormal server causes the session traffic of all the servers in the cluster to be redistributed.
Specifically, when all other servers in the cluster to which the server belongs do not redistribute the session traffic due to the abnormal state, the second server searches the session state in the local session table to satisfy the session in the first state, updates the session state corresponding to the searched session and synchronizes the session state to all other servers in the cluster, wherein the first state condition is that the original server identifier in the session state corresponds to the server, and the life cycle of the session is less than the broadcast time threshold.
In addition, when the first server is abnormal and the session flow of all other servers in the cluster is redistributed, the second server indicates all other servers in the cluster to search the session meeting the second state condition in the local session table, and determines whether the original server identifier in the session state corresponding to the found session corresponds to the first server, if so, the session state corresponding to the session is updated, and the session state corresponding to the found session is synchronized to all other servers in the cluster, wherein the second state condition is that the life cycle of the session is smaller than the broadcast time threshold.
In addition, if the server which generates the session state at present is detected to have an abnormal state, all other servers in the cluster are instructed to search the session of which the session state meets the third state condition in the local session table, and after the session state corresponding to the searched session is updated, the session state corresponding to the searched session is synchronized to the server which is reselected from the cluster and used for backing up the session state corresponding to the searched session. In the above process, the third state condition is that the backup server identifier in the session state corresponds to a server, and the life cycle of the session is less than the broadcast time threshold. For example, when it is detected that the second server a is abnormal and the life cycle is less than the broadcast time threshold, the first server selects the second server B from the cluster. The session state is then synchronized to the second server B and the second server B is set as the server of the backup session state of the first server.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the session processing method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 3
According to an embodiment of the present application, there is also provided another embodiment of a session processing method, it should be noted that the steps shown in the flowchart of the figure can be executed in a computer system such as a set of computer executable instructions, and that although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
Under the same or similar operation environment as that of embodiment 2, the present application provides a session processing method as shown in fig. 6. Fig. 6 is a flowchart of another session processing method according to an embodiment of the present application, and as shown in fig. 6, the method may include the following steps:
step S602, if it is detected that the server currently generating the session state is in an abnormal state, determining whether all other servers in the cluster to which the server belongs redistribute the session traffic due to the abnormal state.
It should be noted that, in this embodiment, the execution subject is the second server 303 in fig. 3, and the server in step S602 is the first server, where the first server may be the first server 301 in fig. 3, and the servers in the first server and the second server set may be, but are not limited to, a load balancing server (i.e., SLB). In addition, the second server and the first server are both members of a server cluster, and an upstream network device (e.g., a router, a switch) may select one server from the server cluster as the first server and the remaining servers as the second servers.
In addition, the first server may process session data and generate a session state, where the session data includes first packet data and non-first packet data, the first packet data may be, but is not limited to, data of a syn packet in a TCP protocol, the syn packet is a handshake signal used when a connection is established by a TCP/IP, and the first server performs load balancing processing on the session data to generate the session state. Wherein the session state includes at least one of: session initialization time (born _ t ime), broadcast time threshold (broadcast _ threshold), original server identification (source _ server), exception status flag source _ down), backup server identification (backup _ server).
In an alternative scheme, the second server may determine whether the first server is abnormal by detecting an attribute value of an abnormal state flag source _ down of whether the first server is abnormal in the session state. Specifically, when the second server detects that the attribute value of the abnormal state flag source _ down is false or 0, the second server determines that the first server is not abnormal; and when the attribute value corresponding to the abnormal state mark source _ down is true or 1, the second server determines that the first server is abnormal.
In addition, the second server may also determine whether the first server is anomalous by detecting a heartbeat protocol between the second server and the first server.
Step S604, forming a processing mode of the cluster to the session state according to the determined result, wherein the cluster comprises: the server and the server for backing up the session state processed by the server.
Optionally, when the first server generating the session is abnormal, all servers in the server cluster may detect the abnormal event of the first server, and detect whether the abnormal event of the first server may cause the session traffic of all other servers in the cluster to be redistributed. If the first server is abnormal and the conversation flow of all other servers in the cluster is redistributed, the second server selects the conversation with the life cycle smaller than the broadcast time threshold value from the conversation table and broadcasts the conversation to all the servers; if the first server is abnormal and the conversation flow of all the servers in the cluster can not be redistributed, the second server searches the conversation table for the original server identification corresponding to the first server, and the conversation with the life time smaller than the broadcast time threshold value is broadcast to all other servers in the cluster.
Therefore, when the first server is abnormal, the integrity of the session can be ensured through the process, and the performance and the reliability of the server cluster system are further improved.
Based on the solutions defined in steps S602 to S604, it can be known that the second server detects that the first server is abnormal, where if it is detected that the server currently generating the session state is in an abnormal state, it is determined whether all other servers in the cluster to which the server belongs redistribute the session traffic due to the abnormal state, and a processing manner of the cluster for the session state is formed according to a determined result.
It is easy to note that, when the first server is abnormal, the second server does not broadcast all the session states to all the servers in the cluster, but makes a decision according to the influence of the first server on the distribution of the session states of the second server, that is, different backup servers are selected according to different session characteristics, so that the backup session states are evenly distributed on different servers, thereby effectively avoiding the problem of resource waste caused by the broadcast of the session states to all the servers in the cluster, and reducing the backup burden of the single-node server.
Therefore, the session processing method provided by the application can solve the technical problem of resource waste caused by the existing broadcast session state synchronization mechanism.
In an alternative scheme, when it is detected that the first server is abnormal, the second server may determine whether all other servers in the cluster to which the server belongs redistribute the session traffic due to the abnormal state, and form a processing mode of the cluster for the session state according to a determination result.
Specifically, when the determined result indicates that all other servers in the cluster do not redistribute the session traffic due to the abnormal state, the second server searches for a session in which the session state in the local session table meets the first state condition, updates the session state corresponding to the searched session and synchronizes the session state to all other servers in the cluster, wherein the first state condition is that the original server identifier in the session state corresponds to the server, and the life cycle of the session is smaller than the broadcast time threshold. For example, the second server searches for a session with source _ server a and lifetime less than broadcast _ threshold from the session table, sets an abnormal state flag source _ down of whether the first server in the session is abnormal to 1, and then broadcasts the session to all servers in the cluster.
In addition, when the determined result indicates that all other servers in the cluster redistribute the session traffic due to the abnormal state, the second server indicates all other servers in the cluster to search the session of which the session state meets the second state condition in the local session table, and for each searched session, if the original server identifier in the corresponding session state corresponds to the server, the session state corresponding to the session is updated. And then, synchronizing the session state corresponding to the searched session to all other servers in the cluster, wherein the second state condition is that the life cycle of the session is less than the broadcast time threshold. For example, the second server searches the session with the life cycle less than the broadcast _ threshold from the session table, and if the source _ server of the first server of the searched session is a, sets the source _ down, which is the indication information of whether the first server in the session is abnormal, to 1, and then broadcasts the session to all servers in the cluster.
It should be noted that each server has a hash table storing all session information, and the table is a session table of the server. In addition, the lifetime of the session is the difference between the current time and the start time point born _ time of the session creation.
In addition, after the first server generates the session state, the synchronization mode of the session state is determined according to the comparison result of the life cycle and the broadcast time threshold. Specifically, when the lifetime is less than the broadcast time threshold, the session state is synchronized to at least one second server in the cluster during the lifetime. And synchronizing the session state to all the rest servers in the cluster in the life cycle when the life cycle is larger than the preset broadcast time.
In an alternative, after determining the synchronization mode of the session state according to the comparison result of the life cycle and the broadcast time threshold, the first server determines that the session state is deleted from the first server, and compares the life cycle of the session with the broadcast time threshold. When the life cycle is smaller than the broadcast time threshold value, the first server deletes the session state from at least one second server; when the lifetime is greater than the airtime threshold, the first server deletes the session state from all remaining servers.
In another optional scheme, if it is detected that the server currently generating the session state is in an abnormal state, all other servers in the cluster are instructed to search for sessions whose session states meet the third state condition in the local session table, and after the session state corresponding to the searched session is updated, the session state corresponding to the searched session is synchronized to the server reselected from the cluster and used for backing up the session state corresponding to the searched session. In the above process, the third state condition is that the backup server identifier in the session state corresponds to a server, and the life cycle of the session is less than the broadcast time threshold. For example, when it is detected that the second server a is abnormal and the life cycle is less than the broadcast time threshold, the first server selects the second server B from the cluster. The session state is then synchronized to the second server B and the second server B is set as the server of the backup session state of the first server.
Example 4
According to an embodiment of the present invention, there is also provided a session processing apparatus for implementing the session processing method, as shown in fig. 7, the apparatus 70 includes: a generating module 701 and a first determining module 703.
The generating module 701 is configured to receive session data corresponding to a current session to be processed, and generate a corresponding session state according to the session data, where the session state includes at least one of the following: session initialization time, broadcast time threshold, original server identification, abnormal state mark and backup server identification; the first determining module 703 is configured to determine a synchronization mode of the session state according to a size relationship between a life cycle of the session and a broadcast time threshold.
Here, it should be noted that the generating module 701 and the first determining module 703 correspond to steps S502 to S504 in embodiment 2, and the two modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure of the second embodiment.
In an optional scheme, the session data includes header packet data and non-header packet data, and the generating module includes: the device comprises a first receiving module and a second receiving module. The first receiving module is used for receiving the first packet data corresponding to the session and initializing the session state corresponding to the session according to the first packet data; and the second receiving module is used for receiving the non-first packet data corresponding to the session and updating the session state correspondingly according to the non-first packet data.
In an alternative, the first determining module includes: the device comprises a first synchronization module and a second synchronization module. The first synchronization module is used for synchronizing the session state to the related servers in the cluster in the life cycle to complete backup when the life cycle of the session is smaller than the broadcast time threshold; and the second synchronization module is used for synchronizing the session state to all other servers in the cluster in the life cycle when the life cycle of the session is greater than the broadcast time threshold.
In an optional scheme, the session processing apparatus further includes: the device comprises a processing module and an indicating module. The processing module is used for determining whether the session state is deleted; and the indicating module is used for indicating the server which is synchronized with the session state in the cluster to delete the session state if the session state is deleted.
Example 5
According to an embodiment of the present invention, there is also provided a session processing apparatus for implementing the session processing method, as shown in fig. 8, the apparatus 80 includes: a second determination module 801 and a formation module 803.
The second determining module 801 is configured to determine, if it is detected that the server currently generating the session state is in an abnormal state, whether session traffic is redistributed due to the abnormal state in all other servers in the cluster to which the server belongs; a forming module 803, configured to form a processing manner of the session state by the cluster according to the determined result.
Here, it should be noted that the second determining module 801 and the forming module 803 correspond to steps S602 to S604 in embodiment 3, and the two modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure of the third embodiment.
In an alternative, forming the module includes: the device comprises a first searching module and a first distribution module. The first searching module is used for searching a session meeting a first state condition in the session state of the local session table if the determined result indicates that all other servers in the cluster redistribute the session traffic due to the abnormal state, wherein the first state condition is that an original server identifier in the session state corresponds to a server and the life cycle of the session is less than a broadcast time threshold value; and the first distribution module is used for updating the session state corresponding to the searched session and then synchronizing the session state to all other servers in the cluster.
In an alternative, forming the module includes: and indicating the module. The indicating module is configured to, if the determined result indicates that all other servers in the cluster do not redistribute the session traffic due to the abnormal state, indicate all other servers in the cluster to perform the following operations: searching a session of which the session state meets a second state condition in the local session table, wherein the second state condition is that the life cycle of the session is smaller than a broadcast time threshold; for each searched session, if the original server identifier in the corresponding session state corresponds to the server, updating the session state corresponding to the session; and synchronizing the session state corresponding to the searched session to all other servers in the cluster.
In an optional scheme, the session processing apparatus further includes: the device comprises a second searching module, a second distribution module and an updating module. The second searching module is used for searching the session which is backed up on the server generating the session state at present and has the life cycle smaller than the broadcast time threshold value by each server in all other servers; the second distribution module is used for reselecting a server in a backup session state for the searched session by each server in all other servers and synchronizing the searched session to the server in the backup session state; and the updating module is used for changing the server identifier of the session searched by the backup of the local record into the server in the backup session state by each server in all other servers.
Example 6
Embodiments of the present invention may provide a computing device that may be any one of a group of computer terminals. Optionally, in this embodiment, the computing device may also be replaced with a terminal device such as a mobile terminal.
Optionally, in this embodiment, the computing device may be located in at least one network device of a plurality of network devices of a computer network.
In this embodiment, the above-mentioned computing device may execute program codes of the following steps in the session processing method of the application program: receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data; determining a synchronization mode of a session state according to the size relation between the life cycle of the session and a broadcast time threshold, wherein the session state comprises at least one of the following: session initialization time, broadcast time threshold, original server identification, abnormal state flag, backup server identification.
Alternatively, fig. 9 is a block diagram of a computing device according to an embodiment of the invention. As shown in fig. 9, the computing device may include: one or more processors 902 (only one shown), a memory 904, and a transmitting device 906.
The memory may be configured to store software programs and modules, such as program instructions/modules corresponding to the session processing method and apparatus in the embodiments of the present invention, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, so as to implement the session processing method. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory located remotely from the processor, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor can call the information and application program stored in the memory through the transmission device to execute the following steps: receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data; determining a synchronization mode of a session state according to the size relation between the life cycle of the session and a broadcast time threshold, wherein the session state comprises at least one of the following: session initialization time, broadcast time threshold, original server identification, abnormal state flag, backup server identification.
Optionally, the processor may further execute the program code of the following steps: receiving first packet data corresponding to the session, and initializing a session state corresponding to the session according to the first packet data; receiving non-first packet data corresponding to the session, and correspondingly updating the session state according to the non-first packet data, wherein the session data comprises the first packet data and the non-first packet data.
Optionally, the processor may further execute the program code of the following steps: when the life cycle of the session is smaller than the broadcast time threshold, synchronizing the session state to the associated servers in the cluster in the life cycle to complete backup; when the lifetime of the session is greater than the airtime threshold, the session state is synchronized to all other servers in the cluster during the lifetime.
Optionally, the processor may further execute the program code of the following steps: determining whether the session state has been deleted; and if so, indicating the server in the cluster synchronizing the session state to delete the session state.
It will be understood by those skilled in the art that the structure shown in fig. 9 is merely an illustration, and the computing device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 9 is a diagram illustrating a structure of the electronic device. For example, the computing device may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 9, or have a different configuration than shown in FIG. 9.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
Example 7
The embodiment of the invention also provides a storage medium. Optionally, in this embodiment, the storage medium may be configured to store a program code executed by the session processing method provided in the second embodiment.
Optionally, in this embodiment, the storage medium may be located in any one of computer terminals in a computer terminal group in a computer network, or in any one of mobile terminals in a mobile terminal group.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data; determining a synchronization mode of a session state according to the size relation between the life cycle of the session and a broadcast time threshold, wherein the session state comprises at least one of the following: session initialization time, broadcast time threshold, original server identification, abnormal state flag, backup server identification.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: receiving first packet data corresponding to the session, and initializing a session state corresponding to the session according to the first packet data; receiving non-first packet data corresponding to the session, and correspondingly updating the session state according to the non-first packet data, wherein the session data comprises the first packet data and the non-first packet data.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: when the life cycle of the session is smaller than the broadcast time threshold, synchronizing the session state to the associated servers in the cluster in the life cycle to complete backup; when the lifetime of the session is greater than the airtime threshold, the session state is synchronized to all other servers in the cluster during the lifetime.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: determining whether the session state has been deleted; and if so, indicating the server in the cluster synchronizing the session state to delete the session state.
Example 8
Embodiments of the present invention may provide a computing device that may be any one of a group of computer terminals. Optionally, in this embodiment, the computing device may also be replaced with a terminal device such as a mobile terminal.
Optionally, in this embodiment, the computing device may be located in at least one network device of a plurality of network devices of a computer network.
In this embodiment, the above-mentioned computing device may execute program codes of the following steps in the session processing method of the application program: if the server which generates the session state at present is detected to have an abnormal state, determining whether all other servers in the cluster to which the server belongs redistribute the session flow due to the abnormal state; and forming a processing mode of the cluster to the session state according to the determined result.
Alternatively, the computing device provided by the present embodiment may be a computing device as shown in fig. 9.
Optionally, the processor may further execute the program code of the following steps: if the determined result indicates that all other servers in the cluster redistribute the session traffic due to the abnormal state, searching for the session of which the session state meets the first state condition, wherein the first state condition is that the original server identifier in the session state corresponds to the server, and the life cycle of the session is less than the broadcast time threshold; and updating the session state corresponding to the searched session and then synchronizing the session state to all other servers in the cluster.
Optionally, the processor may further execute the program code of the following steps: if the determined result indicates that all other servers in the cluster do not redistribute the session traffic due to the abnormal state, all other servers in the cluster are indicated to execute the following operations: searching a session of which the session state meets a second state condition in the local session table, wherein the second state condition is that the life cycle of the session is smaller than a broadcast time threshold; for each searched session, if the original server identifier in the corresponding session state corresponds to the server, updating the session state corresponding to the session; and synchronizing the session state corresponding to the searched session to all other servers in the cluster.
Optionally, the processor may further execute the program code of the following steps: if the server which generates the session state at present is detected to be in an abnormal state, all other servers in the cluster are indicated to execute the following operations: searching a session of which the session state meets a third state condition in the local session table, wherein the third state condition is that a backup server identifier in the session state corresponds to a server, and the life cycle of the session is less than a broadcast time threshold; and after the session state corresponding to the searched session is updated, synchronizing the session state to a server which is reselected from the cluster and used for backing up the session state corresponding to the searched session.
It will be understood by those skilled in the art that the structure shown in fig. 9 is merely an illustration, and the computing device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 9 is a diagram illustrating a structure of the electronic device. For example, the computing device may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 9, or have a different configuration than shown in FIG. 9.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
Example 9
The embodiment of the invention also provides a storage medium. Optionally, in this embodiment, the storage medium may be configured to store a program code executed by the session processing method provided in the third embodiment.
Optionally, in this embodiment, the storage medium may be located in any one of computer terminals in a computer terminal group in a computer network, or in any one of mobile terminals in a mobile terminal group.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: if the server which generates the session state at present is detected to have an abnormal state, determining whether all other servers in the cluster to which the server belongs redistribute the session flow due to the abnormal state; and forming a processing mode of the cluster to the session state according to the determined result.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: if the determined result indicates that all other servers in the cluster redistribute the session traffic due to the abnormal state, searching for the session of which the session state meets the first state condition, wherein the first state condition is that the original server identifier in the session state corresponds to the server, and the life cycle of the session is less than the broadcast time threshold; and updating the session state corresponding to the searched session and then synchronizing the session state to all other servers in the cluster.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: if the determined result indicates that all other servers in the cluster do not redistribute the session traffic due to the abnormal state, all other servers in the cluster are indicated to execute the following operations: searching a session of which the session state meets a second state condition in the local session table, wherein the second state condition is that the life cycle of the session is smaller than a broadcast time threshold; for each searched session, if the original server identifier in the corresponding session state corresponds to the server, updating the session state corresponding to the session; and synchronizing the session state corresponding to the searched session to all other servers in the cluster.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: if the server which generates the session state at present is detected to be in an abnormal state, all other servers in the cluster are indicated to execute the following operations: searching a session of which the session state meets a third state condition in the local session table, wherein the third state condition is that a backup server identifier in the session state corresponds to a server, and the life cycle of the session is less than a broadcast time threshold; and after the session state corresponding to the searched session is updated, synchronizing the session state to a server which is reselected from the cluster and used for backing up the session state corresponding to the searched session.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be 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, units or modules, and may be in an electrical 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 invention 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 invention may be embodied in the form of 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 invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (16)

1. A session processing method, comprising:
receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data;
and determining the synchronization mode of the session state according to the relationship between the life cycle of the session and the broadcast time threshold.
2. The method of claim 1, wherein the session data includes first packet data and non-first packet data, receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data includes:
receiving first packet data corresponding to the session, and initializing a session state corresponding to the session according to the first packet data;
and receiving non-first packet data corresponding to the session, and correspondingly updating the session state according to the non-first packet data.
3. The method of claim 1 or 2, wherein the session state comprises at least one of:
session initialization time, broadcast time threshold, original server identification, abnormal state flag, backup server identification.
4. The method according to claim 1 or 2, wherein determining the synchronization mode of the session state according to the magnitude relation between the life cycle of the session and the broadcast time threshold comprises:
when the life cycle of the session is smaller than a broadcast time threshold value, synchronizing the session state to a server associated in the cluster in the life cycle to complete backup;
synchronizing the session state to all other servers in the cluster during the lifecycle when the lifecycle of the session is greater than a broadcast time threshold.
5. The method of claim 4, wherein after determining the synchronization mode of the session state according to the magnitude relationship between the life cycle of the session and the broadcast time threshold, further comprising:
determining whether the session state has been deleted;
and if so, indicating the server in the cluster which is synchronized with the session state to delete the session state.
6. A session processing method, comprising:
if the server which generates the session state at present is detected to have an abnormal state, determining whether all other servers in a cluster to which the server belongs redistribute the session flow due to the abnormal state;
and forming a processing mode of the cluster to the session state according to the determined result.
7. The method of claim 6, wherein forming the processing manner of the session state by the cluster according to the determined result comprises:
if the determined result indicates that all other servers in the cluster redistribute the session traffic due to the abnormal state, searching for a session in which the session state in the local session table meets a first state condition, wherein the first state condition is that an original server identifier in the session state corresponds to the server, and the life cycle of the session is less than a broadcast time threshold;
and updating the session state corresponding to the searched session and then synchronizing the session state to all other servers in the cluster.
8. The method of claim 6, wherein forming the processing manner of the session state by the cluster according to the determined result comprises:
if the determined result indicates that all other servers in the cluster do not redistribute the session traffic due to the abnormal state, all other servers in the cluster are indicated to execute the following operations:
searching a session of which the session state meets a second state condition in a local session table, wherein the second state condition is that the life cycle of the session is smaller than a broadcast time threshold;
for each searched session, if the original server identifier in the corresponding session state corresponds to the server, updating the session state corresponding to the session;
and synchronizing the session state corresponding to the searched session to all other servers in the cluster.
9. The method of claim 6, further comprising:
if the server which generates the session state at present is detected to be in an abnormal state, indicating all other servers in the cluster to execute the following operations:
searching a session of which the session state meets a third state condition in a local session table, wherein the third state condition is that a backup server identifier in the session state corresponds to the server, and the life cycle of the session is less than a broadcast time threshold;
and after the session state corresponding to the searched session is updated, synchronizing the session state to a server which is reselected from the cluster and used for backing up the session state corresponding to the searched session.
10. A session processing system, comprising:
the first server is used for generating a corresponding session state according to session data corresponding to a current session to be processed, and determining a synchronization mode of the session state according to the size relationship between the life cycle of the session and a broadcast time threshold;
the system comprises at least one second server and a processing module, wherein the at least one second server is used for determining whether all other servers in a cluster to which the first server belongs redistribute session traffic due to the abnormal state when the abnormal state of the first server is detected, and forming a processing mode of the cluster to the session state according to a determination result, wherein the cluster comprises the first server and the at least one second server.
11. A session processing apparatus comprising:
the generation module is used for receiving session data corresponding to the current session to be processed and generating a corresponding session state according to the session data;
and the first determining module is used for determining the synchronous mode of the session state according to the size relation between the life cycle of the session and the broadcast time threshold.
12. A session processing apparatus comprising:
a second determining module, configured to determine, when it is detected that a server currently generating a session state is in an abnormal state, whether session traffic is redistributed due to the abnormal state among all other servers in a cluster to which the server belongs;
and the forming module is used for forming a processing mode of the cluster to the session state according to the determined result.
13. A storage medium comprising a stored program, wherein the program, when executed, controls an apparatus in which the storage medium is located to perform the steps of:
receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data;
and determining the synchronization mode of the session state according to the relationship between the life cycle of the session and the broadcast time threshold.
14. A computing device comprising a processor for executing a program, wherein the program when executed performs the steps of:
receiving session data corresponding to a current session to be processed, and generating a corresponding session state according to the session data;
and determining the synchronization mode of the session state according to the relationship between the life cycle of the session and the broadcast time threshold.
15. A storage medium comprising a stored program, wherein the program, when executed, controls an apparatus in which the storage medium is located to perform the steps of:
if the server which generates the session state at present is detected to have an abnormal state, determining whether all other servers in a cluster to which the server belongs redistribute the session flow due to the abnormal state;
and forming a processing mode of the cluster to the session state according to the determined result.
16. A computing device comprising a processor for executing a program, wherein the program when executed performs the steps of:
if the server which generates the session state at present is detected to have an abnormal state, determining whether all other servers in a cluster to which the server belongs redistribute the session flow due to the abnormal state;
and forming a processing mode of the cluster to the session state according to the determined result.
CN201810847805.8A 2018-07-27 2018-07-27 Session processing method, device, system, storage medium and computing equipment Active CN110769019B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810847805.8A CN110769019B (en) 2018-07-27 2018-07-27 Session processing method, device, system, storage medium and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810847805.8A CN110769019B (en) 2018-07-27 2018-07-27 Session processing method, device, system, storage medium and computing equipment

Publications (2)

Publication Number Publication Date
CN110769019A true CN110769019A (en) 2020-02-07
CN110769019B CN110769019B (en) 2022-05-06

Family

ID=69328420

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810847805.8A Active CN110769019B (en) 2018-07-27 2018-07-27 Session processing method, device, system, storage medium and computing equipment

Country Status (1)

Country Link
CN (1) CN110769019B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113014503A (en) * 2021-03-08 2021-06-22 中国工商银行股份有限公司 Access data routing method, device and system
US20220247813A1 (en) * 2021-02-01 2022-08-04 Hitachi, Ltd. Server management system, method of managing server, and program of managing server
WO2023165429A1 (en) * 2022-03-01 2023-09-07 百果园技术(新加坡)有限公司 Session state management method and system, apparatus, device, and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060070037A1 (en) * 2004-09-30 2006-03-30 Microsoft Corporation Method, system, and apparatus for providing customer product support for a software program based upon states of program execution instability
CN103326924A (en) * 2012-03-21 2013-09-25 阿里巴巴集团控股有限公司 Emerging message task control method, server and instant messaging client
US20140040487A1 (en) * 2005-04-29 2014-02-06 Galin Galchev Flexible failover configuration
US20160203072A1 (en) * 2015-01-08 2016-07-14 International Business Machines Corporation Comparative program execution through control of two or more debug sessions to automatically determine execution differences
CN106341454A (en) * 2016-08-23 2017-01-18 世纪龙信息网络有限责任公司 Across-room multiple-active distributed database management system and across-room multiple-active distributed database management method
CN106940699A (en) * 2016-01-05 2017-07-11 阿里巴巴集团控股有限公司 A kind of synchronization processing method of internal storage data, device, server and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060070037A1 (en) * 2004-09-30 2006-03-30 Microsoft Corporation Method, system, and apparatus for providing customer product support for a software program based upon states of program execution instability
US20140040487A1 (en) * 2005-04-29 2014-02-06 Galin Galchev Flexible failover configuration
CN103326924A (en) * 2012-03-21 2013-09-25 阿里巴巴集团控股有限公司 Emerging message task control method, server and instant messaging client
US20160203072A1 (en) * 2015-01-08 2016-07-14 International Business Machines Corporation Comparative program execution through control of two or more debug sessions to automatically determine execution differences
CN106940699A (en) * 2016-01-05 2017-07-11 阿里巴巴集团控股有限公司 A kind of synchronization processing method of internal storage data, device, server and system
CN106341454A (en) * 2016-08-23 2017-01-18 世纪龙信息网络有限责任公司 Across-room multiple-active distributed database management system and across-room multiple-active distributed database management method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JIA-CHUN LIN ET AL: ""PARES:A Proactive and adaptive redundant system for mapreduce"", 《JOURNAL OF INFORMATION SCIENCE AND ENGINEERING》 *
王冬青: ""提升Web服务响应的Cache调度技术的研究与实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220247813A1 (en) * 2021-02-01 2022-08-04 Hitachi, Ltd. Server management system, method of managing server, and program of managing server
US11659030B2 (en) * 2021-02-01 2023-05-23 Hitachi, Ltd. Server management system, method of managing server, and program of managing server
CN113014503A (en) * 2021-03-08 2021-06-22 中国工商银行股份有限公司 Access data routing method, device and system
WO2023165429A1 (en) * 2022-03-01 2023-09-07 百果园技术(新加坡)有限公司 Session state management method and system, apparatus, device, and storage medium

Also Published As

Publication number Publication date
CN110769019B (en) 2022-05-06

Similar Documents

Publication Publication Date Title
CN110912780B (en) High-availability cluster detection method, system and controlled terminal
US20190028538A1 (en) Method, apparatus, and system for controlling service traffic between data centers
EP2832060B1 (en) Inter-chassis redundancy with coordinated traffic direction
CN110769019B (en) Session processing method, device, system, storage medium and computing equipment
CN106878072B (en) Message transmission method and device
US20130238738A1 (en) Distributed method and system for implementing link aggregation control protocol (lacp) standard state machines
CN104184756A (en) Data synchronization method, device and system
US9288075B2 (en) Method and system for auto-configuration, and network node
CN109150808B (en) Communication method, device and system
WO2021057526A1 (en) Disaster recovery method for gateway device, and communication device
US10402280B2 (en) File transfer system and method, policy server, terminal and storage medium
CN104506330B (en) A kind of message synchronization method and system
CN109495345B (en) BFD processing method and network equipment
CN110928637A (en) Load balancing method and system
CN113169895A (en) N +1 redundancy for virtualization services with low latency failover
EP2928129B1 (en) Method and network devices for determining an administrative domain in a virtual cluster
CN108989204B (en) Link state determination method and device
CN108234358B (en) Multicast message transmission method, device and machine readable storage medium
CN103814591A (en) Communication method, access network equipment and UE (user equipment) of different-format networks
CN114007241A (en) ZigBee system, gateway equipment thereof, gateway switching method and device
EP2736204B1 (en) Rendezvous Point Convergence Method and Apparatus
CN109302328B (en) Hot standby switching method and system for VXLAN (virtual extensible local area network)
CN109039747B (en) Dual-computer hot standby control method and device for DPDK service
CN114125023B (en) Method and device for determining data connection, storage medium and electronic device
CN102647733B (en) Dynamic adjusting method of PS (Packet Switch) permanent timer and RNC (Radio Network Controller)

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