CN106713391A - Session information sharing method and sharing system - Google Patents
Session information sharing method and sharing system Download PDFInfo
- Publication number
- CN106713391A CN106713391A CN201510780728.5A CN201510780728A CN106713391A CN 106713391 A CN106713391 A CN 106713391A CN 201510780728 A CN201510780728 A CN 201510780728A CN 106713391 A CN106713391 A CN 106713391A
- Authority
- CN
- China
- Prior art keywords
- session
- caching server
- server group
- information
- caching
- 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
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
Abstract
The invention discloses a session information sharing method and sharing system. The method comprises the steps that a session central controller is erected between cluster application servers and a cache server group, and session information is stored in the cache server group; each cluster application server is configured so that the cluster application server is enabled to transfer an http request to the session central controller when the cluster application server receives the http request transmitted by a client side; the session central controller is configured so that the session central controller is enabled to manage the session information stored in the cache server group according to the http request transferred by the cluster application servers and manage transmission of the session information so as to realize sharing of the session information between the cluster application servers and the cache server group. According to the technical scheme, the session central controller is erected for unified management of the session information stored in the cache server group so as to ensure the consistency and the security of the session information in the session information sharing process.
Description
Technical field
The present invention relates to Internet communication technology field, more particularly to a kind of sharing method of session information
And shared system.
Background technology
With the popularization of network, B/S (Browser/Server, browser/server) system prevailing and
Large user's amount that B2C (Buisness to Custmoer, business to consumer) banding comes, single service
The design of device list application is the requirement that cannot meet required performance and function, in order to meet above-mentioned requirements, should
With server cluster pattern into effective solution.
The browser and the communication protocol generally http protocol of server used due to user, HTTP
Agreement is stateless protocol, and stateless refers to that agreement does not have memory capability for issued transaction.Lack state
If meaning that subsequent treatment needs to use information above, must retransmit, thus may cause every time
Connect the data volume increase of transmission.
Using the cookies of browser end, (cookies refers to some websites to distinguish user to prior art
Identity, carry out session tracking and be stored in the data on user local terminal) and server end session
Session solves stateless with complementing each other and asks.But under cluster environment, the request of user can be specific
Algorithm under be assigned on the application server of different machines, now session information is in different application service
Synchronization on device is particularly important.
Four kinds of existing session synchronous modes are as follows:
Mode one:Client cookies is locally stored;
General principle is:The session information of server end is stored in browser client cookies,
Cookies is transmitted to server by request every time.
Have the disadvantage:The data of storage can not be too many, and safety coefficient is low.
Mode two:Session copy functions are realized using tomat and jboss servers;
It is based on principle:Application server in cluster by such as multicast (IP multicast) and
IP sockets technologies and other servers share information.
Have the disadvantage:Performance drastically declines with the increase of server, easily causes broadcast storm, and
Session data need serializing, can influence performance;Additionally, when certain the local multicast of application is delayed
When being filled with, new multicast message cannot be just write, so as to session synchronizations cannot be completed.
Mode three:Use database purchase session;
General principle is:Session examples are corresponded in database table, it is complete by the read-write operation to table
Into the read-write operation of session.
Have the disadvantage:Program needs to customize the exploitation of finishing service layer and lasting layer operation, due to request every time
It is required for carrying out data base read-write, overhead is larger.
Mode four:Use buffer memory session;
It is based on principle:Method with mode three is similar, but due to being memory access, performance compares data
Storehouse is high.
Have the disadvantage:Program needs customization, increased workload, and the object data being stored in caching is required for
Serializing, it is less efficient;And caching server delay machine when, all session can lose.
Thus prior art could be improved and improve.
The content of the invention
In view of the above problems, the invention provides the sharing method and shared system of a kind of session information,
Shared with the high efficiency synchronous for realizing session information under cluster environment.
To reach above-mentioned purpose, the technical proposal of the invention is realized in this way:
On the one hand, a kind of sharing method of session information, methods described bag be the embodiment of the invention provides
Include:
Session master controllers, the caching are set up between cluster application server and caching server group
Be stored with session information in server group;
Configure each cluster application server so that cluster application server is receiving client transmission
During http request, session master controllers will be given in the http request;
Configuration session master controllers, make it according to the http request of any cluster application server transfer
The session information stored in management caching server group, and the transmission of session information is managed, it is real
Now the session information between cluster application server and caching server group is shared.
Preferably, session master controllers are configured, makes it according to any cluster application server transfer
The session information of http request management caching server group storage includes:
When the http request is session requests to create, session master controllers are according to receiving
The session requests to create of cluster application server transfer be locally generated session ID, and will generation
Session ID be added in the session requests to create;
The session requests to create serializing of session ID will be added with to caching server group, made
Caching server group stores the session information in session requests to create according to the session ID;
The session that order caching server group is returned creates pass signal, and is sent out to cluster application server
Send the session information with session id informations.
It is further preferred that when the session information created according to session requests to create is effective, matching somebody with somebody
Session master controllers are put, makes it slow according to the management of the http request of any cluster application server transfer
The session information for depositing server group storage also includes:
When another http request of any cluster application server transfer obtains request for session,
Session master controllers extract session ID in obtaining request from the session, and are locally stored with it
Session ID contrast matching;
Session acquisition requests are sent to the caching server group after the match is successful by contrast, make caching
Server group searches the corresponding session informations of session ID during session obtains request;
The session that order caching server group sends obtains pass signal, and session is obtained successfully
Session ID and its corresponding session information in signal are sent to cluster application server.
Preferably, when the session information created according to session requests to create is effective, session is configured
Master controller, makes it manage caching server according to the http request of any cluster application server transfer
The session information of group storage also includes:
When another http request of any cluster application server transfer updates request for session,
Session master controllers extract session ID in updating request from the session, and are locally stored with it
Session ID contrast matching;
The version number of session ID is added 1 after the match is successful by contrast, and version number after will Jia 1 adds
In updating request to session, caching server group is sent to, makes caching server group according to session ID
And its version number storage session updates the session information in request;
The session that order caching server group sends is updated successfully signal, and will state session and be updated to
Session ID session informations corresponding with its version number in function signal are sent to cluster application service
Device.
Preferably, methods described also includes:
Backup database is set;
Configuration session master controllers, make session master controllers real-time update in an asynchronous manner
Session information in the backup database;
And configuration session master controllers, it is created thread on startup and monitor caching server
Group, judge caching server group delay machine when, required session information is obtained from backup database;
Alert notice is initiated simultaneously, after the recovery of caching server group, the data duplication in backup database is arrived
Caching server group.
Preferably, methods described also includes:
Configuration session master controllers, make it in the http according to any cluster application server transfer
During the transmission of request management session information, nonsynchronous session information is intercepted, realize cluster environment
The synchronization of middle session information.
Preferably, caching server group includes a master cache server and at least from caching server, main
Caching server and it is Redis servers from caching server;
Master cache server is used for the communication with session master controllers, realizes the write-in of data, postpones
Deposit the reading that server realizes data;
Master cache server is realized and between caching server using the internal mechanism of Redis servers
Data syn-chronization.
On the other hand, a kind of shared system of session information, including cluster be the embodiment of the invention provides
Application server, session master controllers and caching server group;
Cluster application server, for when the http request that client sends is received, the http being asked
Session master controllers are given in asking;
Caching server group, for storing session information;
Session master controllers, the http request for receiving any cluster application server transfer, and
The session information that caching server group is stored, and management session are managed according to the http request
The transmission of information, realizes sharing for the session information between cluster application server and caching server group.
Preferably, when the http request of any cluster application server transfer is session requests to create,
Session master controllers, specifically for being locally generated session according to session requests to create
ID, the session ID of generation is added in session requests to create, and will be added with session ID
The serializing of session requests to create to caching server group;And sent for order caching server group
Session create pass signal, and to cluster application server send with session ID session
Information;
Caching server group, for storing the session in session requests to create according to session ID
Information, and send session establishment pass signals to session master controllers;
When the session information created according to session requests to create is effective,
Session master controllers, are further used for receiving and from any cluster application server transfer
Session extracts session ID in obtaining request, and the session ID contrasts being locally stored with it are matched, right
After the match is successful, session acquisition requests are sent to the caching server group;And for receiving
The session that caching server group sends obtains pass signal, and by session acquisition pass signals
Session ID and its corresponding session information are sent to the cluster application server;
Caching server group, for searching the corresponding session of session ID during session obtains request
Information, and session acquisition pass signals are sent to the session master controllers;
Or, when the session information created according to the session requests to create is effective,
Session master controllers, are further used for receiving and from the session of cluster application server transfer
Extraction session ID in request are updated, the session ID contrasts being locally stored with it are matched, contrast matching
After success, the version number of session ID is added 1, and the version number after Jia 1 is added to session more
In new request, the caching server group is sent to;And sent for receiving the caching server group
Session be updated successfully signal, and by the session be updated successfully session ID in signal and its
The corresponding session information of version number is sent to the cluster application server;
Caching server group, for storing the session more according to the session ID and its version number
Session information in new request, and session is updated successfully signal is sent to the control of session centers
Device.
Preferably, the system also includes backup database;The session master controllers, further
For the session information in backup database described in real-time update in an asynchronous manner;And session
Master controller creates thread and monitors caching server group on startup, is judging that caching server group delays machine
When, required session information is obtained from backup database;Alert notice is initiated simultaneously, is taken in caching
After business device group is recovered, by the data duplication in backup database to caching server group;
Wherein, caching server group includes a master cache server and at least from caching server, main slow
Deposit server and be Redis servers from caching server;
Master cache server is used for the communication with session master controllers, realizes the write-in of data, postpones
Deposit the reading that server realizes data;
Master cache server and he is realized using the internal mechanism of Redis servers between caching server
Between data syn-chronization.
The beneficial effect of the embodiment of the present invention is:The present invention takes the memory transfer of session information to caching
In business device, session information is stored using the ability for caching fast reading and writing, by cluster application service
Session master controllers are set up between device and caching server so that each http request of Client-initiated exists
Be related to cluster application server needs from caching server group obtain session information when, can be
Obtained from caching server group under the management of session master controllers, it is achieved thereby that under cluster environment
The high efficiency synchronous of session information are shared.Due to the present invention using session master controllers to storing
Session information in caching server group is managed collectively, therefore, it is possible to ensure that session information is shared
During session uniformity.
In a preferred approach, the monitoring by setting up backup database and session master controllers of the invention
Mechanism realizes the backup disaster tolerance in shared procedure, ensures when caching server group delays machine, can be timely
Switch data is originated, and maintains normal operating conditions;And by set up main Redis caching servers and from
Redis caching servers, the write-in of data is realized using main Redis caching servers, using from Redis
Caching server realizes the reading of data, lifts data processing speed, data interaction speed and number of links,
The high efficiency shared so as to realize session information.
Brief description of the drawings
Fig. 1 is the flow chart of the sharing method of the session information that the embodiment of the present invention one is provided;
Fig. 2 is the shared system composition structural representation of the session information that the embodiment of the present invention two is provided;
The workflow of service end in the shared system of the session information that Fig. 3 is provided for the embodiment of the present invention three
Cheng Tu;
The backup of service end is held in the shared system of the session information that Fig. 4 is provided for the embodiment of the present invention three
Calamity workflow diagram.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to this hair
Bright implementation method is described in further detail.
In offered load configuration without using in the case of consistency algorithm, user and cluster application server
Http request each time can be mapped on different cluster application servers, such result can be led
The loss of the session information for creating and preserving on other application server before cause, wherein session
Information typically refers to the user profile such as the account of user, logging status, it is also possible to preserve other special letters
Breath.
In order to avoid above-mentioned condition, whole design idea of the invention is:Can be answered the invention provides one kind
Entirety packing solution, by the memory transfer of session information to caching server, utilizes
Cache the ability of fast reading and writing to store session information, taken by cluster application server and caching
Session master controllers are set up between business device so that each http request of Client-initiated is being related to collection
Group's application server is needed when server group acquisition session information is cached, can be in session
Obtained from caching server group under the management of heart controller, synchronously in caching server
Session information is created, obtained and changed, it is achieved thereby that the synchronization of session information is shared;
And the present invention is also by session master controllers to the security of session information and the disaster tolerance of system
Property is realized.
Embodiment one:
The flow chart of the sharing method of the session information that Fig. 1 is provided for the present embodiment, as shown in figure 1,
Method in Fig. 1 includes:
S110, sets up session master controllers, institute between cluster application server and caching server group
State and be stored with caching server group session information.
S120, configures each cluster application server so that cluster application server is receiving client
During the http request of transmission, the session master controllers will be given in the http request.For example configure
The session information storage address of each cluster application server, refers to the session information storage address
To session master controllers, cluster application server receive client transmission http request when,
Session master controllers can will be given to according to session information storage address in the http request.
In this step, cluster application server is preferably tomcat servers.Tomcat servers are one
The web application servers of free open source code, belong to lightweight application server, in middle-size and small-size system
System and concurrent user be not it is many in the case of be commonly used, be the first-selection for developing and debugging JSP programs.
S130, configures session master controllers, makes it according to any cluster application server transfer
The session information stored in http request management caching server group, and management session information
Transmission, realizes sharing for the session information between cluster application server and caching server group.
In the present embodiment, a conversation procedure of session representative servers and browser, this process can
Being continuous, it is also possible to off and on.When client request session information for the first time, session
Master controller can calculate a session ID for identifying session information by particular algorithm, and
Control caching server group preserves the corresponding session informations of session ID, works as client browser
When (when session information remains valid) asks other resource, client browser can be by session ID
It is placed into the request header of http request, session master controllers receive cluster application server transfer
Http request after, it becomes possible to session ID, the session master controllers for obtaining the http request exist
The session information that the session ID are found in caching server group is returned to requestor and is used.
If necessary, session master controllers are by storing the letters of the session in caching server group
Breath does some conventional operations, such as reads, changes, deletes or destroys, the operating result of associative operation
To be stored in caching server group, so be achieved that using the unified management of session master controllers
The purpose of session information.When multiple cluster application services provide service response simultaneously, before response
The session information of each client is centrally stored in caching server group, and by session
Master controller is managed, therefore for client, the http request quilt no matter client sends
That cluster application server response is processed, and each client only has a session information, equivalent to
All application servers all have shared this part of session information, so as to solve cluster application server between
The problem that session information can not be shared.
Specifically, for configuring session master controllers in step S130, making it according to any cluster
The session information of the http request management caching server group storage of application server transfer includes:
When http request is session requests to create, session master controllers are according to the collection for receiving
The session requests to create of group's application server transfer are locally generated session ID, and will generate
Session ID are added in the session requests to create;
The session requests to create serializing of session ID will be added with to caching server group, make caching
Server group stores the session information in session requests to create according to the session ID;
The session establishment pass signals that the caching server group is returned are received, and to cluster application service
Device sends the session information with session id informations.
When the session information created according to session requests to create is effective, now session centers control
The session information that device processed passes through storage in following management by methods caching server groups:
When another http request of the cluster application server transfer obtains request for session,
Session master controllers extract session ID in obtaining request from the session, and are locally stored with it
Session ID contrast matching;
Session acquisition requests are sent to the caching server group after the match is successful by contrast, are made
The caching server group searches the corresponding session of session ID during the session obtains request
Information;
Receive the session that the caching server group sends and obtain pass signal, and by the session
Obtain session ID and its corresponding session information in pass signal and be sent to the cluster application clothes
Business device.
Or, now session master controllers are by storage in following management by methods caching server groups
Session information:
When another http request of cluster application server transfer updates request for session, session
Master controller extracts session ID, and the session being locally stored with it in updating request from the session
ID contrast matchings;
The version number of the session ID is added 1 after the match is successful by contrast, and by the version number after Jia 1
It is added in the session renewals request, is sent to the caching server group, makes the buffer service
Device group stores the session during the session updates request according to the session ID and its version number
Information;
Receive the session that the caching server group sends and be updated successfully signal, and by the session
The session ID session informations corresponding with its version number being updated successfully in signal are sent to the cluster
Application server.
The present embodiment stores in caching server group session information, by cluster application server
Session master controllers are set up and caching server group between, is managed using session master controllers
There is the session information in caching server group, and management cluster application server and caching server
The transmission of session information between group, the high efficiency synchronous for realizing session information under cluster environment are shared.
It should be noted that the present embodiment further configures session master controllers, make it according to certain
When the http request of platform cluster application server transfer manages the transmission of session information, intercept nonsynchronous
Session information, realizes the synchronization of session information in cluster environment.In actual applications, Ke Yitong
The version number for crossing session ID intercepts nonsynchronous session information, realizes session in cluster environment
The synchronization of information.For example assume there are multiple cluster application servers to be asked to session master controllers simultaneously
Update same session information of the storage in caching server, each cluster application server to
The session ID that the session that session master controllers send is updated in request correspond to unique version
Number, session master controllers update request in caching server according to each session for receiving
Session information be updated, more new capital of each session information covers previous session information,
It is right that the session that session master controllers send simultaneously according to multiple cluster application servers updates request
After same session information of the storage in caching server is updated, then taken to the plurality of cluster application
Business device sends final session information, it is achieved thereby that in cluster environment session information synchronization.
Explanation is needed further exist for, the caching server included by caching server in the present embodiment
Quantity needs to determine according to actual project demands that undersize item uses single caching server.
The caching server group of the present embodiment preferably includes a master cache server and at least and is taken from caching
Business device, master cache server and is Redis servers from caching server, and Redis is one and increases income
Write using ANSI C, support network, can be based on internal memory also can persistence log type,
Key-Value databases.
Master cache server is used for the communication with session master controllers, realizes the write-in of data, at least
One reading that data are realized from caching server, lifting data processing speed, data interaction speed and link
Quantity, the high efficiency shared so as to realize session information;Wherein, using the inside of Redis servers
Mechanism realizes master cache server and from the data syn-chronization between caching server.
In the preferred scheme of the present embodiment, the method in Fig. 1 also includes:
Backup database is set;
Configuration session master controllers, make session master controllers in an asynchronous manner, using with
In the session information identical mode real-time update backup database of management caching server group storage
Session information;
In actual applications, session master controllers are configured, it is created thread on startup and is monitored slow
Deposit server group, judge caching server group delay machine when, obtained from backup database needed for
Session information;Alert notice is initiated simultaneously, after the recovery of caching server group, by backup database
Data duplication to caching server group.
This preferred scheme is ensured by setting the monitoring mechanism of backup database and session master controllers
When caching server group delays machine, switch data can originate in time, maintain the normal operating conditions of system.
Embodiment two:
Based on the identical technical scheme of embodiment one, present embodiments provide a kind of being total to for session information
Enjoy system.
The composition structural representation of the shared system of the session information that Fig. 2 is provided for the present embodiment, such as schemes
Shown in 2, the system in Fig. 2 includes cluster application server, session master controllers and buffer service
Device group.
Cluster application server, for when the http request that client sends is received, by http request
It is given to session master controllers;
Caching server group, for storing session information;
Session master controllers, the http request for receiving any cluster application server transfer, and
The session information that the caching server group is stored, and management are managed according to the http request
The transmission of session information, realizes the session information between cluster application server and caching server group
It is shared.
Wherein, when the http request of any cluster application server transfer is session requests to create,
Session master controllers, specifically for being locally generated session according to session requests to create
ID, the session ID of generation is added in the session requests to create, and will be added with session
Caching server group is arrived in the session requests to create serializing of ID;And for order caching service
The session that device group sends creates pass signal, and is sent with session ID to cluster application server
The session information of information;
Caching server group, for storing the session in session requests to create according to session ID
Information, and send session establishment pass signals to session master controllers.
When the session information created according to session requests to create is effective,
Session master controllers, are further used for receiving and from any cluster application server transfer
Session extracts session ID in obtaining request, and the session ID contrasts being locally stored with it are matched,
Session acquisition requests are sent to the caching server group after the match is successful by contrast;And for connecing
The session acquisition pass signals that caching server group sends are received, and by session acquisition pass signals
Session ID and its corresponding session information be sent to cluster application server.
Caching server group, for searching the corresponding session of session ID during session obtains request
Information, and session acquisition pass signals are sent to session master controllers.
Or, when the session information created according to session requests to create is effective,
Session master controllers, are further used for receiving and from any cluster application server transfer
Session extracts session ID in updating request, and the session ID contrasts being locally stored with it are matched,
The version number of session ID is added 1, and the version number after Jia 1 is added to after the match is successful by contrast
Session is updated in request, is sent to the caching server group;And for receiving the buffer service
The session that device group sends is updated successfully signal, and the session is updated successfully into the session in signal
ID session informations corresponding with its version number are sent to cluster application server;
Caching server group, for storing the session more according to the session ID and its version number
Session information in new request, and session is updated successfully signal is sent to the control of session centers
Device.
Wherein, the quantity of the caching server included by the caching server in the present embodiment is needed according to reality
The project demands on border determine that undersize item can use single caching server.
The caching server group of the present embodiment preferably includes a master cache server and at least and is taken from caching
Business device, master cache server and is Redis servers from caching server, and Redis is one and increases income
Write using ANSI C, support network, can be based on internal memory also can persistence log type,
Key-Value databases.
Master cache server is used for the communication with session master controllers, realizes the write-in of data, at least
One reading that data are realized from caching server;Wherein, realized using the internal mechanism of Redis servers
Master cache server and from the data syn-chronization between caching server.
In a preferred scheme of the present embodiment, as shown in Fig. 2 the system in the present embodiment also includes
Backup database.
Session master controllers in this preferred scheme, are further used for real-time update in an asynchronous manner
Session information in the backup database;And monitor the caching for creating thread on startup
Server group, judge the caching server group delay machine when, obtained from the backup database needed for
Session information;Alert notice is initiated simultaneously, after caching server group recovery, will be described standby
Data duplication in part database is to the caching server group.
In another preferred scheme of the present embodiment, session master controllers are additionally operable to according to certain
When the http request of cluster application server transfer manages the transmission of session information, intercept nonsynchronous
Session information, realizes the synchronization of session information in cluster environment.
Embodiment three:
This implements the specific workflow of the session information shared system for specific illustrative embodiment two.
Fig. 3 is the workflow diagram of service end in the shared system of session information, as shown in figure 3, should
Shared system includes cluster application server, session master controllers, caching server group and data
Storehouse, wherein cluster application server, session master controllers, caching server group and database
Referring to embodiment two, present invention's function will not be repeated here.
The present embodiment illustrates certain the cluster application server head in client and cluster environment by Fig. 3
It is secondary set up http connect when, management of the session master controllers to session information:
Step 1, the http request that cluster application server sends according to client is controlled to session centers
Device sends session requests to create.
Step 2, session master controllers are locally generated according to the session requests to create for receiving
Session ID, and the session ID are added in session requests to create;
Step 3, the session requests to create that session master controllers will be added with session ID send
Give caching server group.
Step 4, caching server group performs newly-increased operation, i.e., store session wounds according to session ID
The session information built in request.
Step 5, caching server group sends session and creates pass signal to session master controllers.
Step 6, session master controllers receive the session and create pass signal, and with asynchronous side
Formula control Backup Data library storage session information.
Session information with session ID is sent to cluster by step 7, session master controllers
Application server.
Step 8, when the session information remains valid, cluster application server sends according to client
Another http request to session master controllers send session obtain request.
Step 9, session master controllers are received and obtain request from the session and extract session ID,
And the session ID contrasts being locally stored with it are matched.
Session after the match is successful, is obtained request hair by step 10, session master controllers in contrast
Give caching server group.
Step 11, caching server group perform inquiry operation, that is, search the session obtain request in
The corresponding session informations of session ID.
Session acquisition pass signals are sent to the control of session centers by step 12, caching server group.
Step 13, session master controllers receive the session and obtain pass signal.
Step 14, session master controllers by session obtain pass signal in session ID and its
Corresponding session information is sent to cluster application server.
Step 15, when the session information remains valid, cluster application server is sent out according to client
Another http request sent sends session and updates request to session master controllers.
Step 16, session master controllers are received and update request from the session and extract session ID,
And the session ID contrasts being locally stored with it are matched.
Step 17, session master controllers in session ID contrasts after the match is successful, by session ID
Version number add 1, and by the version number after Jia 1 be added to the session update request in, be sent to
Caching server group.
Step 18, caching server group is performed and updates operation, i.e., deposited according to session ID and its version number
Storage session updates the session information in request.
Session is updated successfully signal and is sent to the control of session centers by step 19, caching server group
Device.
Step 20, session master controllers receive the session and are updated successfully signal, and with asynchronous
Mode update the backup database session ID for session information.
Step 21, session master controllers by the session be updated successfully session ID in signal with
The corresponding session information of its version number is sent to cluster application server.
Fig. 4 is the backup disaster tolerance workflow diagram of service end in the shared system of session information, such as Fig. 4
Shown, the shared system includes cluster application server, session master controllers, caching server
Group and database, wherein cluster application server, session master controllers, caching server group and
Referring to embodiment two, present invention's function of database will not be repeated here.
The present embodiment illustrates the disaster tolerance performance of shared system by Fig. 4:
Step 1, session master controllers create the thread for monitoring caching server group on startup.
Step 2, the http request that cluster application server sends according to client is controlled to session centers
Device sends session operation requests.
Session operation requests in this step can be session requests to create, session in Fig. 3
Obtain request or session updates request.
Step 3, session master controllers receive the session operation requests, and according to the session
The type of operation requests is performed locally corresponding operation.
Be sent to for the session operation requests performed after corresponding operating by step 4, session master controllers
Caching server group.
Step 5, session master controllers send when error signal is received to backup database
Session operation requests, while initiating alert notice.
Step 6, backup database receives session operation requests, and according to the session operation requests
Corresponding operation is performed, corresponding session information is sent to session master controllers.
Step 7, the session information that session master controllers will be received is sent to cluster application service
Device.
Step 8, session master controllers continue to monitor caching server group.
Step 9, session master controllers caching server group recovery after, by backup database
Data duplication completes the backup disaster tolerance of the system to caching server group.
In sum, the invention provides the sharing method and shared system of a kind of session information, will
The memory transfer of session information is stored in caching server using the ability for caching fast reading and writing
Session information, is controlled by setting up session centers between cluster application server and caching server
Device so that each http request of Client-initiated is being related to cluster application server needs from buffer service
When device group obtains session information, can be under the management of session master controllers from buffer service
Obtained in device group, it is achieved thereby that the high efficiency synchronous of session information are shared under cluster environment.Due to this hair
Bright utilization session master controllers do unified pipe to storing the session information in caching server group
Reason, therefore, it is possible to ensure the uniformity of session in session information shared procedure.In a preferred approach,
The present invention was shared by setting up the monitoring mechanism of backup database and session master controllers and realizing
Backup disaster tolerance in journey, ensures when caching server group delays machine, switch data can originate in time, dimension
Hold normal operating conditions;And by setting up main Redis caching servers and from Redis caching servers,
The write-in of data is realized using main Redis caching servers, number is realized using from Redis caching servers
According to reading, lifting data processing speed, data interaction speed and number of links, so as to realize session
The high efficiency of information sharing.
Presently preferred embodiments of the present invention is the foregoing is only, protection model of the invention is not intended to limit
Enclose.All any modification, equivalent substitution and improvements made within the spirit and principles in the present invention etc.,
Comprising within the scope of the present invention.
Claims (10)
1. a kind of sharing method of session information, it is characterised in that methods described includes:
Session master controllers, the caching are set up between cluster application server and caching server group
Be stored with session information in server group;
Configure each cluster application server so that the cluster application server is receiving client hair
During the http request sent, the session master controllers will be given in the http request;
The session master controllers are configured, makes it according to the http of any cluster application server transfer
The session information stored in the request management caching server group, and management session information
Transmission, realizes being total to for the session information between the cluster application server and the caching server group
Enjoy.
2. sharing method according to claim 1, it is characterised in that the configuration session
Master controller, makes it according to the http request of any cluster application server transfer management caching clothes
The session information of business device group storage includes:
When the http request is session requests to create, the session master controllers are according to connecing
The session requests to create of the cluster application server transfer for receiving are locally generated session ID,
And the session ID of generation are added in the session requests to create;
The caching server is arrived in the session requests to create serializing that session ID will be added with
Group, makes the caching server group according in the session ID storage session requests to create
Session information;
The session establishment pass signals that the caching server group is returned are received, and to the cluster application
Server sends the session information with session id informations.
3. sharing method according to claim 2, it is characterised in that according to the session
When the session information that request to create is created is effective, the configuration session master controllers make
It manages what the caching server group was stored according to the http request of any cluster application server transfer
Session information also includes:
It is described when another http request of any cluster application server transfer obtains request for session
Session master controllers extract session ID in obtaining request from the session, and are locally stored with it
Session ID contrast matching;
Session acquisition requests are sent to the caching server group after the match is successful by contrast, are made
The caching server group searches the corresponding session of session ID during the session obtains request
Information;
Receive the session that the caching server group sends and obtain pass signal, and by the session
Obtain session ID and its corresponding session information in pass signal and be sent to the cluster application clothes
Business device.
4. sharing method according to claim 2, it is characterised in that according to the session
When the session information that request to create is created is effective, the configuration session master controllers make
It manages what the caching server group was stored according to the http request of any cluster application server transfer
Session information also includes:
When another http request of any certain cluster application server transfer updates request for session,
The session master controllers extract session ID in updating request from the session, and local with it
The session ID contrast matchings of storage;
The version number of the session ID is added 1 after the match is successful by contrast, and by the version number after Jia 1
It is added in the session renewals request, is sent to the caching server group, makes the buffer service
Device group stores the session during the session updates request according to the session ID and its version number
Information;
Receive the session that the caching server group sends and be updated successfully signal, and by the session
The session ID session informations corresponding with its version number being updated successfully in signal are sent to the cluster
Application server.
5. sharing method according to claim 1, it is characterised in that methods described also includes:
Backup database is set;
The session master controllers are configured, makes the session master controllers in an asynchronous manner
Session information in backup database described in real-time update;
And the session master controllers are configured, it is created thread on startup and monitor the caching
Server group, judge the caching server group delay machine when, obtained from the backup database needed for
Session information;Alert notice is initiated simultaneously, after caching server group recovery, will be described standby
Data duplication in part database is to the caching server group.
6. sharing method according to claim 1, it is characterised in that methods described also includes:
The session master controllers are configured, makes it according to any cluster application server transfer
Http request when managing the transmission of session information, intercept nonsynchronous session information, realize institute
State the synchronization of session information in cluster environment.
7. the sharing method according to any one of claim 1 to 6, it is characterised in that the caching
Server group include a master cache server and at least from caching server, the master cache server with
It is described to be Redis servers from caching server;
The master cache server is used for the communication with the session master controllers, realizes writing for data
Enter, the reading that data are realized from caching server;
Realize the master cache server with described from buffer service using the internal mechanism of Redis servers
Data syn-chronization between device.
8. a kind of shared system of session information, it is characterised in that including cluster application server,
Session master controllers and caching server group;
The cluster application server, for when the http request that client sends is received, by the http
The session master controllers are given in request;
The caching server group, for storing session information;
The session master controllers, the http request for receiving any cluster application server transfer,
And the session information that the caching server group is stored, and management are managed according to the http request
The transmission of session information, realizes the session information between cluster application server and caching server group
It is shared.
9. shared system according to claim 8, it is characterised in that when any cluster application service
When the http request of device transfer is session requests to create,
The session master controllers, specifically for locally being given birth to according to the session requests to create
Into session ID, the session ID of generation are added in the session requests to create, and will add
Caching server group is arrived in session requests to create serializing added with session ID;And it is slow for receiving
The session for depositing server group transmission creates pass signal, and is carried to cluster application server transmission
The session information of session ID;
The caching server group, for according in session ID storage session requests to create
Session information, and send session establishment pass signals to the session master controllers;
When the session information created according to the session requests to create is effective,
The session master controllers, are further used for receiving and from any cluster application server
The session of transfer extracts session ID in obtaining request, the session ID contrasts being locally stored with it
Session acquisition requests are sent to the caching server group after the match is successful by matching, contrast;And
Pass signal is obtained for the session that order caching server group sends, and session is obtained successfully
Session ID and its corresponding session information in signal are sent to the cluster application server;
The caching server group, it is corresponding for searching the session ID in session acquisition requests
Session information, and session acquisition pass signals are sent to the session master controllers;
Or, when the session information created according to the session requests to create is effective,
The session master controllers, are further used for receiving and from any cluster application server
The session of transfer extracts session ID in updating request, the session ID contrasts being locally stored with it
The version number of session ID is added 1, and the version number after Jia 1 is added after the match is successful by matching, contrast
It is added in session renewal requests, is sent to the caching server group;And for receiving the caching
The session that server group sends is updated successfully signal, and the session is updated successfully in signal
Session ID session informations corresponding with its version number are sent to the cluster application server;
The caching server group, for storing the session according to the session ID and its version number
The session information in request is updated, and session is updated successfully signal and be sent to the control of session centers
Device processed.
10. shared system according to claim 8, it is characterised in that the system also includes standby
Part database;The session master controllers, are further used for described in real-time update in an asynchronous manner
Session information in backup database;And the session master controllers create line on startup
Journey monitors the caching server group, judge the caching server group delay machine when, from the backup number
According to the session information needed for being obtained in storehouse;Alert notice is initiated simultaneously, it is extensive in the caching server group
After multiple, by the data duplication in the backup database to the caching server group;
Wherein, the caching server group includes a master cache server and at least from caching server,
The master cache server and described it is Redis servers from caching server;
The master cache server is used for the communication with the session master controllers, realizes writing for data
Enter, the reading that data are realized from caching server;
The master cache server and the inside machine between caching server using Redis servers
System realizes the data syn-chronization between them.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510780728.5A CN106713391B (en) | 2015-11-13 | 2015-11-13 | Session information sharing method and sharing system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510780728.5A CN106713391B (en) | 2015-11-13 | 2015-11-13 | Session information sharing method and sharing system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106713391A true CN106713391A (en) | 2017-05-24 |
CN106713391B CN106713391B (en) | 2019-12-27 |
Family
ID=58930432
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510780728.5A Active CN106713391B (en) | 2015-11-13 | 2015-11-13 | Session information sharing method and sharing system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106713391B (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107769961A (en) * | 2017-09-14 | 2018-03-06 | 广州西麦科技股份有限公司 | A kind of SDN controllers cluster and network system |
CN108121559A (en) * | 2017-12-29 | 2018-06-05 | 重庆金融资产交易所有限责任公司 | Configuration file method for pushing, server and storage medium |
CN108377247A (en) * | 2018-03-08 | 2018-08-07 | 北京车和家信息技术有限公司 | A kind of information push method and device |
CN109151061A (en) * | 2018-09-28 | 2019-01-04 | 视联动力信息技术股份有限公司 | A kind of date storage method and device |
CN109150936A (en) * | 2017-06-19 | 2019-01-04 | 北京宝兰德软件股份有限公司 | The sharing method and device of session object Session in a kind of distributed type assemblies |
CN110134372A (en) * | 2019-07-10 | 2019-08-16 | 启迪云计算有限公司 | A kind of rule-based zookeeper session external management system |
CN110300154A (en) * | 2019-05-30 | 2019-10-01 | 上海派拉软件股份有限公司 | More browser session sharing methods are realized based on plug-in unit |
CN111565209A (en) * | 2019-08-29 | 2020-08-21 | 杭州天宽科技有限公司 | Client instant messaging method, device, equipment and medium |
CN113590414A (en) * | 2021-06-30 | 2021-11-02 | 济南浪潮数据技术有限公司 | Server cluster information acquisition and caching method, device, equipment and medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1471713A1 (en) * | 2003-03-31 | 2004-10-27 | France Telecom | Method and system for controlling access to Internet sites via cache server |
CN201682522U (en) * | 2010-02-08 | 2010-12-22 | 阿里巴巴集团控股有限公司 | Conversation information storage system and application server |
CN103200212A (en) * | 2012-01-04 | 2013-07-10 | 中国移动通信集团公司 | Method and system achieving distributed conversation under cloud computing environment |
CN103428171A (en) * | 2012-05-17 | 2013-12-04 | 阿里巴巴集团控股有限公司 | Session processing method, application server and system |
CN103888499A (en) * | 2012-12-21 | 2014-06-25 | 中国科学院深圳先进技术研究院 | Distributed object processing method and system |
-
2015
- 2015-11-13 CN CN201510780728.5A patent/CN106713391B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1471713A1 (en) * | 2003-03-31 | 2004-10-27 | France Telecom | Method and system for controlling access to Internet sites via cache server |
CN201682522U (en) * | 2010-02-08 | 2010-12-22 | 阿里巴巴集团控股有限公司 | Conversation information storage system and application server |
CN103200212A (en) * | 2012-01-04 | 2013-07-10 | 中国移动通信集团公司 | Method and system achieving distributed conversation under cloud computing environment |
CN103428171A (en) * | 2012-05-17 | 2013-12-04 | 阿里巴巴集团控股有限公司 | Session processing method, application server and system |
CN103888499A (en) * | 2012-12-21 | 2014-06-25 | 中国科学院深圳先进技术研究院 | Distributed object processing method and system |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109150936A (en) * | 2017-06-19 | 2019-01-04 | 北京宝兰德软件股份有限公司 | The sharing method and device of session object Session in a kind of distributed type assemblies |
CN107769961A (en) * | 2017-09-14 | 2018-03-06 | 广州西麦科技股份有限公司 | A kind of SDN controllers cluster and network system |
CN108121559A (en) * | 2017-12-29 | 2018-06-05 | 重庆金融资产交易所有限责任公司 | Configuration file method for pushing, server and storage medium |
CN108377247A (en) * | 2018-03-08 | 2018-08-07 | 北京车和家信息技术有限公司 | A kind of information push method and device |
CN108377247B (en) * | 2018-03-08 | 2021-02-26 | 北京车和家信息技术有限公司 | Message pushing method and device |
CN109151061A (en) * | 2018-09-28 | 2019-01-04 | 视联动力信息技术股份有限公司 | A kind of date storage method and device |
CN110300154A (en) * | 2019-05-30 | 2019-10-01 | 上海派拉软件股份有限公司 | More browser session sharing methods are realized based on plug-in unit |
CN110134372A (en) * | 2019-07-10 | 2019-08-16 | 启迪云计算有限公司 | A kind of rule-based zookeeper session external management system |
CN111565209A (en) * | 2019-08-29 | 2020-08-21 | 杭州天宽科技有限公司 | Client instant messaging method, device, equipment and medium |
CN113590414A (en) * | 2021-06-30 | 2021-11-02 | 济南浪潮数据技术有限公司 | Server cluster information acquisition and caching method, device, equipment and medium |
Also Published As
Publication number | Publication date |
---|---|
CN106713391B (en) | 2019-12-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106713391A (en) | Session information sharing method and sharing system | |
US9460185B2 (en) | Storage device selection for database partition replicas | |
CN103812849B (en) | A kind of local cache update method, system, client and server | |
CN104580226B (en) | A kind of system and method for shared session data | |
CN105393220B (en) | System and method for disposing dotted virtual server in group system | |
CN105245373B (en) | A kind of container cloud platform system is built and operation method | |
CN104823170B (en) | Distributed caching cluster management | |
US7783763B2 (en) | Managing stateful data in a partitioned application server environment | |
CN104735098B (en) | The control method and control system of session information | |
CN102426594B (en) | Method and system for operating database | |
CN109327539A (en) | A kind of distributed block storage system and its data routing method | |
CN108183961A (en) | A kind of distributed caching method based on Redis | |
US20090144338A1 (en) | Asynchronously replicated database system using dynamic mastership | |
CN110149382A (en) | Data synchronous method, system, primary server, sync client and medium | |
CN110351246A (en) | Server cluster system Socket management method and device | |
US20090144220A1 (en) | System for storing distributed hashtables | |
CN104011701A (en) | Content delivery network | |
CN101442558B (en) | Method and system for providing index service for P2SP network | |
CN103605698A (en) | Cloud database system used for distributed heterogeneous data resource integration | |
CN106657314A (en) | Cross-data center data synchronization system and method | |
CN105868231A (en) | Cache data updating method and device | |
CN109639773B (en) | Dynamically constructed distributed data cluster control system and method thereof | |
CN109783151B (en) | Method and device for rule change | |
CN103793485A (en) | Method for inquiring network data by client terminal based on cached data | |
CN106921721A (en) | A kind of server, conversation managing method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP02 | Change in the address of a patent holder | ||
CP02 | Change in the address of a patent holder |
Address after: Room 810, 8 / F, 34 Haidian Street, Haidian District, Beijing 100080 Patentee after: BEIJING D-MEDIA COMMUNICATION TECHNOLOGY Co.,Ltd. Address before: 100089 Beijing city Haidian District wanquanzhuang Road No. 28 Wanliu new building 6 storey block A room 602 Patentee before: BEIJING D-MEDIA COMMUNICATION TECHNOLOGY Co.,Ltd. |