CN110839084A - Session management method, device, equipment and medium - Google Patents

Session management method, device, equipment and medium Download PDF

Info

Publication number
CN110839084A
CN110839084A CN201911133671.4A CN201911133671A CN110839084A CN 110839084 A CN110839084 A CN 110839084A CN 201911133671 A CN201911133671 A CN 201911133671A CN 110839084 A CN110839084 A CN 110839084A
Authority
CN
China
Prior art keywords
session
server
request
interactive
session request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911133671.4A
Other languages
Chinese (zh)
Other versions
CN110839084B (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.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
CCB Finetech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp, CCB Finetech Co Ltd filed Critical China Construction Bank Corp
Priority to CN201911133671.4A priority Critical patent/CN110839084B/en
Publication of CN110839084A publication Critical patent/CN110839084A/en
Application granted granted Critical
Publication of CN110839084B publication Critical patent/CN110839084B/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/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
    • 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/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • H04L67/63Routing a service request depending on the request content or context

Abstract

The embodiment of the invention discloses a session management method, a session management device, session management equipment and session management media. The method comprises the following steps: calculating a hash value corresponding to the session identifier according to the session identifier of the received session request; and determining an interactive server according to the hash value, and routing the session request to the interactive server, wherein the interactive server is any server in the server cluster and is used for responding to the session request. The embodiment of the invention reduces the data processing burden of the same server by routing different session requests to different servers, realizes load balancing, ensures the performance of the servers, improves the stability and robustness of an interactive system, and simultaneously can ensure that the session requests are routed to the server with the context information of the session requests when the same user sends the session requests again, thereby providing better services for the user, and having simple implementation mode and low cost.

Description

Session management method, device, equipment and medium
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to a session management method, a session management device, session management equipment and session management media.
Background
With the development of natural speech processing technology, multiple rounds of interaction and context technology in an interactive system are increasingly applied to human-computer interaction, so that a machine device can more accurately understand user intention and respond. In actual use, the context information of the interaction between the machine device and the user is stored in the server memory corresponding to the machine device. However, when a plurality of users interact with the machine device at the same time, the amount of context information called in the memory of the server corresponding to the computer device is particularly large, so that the performance of the server is reduced, and the stability and robustness of the interactive system are poor.
In the related art, in order to improve the stability and robustness of an interactive system, the following two ways are generally adopted: in the first mode, the memory of the server is increased to meet the requirement of high concurrent session; and secondly, by introducing a Redis storage system, the master-slave synchronization between the Redis storage system and the server memory is realized through the storage system, so that the sharing of the server memory and the stability of an interactive system are ensured.
However, the above two methods have the following problems: aiming at the first mode, when the server fails, the interactive system cannot be used; and the mode II is high in cost, complex in installation, strong in specialization and difficult in maintenance when the Redis storage system is introduced.
Disclosure of Invention
Embodiments of the present invention provide a session management method, apparatus, device, and medium, which improve stability and robustness of an interactive system, and simultaneously ensure that when the same user sends a session request again, the session request is routed to a server having context information of the session request, so as to provide better service for the user, and the implementation manner is simple and the cost is low.
In a first aspect, an embodiment of the present invention provides a session management method, where the method includes:
calculating a hash value corresponding to a session identifier according to the session identifier of the received session request;
and determining an interactive server according to the hash value, and routing the session request to the interactive server, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
In a second aspect, an embodiment of the present invention further provides a session management apparatus, where the apparatus includes:
the computing module is used for computing a hash value corresponding to the session identifier according to the session identifier of the received session request;
and the processing module is used for determining an interactive server according to the hash value and routing the session request to the interactive server, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the session management method according to any embodiment of the present invention.
In a fourth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the session management method according to any embodiment of the present invention.
The technical scheme disclosed by the embodiment of the invention has the following beneficial effects:
and calculating a hash value corresponding to the session identifier according to the session identifier of the session request, and determining an interactive server from the server cluster according to the hash value so as to respond to the session request through the interactive server. Therefore, different session requests are routed to different servers, so that the data processing burden of the same server is reduced, load balance is realized, the performance of the server is ensured, the stability and the robustness of an interactive system are improved, and meanwhile, when the same user sends the session request again, the session request is routed to the server with the context information of the session request, better service is provided for the user, the implementation mode is simple, the cost is low
Drawings
Fig. 1 is a flowchart illustrating a session management method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a session management method according to a second embodiment of the present invention;
fig. 3 is a flowchart illustrating a session management method according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a session management apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention.
Detailed Description
The embodiments of the present invention will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad invention. It should be further noted that, for convenience of description, only some structures, not all structures, relating to the embodiments of the present invention are shown in the drawings.
The embodiment of the invention aims at the problem that in the related technology, the requirement of high concurrent session is met by increasing the memory of the server, and when the server fails, an interactive system cannot be used; or, master-slave synchronization with a server memory is realized by introducing a Redis storage system, the stability of an interactive system is ensured, and the problems of high cost, complex installation, strong professional property and difficult maintenance are solved.
According to the embodiment of the invention, the hash value corresponding to the session identifier is calculated according to the session identifier of the session request, so that the interactive server is determined from the server cluster according to the hash value, the session request is routed to the interactive server, and the session request is responded through the interactive server. Therefore, different session requests are routed to different servers, so that the data processing burden of the same server is reduced, load balance is realized, the performance of the server is ensured, the stability and the robustness of an interactive system are improved, and meanwhile, when the same user sends the session request again, the session request is routed to the server with the context information of the session request, better service is provided for the user, the implementation mode is simple, and the cost is low.
A session management method, apparatus, device, and medium of an embodiment of the present invention are described below with reference to the accompanying drawings.
Example one
Fig. 1 is a flowchart of a session management method according to an embodiment of the present invention, where this embodiment is applicable to determining a scenario of an interaction server based on a session request, and the method may be executed by a session management apparatus, where the session management apparatus may be composed of hardware and/or software and may be integrated in a computer device, and the computer device may be any device having a data processing function. In this embodiment, the computer device is preferably a server, and the server refers to any server in a server cluster. The session management method specifically comprises the following steps:
s101, calculating a hash value corresponding to the session identifier according to the session identifier of the received session request.
In the embodiment of the present invention, the session request may include a session registration request, a session interaction request, and a session de-registration request.
In actual use, a user may interact with a machine device by sending a session request to the machine device. When the machine device receives a session request sent by a user, the session request can be randomly uploaded to any server in a server cluster of an interactive system, and a session identifier corresponding to the session request can be automatically carried during uploading. That is, the present embodiment further includes, before executing S101: receiving a session request sent by a user, and acquiring a session identifier corresponding to the session request. In the embodiment of the present invention, the session identifier may be represented by sessionId.
In this embodiment, the machine device may be any intelligent device with an interaction function, such as a smart phone, a smart home appliance, and the like. The intelligent appliance may be, but is not limited to: smart speakers, smart televisions, smart refrigerators, and the like.
Furthermore, the computer device may calculate, according to the obtained session identifier and according to a preset calculation rule, a hash value corresponding to the session identifier. The preset calculation rule refers to any rule capable of calculating the hash value according to the session identifier.
Since the session identifier may be a pure number, it may also be composed of letters and/or special characters. Therefore, in this embodiment, before calculating the hash value according to the session identifier, it is first determined whether the session identifier is a pure number, and if so, the hash value corresponding to the session identifier is calculated according to a preset calculation rule; if not, the session identifier is converted into a numerical value within a preset numerical value range according to a preset conversion rule, and then the hash value corresponding to the session identifier is calculated according to a calculation rule.
In this embodiment, the preset conversion rule refers to any rule capable of converting letters and/or special characters into numerical values. For example, American Standard Code for Information Interchange (ASCII), or a rule may be customized according to actual needs, which is not specifically limited herein.
The preset value range may be obtained from a parameter configuration file, or may be set in a user-defined manner according to actual application requirements, which is not specifically limited herein.
For example, if the session identifier is 10 bits, the last two bits of the session identifier may be used as a value range according to actual needs, and the corresponding value range is: 0-99. For another example, if the session identifier is 10 bits, the last three bits of the session identifier may be used as a value range, and the corresponding value range is: 0-999.
For example, in this embodiment, the hash value corresponding to the session identifier is calculated, a maximum number and a minimum number may be selected from numbers of each server in the server cluster, and a maximum value and a minimum value are selected from a value range corresponding to the session identifier; and calculating a hash value corresponding to the session request according to the maximum number, the minimum number, the maximum numerical value, the minimum numerical value and the session identifier.
In a specific implementation, the hash value corresponding to the session request may be calculated by the following formula (1):
Figure BDA0002279007620000061
wherein, k represents a hash value,
Figure BDA0002279007620000062
denotes rounding down, TmaxMaximum number, T, representing a server in a cluster of serversminMinimum number, O, representing a server in a cluster of serversmaxRepresenting the maximum value, O, of the range of values corresponding to the session identitymixAnd the minimum value in the numerical range corresponding to the session identifier is shown, and N is the numerical value corresponding to the session identifier.
It should be noted that, when the session identifier is determined to be a pure number, the hash value corresponding to the session identifier may be calculated according to the preset value range by using the above formula (1).
For example, assuming that the preset value range is obtained from the parameter configuration file, for example, the value range is 0 to 99, and the server cluster includes 10 servers, where the maximum number of the server is 10, the minimum number is 1, and the value corresponding to the session identifier is 9, the hash value may be calculated according to the above formula (1):
Figure BDA0002279007620000063
for another example, if the session identifier is a 10-digit number, and the technician uses the last three digits of the session identifier as a value range according to actual needs, the corresponding value range may be: 0-999, then when the server cluster includes 20 servers, wherein the maximum number of the server is 19, the minimum number is 0, and the session identifier corresponds to 111, the hash value can be calculated according to the above formula (1):
Figure BDA0002279007620000071
s102, determining an interactive server according to the hash value, and routing the session request to the interactive server, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
For example, in this embodiment, according to the hash value, a corresponding server is searched in a mapping relationship between a preset hash value and a server number, and the searched server is determined as an interactive server. The session request is then routed to the interaction server for responding to the session request by the interaction server.
The mapping relationship may be pre-stored in the parameter configuration file, that is, after the hash value corresponding to the session identifier is calculated, the computer device may obtain the mapping relationship between the preset hash value and the server number from the parameter configuration file, and then search the corresponding interaction server in the mapping relationship according to the hash value.
It should be noted that, in this embodiment, the mapping relationship between the preset hash value and the server number may be adaptively set according to the actual application requirement.
For example, if the server cluster includes 10 servers, and the servers in the server cluster are numbered in ascending order from 1 to 10, and the numerical range corresponding to the session identifier is [0,99], the preset mapping relationship may be as follows:
Figure BDA0002279007620000072
Figure BDA0002279007620000081
it should be noted that the mapping relationship between the hash value and the server number is only an exemplary illustration of the present embodiment, and is not limited to the specific one.
Continuing with the above example, if the preset mapping relationship between the hash value and the server number is the above example, then according to k being 1, the server with server number 1 in the server cluster can be determined to be the interactive server, and at this time, the session request can be routed to the server with server number 1, so as to perform a response operation through the server with server number 1.
In another implementation, the embodiment of the present invention may further determine the interaction server according to the received session request through a random policy or a polling policy.
In specific implementation, if a random strategy is adopted to determine the interactive server, one optional server in the server cluster can be used as the interactive server, and the session request is routed to the interactive server; and if the polling strategy is adopted to determine the interactive servers, routing the session requests to the corresponding servers in sequence according to the sequence of the servers in the server cluster.
It should be noted that, after the interactive server is determined by using the random policy and the polling policy, the mapping relationship between the session identifier corresponding to the session request and the server identifier needs to be stored in the database, so as to ensure that the session request of the same person is distributed to the same interactive server when the session request is subsequently performed again. The database may be a database in a data server, or may be a database in a computer device, which is not limited herein. In this embodiment, the server identifier is a server number.
For example, if a random policy is adopted to determine that the session identifier sessionID ═ 5 is routed to the server 2, {5- >2} may be stored in the database.
According to the session management method provided by the embodiment of the invention, the hash value corresponding to the session identifier is calculated according to the session identifier of the session request, and the interactive server is determined from the server cluster according to the hash value, so that the session request is responded through the interactive server. Therefore, different session requests are routed to different servers, so that the data processing burden of the same server is reduced, load balance is realized, the performance of the server is ensured, the stability and the robustness of an interactive system are improved, and meanwhile, when the same user sends the session request again, the session request is routed to the server with the context information of the session request, better service is provided for the user, the implementation mode is simple, and the cost is low.
On the basis of the above embodiment, S102 further includes:
and if the session time length of the session request routed to the interactive server exceeds a time length threshold value, deleting the session information corresponding to the session request in the interactive server.
In this embodiment, the session information may include: the server identifies the mapping relation between the conversation identification and the context information corresponding to the conversation request.
The duration threshold value can be obtained from the parameter configuration file, and relevant technicians store the duration threshold value parameters into the parameter configuration file through the background control interface in advance.
In actual use, during the interaction process between the user and the machine device, the user may forget to end the interaction with the machine device due to other things, so that the interactive connection is always in a connected state and the interaction server resource is consumed. In order to reduce the waste of the resources of the interactive server, in this embodiment, the established interactive connection duration may be detected at regular time according to the detection period obtained from the parameter configuration file, and the interactive server is controlled to perform a clearing operation on the session information corresponding to the session request according to the detection result.
In specific implementation, the last interaction time of the user and the machine equipment can be obtained from the interaction server, then the last interaction time is differed from the current time, and the difference value is compared with the duration threshold value. If the difference is smaller than or equal to the time length threshold, the user and the machine equipment are interacting normally; if the difference is greater than the duration threshold, it indicates that the user may forget to end the interaction with the machine device. The computer equipment can send a disconnection request to the interactive server to control disconnection of the interactive connection, so that the interactive server deletes the session information corresponding to the session request in the memory of the interactive server, and the resource occupancy rate of the interactive server is reduced.
The embodiment of the invention can reduce the waste of server resources and reduce the resource occupancy rate of the server by ending the interactive connection of which the session duration exceeds the duration threshold and deleting the session information corresponding to the session request in the interactive server.
On the basis of the above embodiment, S102 further includes: and sending heartbeat packets to the servers in the server cluster at regular time for heartbeat detection, and if any server does not respond normally, determining that the any server is abnormal and unavailable. When a new session request is received, the exception server is skipped and the interaction server is determined from the other available servers to route the session request to the interaction server. And if the abnormal server which is unavailable in the previous period normally responds when the heartbeat packet is sent to the servers in the server cluster again for heartbeat detection, determining that the abnormal server is recovered to be normal, determining that the server recovered to be normal is an interactive server when another new session request is received, and routing the other new session request to the determined interactive server, so that the session request can be normally processed all the time.
Example two
As can be seen from the above analysis, in the embodiment of the present invention, the hash value is calculated according to the session identifier of the session request, the interactive server is determined according to the hash value, the session request is routed to the interactive server, and the interactive server responds to the session request.
In the actual use process, when the user interacts with the machine equipment for the first time, the session registration operation can be performed first, that is, the session request sent by the user is the session registration request, so as to determine the interaction server according to the session identifier corresponding to the session registration request, and route the session registration request to the interaction server for the session registration operation, so as to lay a foundation for the subsequent session interaction. The above-mentioned situation of the session management method according to the present invention will be described with reference to fig. 2.
Fig. 2 is a flowchart illustrating a session management method according to a second embodiment of the present invention. As shown in fig. 2, the session management method includes the following steps:
s201, according to the session identification of the received session request, calculating a hash value corresponding to the session identification.
Wherein, the session request is a session registration request.
S202, determining an interactive server according to the hash value, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
S203, when the session request is routed to the interactive server, if the interactive server is abnormal, a new interactive server is determined again according to a preset strategy, so that the session request is routed to the new interactive server.
Because the interactive server may be unavailable due to power failure or other reasons, in order to perform the session registration operation normally, the embodiment of the present invention may determine a new interactive server from the server cluster again according to the preset policy, so as to route the session registration request to the new interactive server, and respond to the session registration request through the new interactive server.
In the embodiment of the present invention, the preset policy includes: a random selection strategy and a polling selection strategy.
Correspondingly, the step of re-determining a new interaction server according to the preset policy in this embodiment may include:
if the preset strategy is a random selection strategy, selecting any server in the server cluster as a new interactive server;
and if the preset strategy is a polling selection strategy, selecting a server as a new interactive server according to the sequence of the servers in the server cluster.
Further, after the new interaction server is determined, the interaction server can be determined in order to facilitate the subsequent user to initiate a session interaction request or a session de-registration operation. The embodiment of the invention also establishes the mapping relation between the session identifier corresponding to the session registration request and the new interactive server, and stores the mapping relation between the session identifier and the new interactive server, so that when a subsequent user initiates a session interaction request or a session de-registration request, the corresponding interactive server is directly determined based on the session identifier corresponding to the user session request.
The mapping relationship may be stored in a database in a data server, or may be stored in a database in a computer device, which is not limited herein.
For example, if the session identifier corresponding to the session registration request is 2 and the number of the new interaction server is 4, a mapping {2- >4} may be established, and {2- >4} may be stored, so that when the subsequent sessionID is 2, the computer device may determine that the interaction server is the server with the number of 4 from the stored mapping, so as to route the session request to the server 4.
According to the session management method provided by the embodiment of the invention, when the session request is routed to the interactive server as the session registration request, if the interactive server is determined to be abnormal, the new interactive server is determined again according to the preset strategy so as to route the session request to the new interactive server, so that when any server in the server cluster is abnormal, the session request can be routed to other servers which normally operate, and the interactive system can still be continuously used when any server is abnormal, thereby improving the robustness and stability of the interactive system and improving the use experience of users.
EXAMPLE III
As can be seen from the above analysis, in the embodiment of the present invention, when the session request is routed to the interactive server, if the interactive server is abnormal, the new interactive server may be determined again according to the preset policy, so that the session request is routed to the new interactive server, and the new interactive server responds to the session request.
In another implementation scenario of the present invention, the session request may also be a session interaction request or a session de-registration request, and when the session request is routed to an interaction server determined based on a hash value calculated by a session identifier corresponding to the session request, if the interaction server is abnormal, an abnormal reminding message may also be sent to the user, so that the user may take corresponding operations according to the reminding message. The above-mentioned situation of the session management method according to the present invention will be described with reference to fig. 3.
Fig. 3 is a flowchart illustrating a session management method according to a third embodiment of the present invention. As shown in fig. 3, the session management method includes the following steps:
s301, according to the session identification of the received session request, calculating the hash value corresponding to the session identification.
The session request is a session interaction request or a session deregistration request;
s302, determining an interactive server according to the hash value, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
Because the session identifier corresponding to the session request sent by the same user is fixed, the hash value calculated by the formula (1) in the first embodiment is adopted according to the session identifier corresponding to the session request, and the interaction server determined according to the hash value is the same as the interaction server determined during session registration, so that the same user can be ensured to be allocated to the same server when interacting with the machine equipment, and the intention of the user can be accurately understood and responded by using the context information stored in the server memory.
S303, when the session request is routed to the interactive server, if the interactive service is abnormal, an abnormal reminding message is sent to the user.
In the embodiment of the present invention, the abnormal alert message may be sent to the user by a voice broadcast method, or may be sent by other methods, which is not limited herein.
Illustratively, if the session request is routed to the interaction server and it is determined that the interaction server is abnormal and cannot be used normally, the computer device sends an abnormal reminding message to the user, so that the user re-initiates a session registration request as required, and performs session interaction operation based on the interaction server determined by new registration, or performs interaction operation after waiting for the interaction server to recover to normal.
If the session registration request is reinitiated as needed, the session registration operation is performed by using the implementation manner of the second embodiment, which is not described in detail herein.
Example four
In order to achieve the above object, an embodiment of the present invention further provides a session management apparatus. Fig. 4 is a schematic structural diagram of a session management apparatus according to a fourth embodiment of the present invention. As shown in fig. 4, the session management apparatus 400 according to the embodiment of the present invention includes: a calculation module 412 and a processing module 414.
The calculating module 412 is configured to calculate, according to a session identifier of the received session request, a hash value corresponding to the session identifier;
a processing module 414, configured to determine an interaction server according to the hash value, and route the session request to the interaction server, where the interaction server is configured to respond to the session request.
As an optional implementation manner of the embodiment of the present invention, the calculation module 412 is specifically configured to:
selecting a maximum number and a minimum number from the numbers of the servers in the server cluster, and selecting a maximum value and a minimum value from the value range corresponding to the session identifier;
and calculating a hash value corresponding to the session request according to the maximum number, the minimum number, the maximum numerical value, the minimum numerical value and the session identifier.
As an optional implementation manner of the embodiment of the present invention, the session request is a session registration request;
correspondingly, the processing module 414 is specifically configured to:
and if the interaction server is abnormal, re-determining a new interaction server according to a preset strategy so as to route the session request to the new interaction server.
As an optional implementation manner of the embodiment of the present invention, the preset policy includes: a random selection strategy and a polling selection strategy.
Accordingly, the processing module 414 is further configured to:
if the preset strategy is a random selection strategy, selecting any server in the server cluster as a new interactive server;
and if the preset strategy is a polling selection strategy, selecting a server as a new interactive server according to the sequence of the servers in the server cluster.
As an optional implementation manner of the embodiment of the present invention, the session management apparatus 400 further includes a storage module.
The storage module is used for establishing a mapping relation between the session identifier and the new interactive server and storing the mapping relation between the session identifier and the new interactive server.
As an optional implementation manner of the embodiment of the present invention, the session request is a session interaction request or a session deregistration request;
accordingly, the processing module 412 is further configured to:
and if the interactive service is abnormal, sending an abnormal reminding message to the user.
As an optional implementation manner of the embodiment of the present invention, the apparatus 400 further includes: and a storage module.
And the storage module is used for deleting the session information corresponding to the session request in the interactive server if the session duration of the session request routed to the interactive server exceeds a duration threshold.
It should be noted that the foregoing explanation on the embodiment of the session management method is also applicable to the session management apparatus of this embodiment, and the implementation principle thereof is similar and will not be described herein again.
According to the session management device provided by the embodiment of the invention, the hash value corresponding to the session identifier is calculated according to the session identifier of the session request, and the interactive server is determined from the server cluster according to the hash value, so that the session request is responded through the interactive server. Therefore, different session requests are routed to different servers, so that the data processing burden of the same server is reduced, load balance is realized, the performance of the server is ensured, the stability and the robustness of an interactive system are improved, and meanwhile, when the same user sends the session request again, the session request is routed to the server with the context information of the session request, better service is provided for the user, the implementation mode is simple, and the cost is low.
EXAMPLE five
Referring to fig. 5, the present embodiment provides a computer apparatus 500, which includes: one or more processors 510; the storage 512 is configured to store one or more programs, and when the one or more programs are executed by the one or more processors 510, the one or more processors 510 implement the session management method provided in the embodiment of the present invention, including:
calculating a hash value corresponding to a session identifier according to the session identifier of the received session request;
and determining an interactive server according to the hash value, and routing the session request to the interactive server, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
Of course, it can be understood by those skilled in the art that processor 510 may also implement the technical solution of the session management method provided by any embodiment of the present invention.
As shown in fig. 5, computer device 500 is in the form of a general purpose computing device. The components of computer device 500 may include, but are not limited to: one or more processors or processors 510, a memory device 512, and a bus 18 that couples various system components including the memory device 512 and the processors 510.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 500 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by computer device 500 and includes both volatile and nonvolatile media, removable and non-removable media.
The storage 512 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. The computer device 500 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, and commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. Storage 512 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
The computer device 500 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with the computer device 500, and/or with any devices (e.g., network card, modem, etc.) that enable the computer device 500 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Moreover, computer device 500 may also communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet) via network adapter 20. As shown, the network adapter 20 communicates with the other modules of the computer device 500 via the bus 18. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in conjunction with computer device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processor 510 executes various functional applications and data processing, for example, implementing a session management method provided by an embodiment of the present invention, by executing programs stored in the storage device 512.
It should be noted that the foregoing explanation on the embodiment of the session management method is also applicable to the computer device of this embodiment, and the implementation principle thereof is similar and will not be described herein again.
According to the computer device provided by the embodiment of the invention, the hash value corresponding to the session identifier is calculated according to the session identifier of the session request, and the interactive server is determined from the server cluster according to the hash value, so that the session request is responded through the interactive server. Therefore, different session requests are routed to different servers, so that the data processing burden of the same server is reduced, load balance is realized, the performance of the server is ensured, the stability and the robustness of an interactive system are improved, and meanwhile, when the same user sends the session request again, the session request is routed to the server with the context information of the session request, better service is provided for the user, the implementation mode is simple, and the cost is low.
EXAMPLE six
In order to achieve the above object, the present invention also provides a computer-readable storage medium. A computer-readable storage medium provided in an embodiment of the present invention stores thereon a computer program, which when executed by a processor implements a session management method of an embodiment of the present invention, the method including:
calculating a hash value corresponding to a session identifier according to the session identifier of the received session request;
and determining an interactive server according to the hash value, and routing the session request to the interactive server, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
Of course, the computer-readable storage medium provided by the embodiments of the present invention and having the computer program executable instructions stored thereon are not limited to the method operations described above, and may also perform related operations in the session management method provided by any embodiment of the present invention.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method for session management, the method comprising:
calculating a hash value corresponding to a session identifier according to the session identifier of the received session request;
and determining an interactive server according to the hash value, and routing the session request to the interactive server, wherein the interactive server is any server in a server cluster and is used for responding to the session request.
2. The method according to claim 1, wherein calculating, according to a session identifier of the received session request, a hash value corresponding to the session identifier specifically includes:
selecting a maximum number and a minimum number from the numbers of the servers in the server cluster, and selecting a maximum value and a minimum value from the value range corresponding to the session identifier;
and calculating a hash value corresponding to the session request according to the maximum number, the minimum number, the maximum numerical value, the minimum numerical value and the session identifier.
3. The method of claim 1, wherein the session request is a session registration request;
correspondingly, routing the session request to the interaction server further comprises:
and if the interaction server is abnormal, re-determining a new interaction server according to a preset strategy so as to route the session request to the new interaction server.
4. The method of claim 3, wherein the preset policy comprises: a random selection strategy and a polling selection strategy.
Correspondingly, the step of re-determining the new interaction server according to the preset strategy comprises the following steps:
if the preset strategy is a random selection strategy, selecting any server in the server cluster as a new interactive server;
and if the preset strategy is a polling selection strategy, selecting a server as a new interactive server according to the sequence of the servers in the server cluster.
5. The method of claim 4, wherein after re-determining the new interaction server according to the predetermined policy, further comprising:
and establishing a mapping relation between the session identifier and the new interaction server, and storing the mapping relation between the session identifier and the new interaction server.
6. The method of claim 1, wherein the session request is a session interaction request or a session de-registration request;
correspondingly, routing the session request to the interaction server further comprises:
and if the interactive service is abnormal, sending an abnormal reminding message to the user.
7. The method of claim 1, further comprising:
and if the session time length of the session request routed to the interactive server exceeds a time length threshold value, deleting the session information corresponding to the session request in the interactive server.
8. A session management apparatus, comprising:
the computing module is used for computing a hash value corresponding to the session identifier according to the session identifier of the received session request;
and the processing module is used for determining an interactive server according to the hash value and routing the session request to the interactive server, and the interactive server is used for responding to the session request.
9. A computer device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a session management method as recited in any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a session management method according to any one of claims 1 to 7.
CN201911133671.4A 2019-11-19 2019-11-19 Session management method, device, equipment and medium Active CN110839084B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911133671.4A CN110839084B (en) 2019-11-19 2019-11-19 Session management method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911133671.4A CN110839084B (en) 2019-11-19 2019-11-19 Session management method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN110839084A true CN110839084A (en) 2020-02-25
CN110839084B CN110839084B (en) 2022-04-05

Family

ID=69576701

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911133671.4A Active CN110839084B (en) 2019-11-19 2019-11-19 Session management method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN110839084B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112311876A (en) * 2020-10-30 2021-02-02 武汉绿色网络信息服务有限责任公司 Method and device for determining back-end device of current session through load balancing device
CN113206877A (en) * 2021-04-29 2021-08-03 工银科技有限公司 Session keeping method and device
CN113391759A (en) * 2020-03-13 2021-09-14 华为技术有限公司 Communication method and device
CN113762857A (en) * 2020-11-24 2021-12-07 北京沃东天骏信息技术有限公司 Inventory deduction method, device, equipment and storage medium
CN113793612A (en) * 2021-09-15 2021-12-14 京东科技信息技术有限公司 Model service updating method and device and storage medium
CN115002131A (en) * 2022-05-24 2022-09-02 中欣链证数字科技有限公司 User request distribution method, device, equipment and system
CN116436855A (en) * 2023-06-12 2023-07-14 建信金融科技有限责任公司 Data information processing method, device, electronic equipment and medium
WO2023165429A1 (en) * 2022-03-01 2023-09-07 百果园技术(新加坡)有限公司 Session state management method and system, apparatus, device, and storage medium

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002342298A (en) * 2001-05-11 2002-11-29 Fujitsu Ltd Client server type information processing system and parallel load balance system
CN101702645A (en) * 2009-11-30 2010-05-05 中国人民解放军信息工程大学 Three-side password authentication key exchange method
CN103294785A (en) * 2013-05-17 2013-09-11 华中科技大学 Packet-based metadata server cluster management method
CN104836839A (en) * 2015-03-30 2015-08-12 南京大学 Universal user self-defining session system and session management method thereof
CN105591959A (en) * 2014-10-24 2016-05-18 华耀(中国)科技有限公司 System and method for load balancing by SSL session resuming
CN105812351A (en) * 2016-02-23 2016-07-27 平安科技(深圳)有限公司 Method and system for sharing session
CN106101290A (en) * 2016-08-25 2016-11-09 Tcl集团股份有限公司 A kind of method and system of server cluster management
CN106951425A (en) * 2016-01-07 2017-07-14 阿里巴巴集团控股有限公司 A kind of mapping method and equipment
CN107995304A (en) * 2017-12-13 2018-05-04 杭州迪普科技股份有限公司 A kind of session keeping method and device based on cookie
US20180351926A1 (en) * 2017-06-02 2018-12-06 Arris Enterprises Llc Secure shell (ssh) server public key validation by a ssh client in a high volume device deployment
CN109361778A (en) * 2018-12-18 2019-02-19 厦门商集网络科技有限责任公司 A kind of method and terminal managing session
CN109547512A (en) * 2017-09-22 2019-03-29 中国移动通信集团浙江有限公司 A kind of method and device of the distributed Session management based on NoSQL
CN109600302A (en) * 2018-11-27 2019-04-09 金瓜子科技发展(北京)有限公司 A kind of method, apparatus orderly communicated, storage medium and electronic equipment
CN109688006A (en) * 2018-12-24 2019-04-26 北京天元特通科技有限公司 Support the high performance network log information distribution method of object set group dynamic instrumentation
CN109936635A (en) * 2019-03-12 2019-06-25 北京百度网讯科技有限公司 Load-balancing method and device

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002342298A (en) * 2001-05-11 2002-11-29 Fujitsu Ltd Client server type information processing system and parallel load balance system
CN101702645A (en) * 2009-11-30 2010-05-05 中国人民解放军信息工程大学 Three-side password authentication key exchange method
CN103294785A (en) * 2013-05-17 2013-09-11 华中科技大学 Packet-based metadata server cluster management method
CN105591959A (en) * 2014-10-24 2016-05-18 华耀(中国)科技有限公司 System and method for load balancing by SSL session resuming
CN104836839A (en) * 2015-03-30 2015-08-12 南京大学 Universal user self-defining session system and session management method thereof
CN106951425A (en) * 2016-01-07 2017-07-14 阿里巴巴集团控股有限公司 A kind of mapping method and equipment
CN105812351A (en) * 2016-02-23 2016-07-27 平安科技(深圳)有限公司 Method and system for sharing session
CN106101290A (en) * 2016-08-25 2016-11-09 Tcl集团股份有限公司 A kind of method and system of server cluster management
US20180351926A1 (en) * 2017-06-02 2018-12-06 Arris Enterprises Llc Secure shell (ssh) server public key validation by a ssh client in a high volume device deployment
CN109547512A (en) * 2017-09-22 2019-03-29 中国移动通信集团浙江有限公司 A kind of method and device of the distributed Session management based on NoSQL
CN107995304A (en) * 2017-12-13 2018-05-04 杭州迪普科技股份有限公司 A kind of session keeping method and device based on cookie
CN109600302A (en) * 2018-11-27 2019-04-09 金瓜子科技发展(北京)有限公司 A kind of method, apparatus orderly communicated, storage medium and electronic equipment
CN109361778A (en) * 2018-12-18 2019-02-19 厦门商集网络科技有限责任公司 A kind of method and terminal managing session
CN109688006A (en) * 2018-12-24 2019-04-26 北京天元特通科技有限公司 Support the high performance network log information distribution method of object set group dynamic instrumentation
CN109936635A (en) * 2019-03-12 2019-06-25 北京百度网讯科技有限公司 Load-balancing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
LWJ~: ""哈希算法"", 《CSDN》 *

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113391759A (en) * 2020-03-13 2021-09-14 华为技术有限公司 Communication method and device
CN113391759B (en) * 2020-03-13 2024-04-09 华为云计算技术有限公司 Communication method and equipment
CN112311876A (en) * 2020-10-30 2021-02-02 武汉绿色网络信息服务有限责任公司 Method and device for determining back-end device of current session through load balancing device
CN113762857A (en) * 2020-11-24 2021-12-07 北京沃东天骏信息技术有限公司 Inventory deduction method, device, equipment and storage medium
CN113206877A (en) * 2021-04-29 2021-08-03 工银科技有限公司 Session keeping method and device
CN113793612A (en) * 2021-09-15 2021-12-14 京东科技信息技术有限公司 Model service updating method and device and storage medium
CN113793612B (en) * 2021-09-15 2024-04-09 京东科技信息技术有限公司 Updating method and device of model service and storage medium
WO2023165429A1 (en) * 2022-03-01 2023-09-07 百果园技术(新加坡)有限公司 Session state management method and system, apparatus, device, and storage medium
CN115002131A (en) * 2022-05-24 2022-09-02 中欣链证数字科技有限公司 User request distribution method, device, equipment and system
CN115002131B (en) * 2022-05-24 2024-03-01 中欣链证数字科技有限公司 User request distribution method, device, equipment and system
CN116436855A (en) * 2023-06-12 2023-07-14 建信金融科技有限责任公司 Data information processing method, device, electronic equipment and medium
CN116436855B (en) * 2023-06-12 2023-09-12 建信金融科技有限责任公司 Data information processing method, device, electronic equipment and medium

Also Published As

Publication number Publication date
CN110839084B (en) 2022-04-05

Similar Documents

Publication Publication Date Title
CN110839084B (en) Session management method, device, equipment and medium
CN111737022A (en) Interface calling method, system, equipment and medium based on micro-service
US20230161541A1 (en) Screen projection method and system
CN114697391B (en) Data processing method, device, equipment and storage medium
CN107342929B (en) Method, device and system for sending new message notification
CN113012695B (en) Intelligent control method and device, electronic equipment and computer readable storage medium
US10389811B2 (en) Cloud data transmission system and dynamic data flow decentralizing method thereof
CN108833588B (en) Session processing method and device
CN106992893A (en) The management method and device of router
EP3723343A1 (en) Resource processing method and system, storage medium and electronic device
CN114513552B (en) Data processing method, device, equipment and storage medium
CN116032614A (en) Container network micro-isolation method, device, equipment and medium
CN113691937B (en) Method for determining position information, cloud mobile phone and terminal equipment
CN115412993A (en) Relay discovery method, system, device and storage medium
CN113986995A (en) Request distribution method and device, storage medium and electronic equipment
CN114553778A (en) Heartbeat control method and device, storage medium and electronic equipment
CN113946376A (en) Load adjustment method and device, electronic equipment and storage medium
CN113726881A (en) Communication connection establishment method, related device and computer program product
CN112714420A (en) Network access method and device of wifi hotspot providing equipment and electronic equipment
CN113746909A (en) Network connection method, device, electronic equipment and computer readable storage medium
CN113420275A (en) Data connection processing method, related device and computer program product
CN112615916A (en) File deployment method and device, electronic equipment and storage medium
CN113904980B (en) Channel switching method, device, switch and storage medium
WO2022188509A1 (en) Method and apparatus for task processing in distributed environment, and electronic device and medium
CN115460000B (en) Session processing method, network device, terminal device and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220919

Address after: 25 Financial Street, Xicheng District, Beijing 100033

Patentee after: CHINA CONSTRUCTION BANK Corp.

Address before: 25 Financial Street, Xicheng District, Beijing 100033

Patentee before: CHINA CONSTRUCTION BANK Corp.

Patentee before: Jianxin Financial Science and Technology Co.,Ltd.