[go: up one dir, main page]

CN105357222B - A kind of distribution Session management middleware - Google Patents

A kind of distribution Session management middleware Download PDF

Info

Publication number
CN105357222B
CN105357222B CN201510894376.6A CN201510894376A CN105357222B CN 105357222 B CN105357222 B CN 105357222B CN 201510894376 A CN201510894376 A CN 201510894376A CN 105357222 B CN105357222 B CN 105357222B
Authority
CN
China
Prior art keywords
session
information
session information
request
buffer pool
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510894376.6A
Other languages
Chinese (zh)
Other versions
CN105357222A (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.)
State Grid Information and Telecommunication Group Co Ltd
NARI Group Corp
State Grid Corp of China SGCC
Original Assignee
State Grid Information and Telecommunication Group Co Ltd
NARI Group Corp
State Grid Corp of China SGCC
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 State Grid Information and Telecommunication Group Co Ltd, NARI Group Corp, State Grid Corp of China SGCC filed Critical State Grid Information and Telecommunication Group Co Ltd
Priority to CN201510894376.6A priority Critical patent/CN105357222B/en
Publication of CN105357222A publication Critical patent/CN105357222A/en
Application granted granted Critical
Publication of CN105357222B publication Critical patent/CN105357222B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/50Network services
    • H04L67/56Provisioning of proxy services
    • 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
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

本申请公开了一种分布式Session管理中间件,包括Session生命周期管理模块和Session存储器;Session生命周期管理模块用于当用户通过浏览器向服务器集群系统发送的本次会话请求为首次会话请求时,创建与本次会话请求对应的Session信息,并将该Session信息发送至Session存储器;Session存储器用于对每次Session生命周期管理模块发送的Session信息进行存储,并且当有新的节点服务器被添加到服务器集群系统中时,通过中心节点服务器,将自身存储的所有Session信息下发至新的节点服务器。本申请提高了对Session信息的管理效率,避免了大量信息同步。

This application discloses a distributed session management middleware, including a session lifecycle management module and a session memory; the session lifecycle management module is used when the session request sent by the user to the server cluster system through the browser is the first session request , create the Session information corresponding to this session request, and send the Session information to the Session memory; the Session memory is used to store the Session information sent by the Session life cycle management module each time, and when a new node server is added When entering the server cluster system, send all the session information stored by itself to the new node server through the central node server. This application improves the management efficiency of Session information and avoids a large amount of information synchronization.

Description

一种分布式Session管理中间件A Distributed Session Management Middleware

技术领域technical field

本发明涉及Session管理技术领域,特别涉及一种分布式Session管理中间件。The invention relates to the technical field of session management, in particular to a distributed session management middleware.

背景技术Background technique

随着互联网的发展,人们要求服务器系统具有更高的性能和稳定性,由此使得服务器集群系统的应用越来越广泛,而服务器集群系统中的Session管理模式也由此从单机管理模式逐渐向集群管理模式扩展,Session在集群节点之间的同步、存储成为了其核心技术问题。With the development of the Internet, people require the server system to have higher performance and stability, which makes the server cluster system more and more widely used, and the Session management mode in the server cluster system has gradually changed from a stand-alone management mode to a The expansion of the cluster management mode, and the synchronization and storage of Session among cluster nodes have become its core technical issues.

目前,基于Tomcat或WebLogic中间件对于Session的同步均是采用组播的方式,在各个集群节点进行Session复制,这样需要对大量的Session信息进行复制,在用户数量和集群数量达到一定规模后,对Session信息的复制操作便成为了系统的性能瓶颈,从而降低了对Session信息的管理效率。At present, the synchronization of sessions based on Tomcat or WebLogic middleware adopts the multicast method, and session replication is performed on each cluster node, which requires a large amount of session information to be replicated. After the number of users and the number of clusters reach a certain scale, The copy operation of Session information becomes the performance bottleneck of the system, thereby reducing the management efficiency of Session information.

综上所述可以看出,如何提高对Session信息的管理效率,避免大量信息同步是目前亟待解决的问题。From the above, it can be seen that how to improve the management efficiency of Session information and avoid the synchronization of a large amount of information is an urgent problem to be solved at present.

发明内容Contents of the invention

有鉴于此,本发明的目的在于提供一种分布式Session管理中间件,提高了对Session信息的管理效率,避免大量信息同步。其具体方案如下:In view of this, the object of the present invention is to provide a distributed session management middleware, which improves the management efficiency of session information and avoids the synchronization of a large amount of information. The specific plan is as follows:

一种分布式Session管理中间件,应用于服务器集群系统,所述服务器集群系统包括N台节点服务器,N为正整数,其中,所述N台节点服务器中包括一台中心节点服务器;所述分布式Session管理中间件包括Session生命周期管理模块和Session存储器;其中,A distributed session management middleware, applied to a server cluster system, the server cluster system includes N node servers, N is a positive integer, wherein, the N node servers include a central node server; the distributed The session management middleware includes session life cycle management module and session storage; among them,

所述Session生命周期管理模块,用于当用户通过浏览器向所述服务器集群系统发送的本次会话请求为首次会话请求时,创建与本次会话请求对应的Session信息,并将该Session信息发送至所述Session存储器;当用户通过浏览器向所述服务器集群系统发送的本次会话请求并非首次会话请求时,从所述Session存储器中读取出与该用户通过当前浏览器发送的首次会话请求所对应的Session信息;The Session lifecycle management module is used to create session information corresponding to this session request when the session request sent by the user to the server cluster system through the browser is the first session request, and send the Session information to To the Session memory; when the session request sent by the user to the server cluster system through the browser is not the first session request, read the first session request sent by the user through the current browser from the Session memory Corresponding Session information;

所述Session存储器,用于对每次所述Session生命周期管理模块发送的Session信息进行存储,并且当有新的节点服务器被添加到所述服务器集群系统中时,通过所述中心节点服务器,将自身存储的所有Session信息下发至所述新的节点服务器。The Session memory is used to store the Session information sent by the Session lifecycle management module each time, and when a new node server is added to the server cluster system, through the central node server, the Send all the Session information stored by itself to the new node server.

优选的,所述Session存储器包括Session缓冲池和MongoDB数据库;其中,Preferably, the Session memory includes a Session buffer pool and a MongoDB database; wherein,

所述Session缓冲池,用于在每次接收到所述Session生命周期管理模块发送的Session信息后,对该Session信息进行缓存处理,并将该Session信息转发至所述MongoDB数据库;The Session buffer pool is used for caching the Session information after receiving the Session information sent by the Session life cycle management module each time, and forwarding the Session information to the MongoDB database;

所述MongoDB数据库,用于在每次接收到所述Session缓冲池发送的Session信息后,对该Session信息进行持久化存储,并且当有新的节点服务器被添加到所述服务器集群系统中时,通过所述中心节点服务器,将自身存储的所有Session信息下发至所述新的节点服务器。The MongoDB database is used for persistently storing the Session information after receiving the Session information sent by the Session buffer pool each time, and when a new node server is added to the server cluster system, Send all the Session information stored by itself to the new node server through the central node server.

优选的,所述中心节点服务器包括:Preferably, the central node server includes:

指令接收单元,用于当有新的节点服务器被添加到所述服务器集群系统中时,获取所述新的节点服务器发送的Session信息请求指令;An instruction receiving unit, configured to obtain the Session information request instruction sent by the new node server when a new node server is added to the server cluster system;

信息传输单元,用于当所述指令接收单元接收到所述Session信息请求指令时,将所述MongoDB数据库中存储的所有Session信息传输至所述新的节点服务器。The information transmission unit is configured to transmit all the Session information stored in the MongoDB database to the new node server when the instruction receiving unit receives the Session information request instruction.

优选的,所述Session生命周期管理模块包括:Preferably, the Session lifecycle management module includes:

请求拦截单元,用于对用户通过浏览器向所述服务器集群系统发送的本次会话请求进行拦截;The request interception unit is used to intercept the current session request sent by the user to the server cluster system through the browser;

请求判断单元,用于判断所述请求拦截单元拦截到的本次会话请求中是否携带SessionID,如果否,则判定本次会话请求为首次会话请求,如果是,则判定本次会话请求并非首次会话请求;Request judging unit, for judging whether the current session request intercepted by the request interception unit carries SessionID, if not, then judging that this session request is the first session request, if yes, then judging that this session request is not the first session ask;

Session创建单元,用于当本次会话请求没有携带SessionID时,创建与本次会话请求对应的Session信息,并将该Session信息发送至所述Session缓冲池,其中,每个Session信息均包含与其对应的SessionID;The Session creating unit is used to create the Session information corresponding to the session request when the session request does not carry the SessionID, and send the Session information to the Session buffer pool, wherein each Session information includes its corresponding sessionID;

Session读取单元,用于当本次会话请求携带有SessionID时,利用该SessionID,确定当前所述Session缓冲池中是否存储有与该SessionID对应的Session信息,如果是,则从所述Session缓冲池中读取出与该SessionID对应的Session信息,如果否,则从所述MongoDB数据库读取出与该SessionID对应的Session信息。The Session reading unit is used to determine whether the Session information corresponding to the SessionID is stored in the current Session buffer pool by utilizing the SessionID when the current session request carries the SessionID, and if so, from the Session buffer pool Read out the Session information corresponding to the SessionID, if not, then read the Session information corresponding to the SessionID from the MongoDB database.

优选的,所述分布式Session管理中间件还包括超时Session销毁模块,其中,Preferably, the distributed session management middleware also includes a timeout session destruction module, wherein,

所述超时Session销毁模块,用于对所述Session缓冲池的每个Session信息是否超时进行判断,当判断出所述Session缓冲池的任一Session信息超时后,对该Session信息进行销毁处理;The overtime Session destruction module is used to judge whether each Session information in the Session buffer pool is overtime, and when it is judged that any Session information in the Session buffer pool is overtime, the Session information is destroyed;

所述Session缓冲池,还用于当所述所述超时Session销毁模块对所述Session缓冲池中的任一Session信息进行销毁后,发送相应指令到所述MongoDB数据库,以通知所述MongoDB数据库对相应的Session信息进行销毁处理。The Session buffer pool is also used to send corresponding instructions to the MongoDB database when the overtime Session destruction module destroys any Session information in the Session buffer pool to notify the MongoDB database to The corresponding Session information is destroyed.

优选的,所述超时Session销毁模块包括:Preferably, the overtime Session destruction module includes:

超时监控单元,用于对所述Session缓冲池中的每个Session信息进行扫描,并计算当前时刻与每个Session信息对应的上一次会话请求的时刻之间的时间差,判断每个Session信息对应的时间差是否大于或等于预设值;The overtime monitoring unit is used to scan each Session information in the Session buffer pool, and calculate the time difference between the current moment and the time of the last session request corresponding to each Session information, and determine the corresponding session information of each Session information. Whether the time difference is greater than or equal to the preset value;

销毁指令发送单元,用于当所述超时监控单元判断出任一Session信息对应的时间差大于或等于所述预设值时,向所述Session缓冲池发送与该Session信息对应的Session销毁指令,以使所述Session缓冲池根据该Session销毁指令对相应的Session信息进行销毁处理。Destruction instruction sending unit, used to send the Session destruction instruction corresponding to the Session information to the Session buffer pool when the timeout monitoring unit judges that the time difference corresponding to any Session information is greater than or equal to the preset value, so that The Session buffer pool destroys the corresponding Session information according to the Session destruction instruction.

优选的,所述分布式Session管理中间件还包括:Preferably, the distributed session management middleware also includes:

Session属性更新单元,用于当需要对已创建的任一Session信息的属性进行更新时,同时对所述Session缓冲池和所述MongoDB数据库中相应的Session信息的属性进行更新处理。The session attribute updating unit is used for updating the attribute of the corresponding Session information in the Session buffer pool and the MongoDB database simultaneously when the attribute of any created Session information needs to be updated.

优选的,所述分布式Session管理中间件还包括:Preferably, the distributed session management middleware also includes:

Session会话时间变更单元,用于当需要对已创建的任一Session信息的会话时间进行变更时,仅对所述Session缓冲池中的相应Session信息的会话时间进行变更。The session time changing unit is configured to change only the session time of the corresponding Session information in the Session buffer pool when the session time of any created Session information needs to be changed.

优选的,所述分布式Session管理中间件还包括:Preferably, the distributed session management middleware also includes:

Session监控模块,用于对所述Session缓冲池中的Session信息的数量以及占用内存情况进行监控,并对所述MongoDB数据库的运行状态进行监控。The Session monitoring module is used to monitor the quantity of the Session information in the Session buffer pool and the occupied memory situation, and monitor the running status of the MongoDB database.

优选的,所述分布式Session管理中间件还包括:Preferably, the distributed session management middleware also includes:

MongoDB副本集,用于对所述MongoDB数据库中存储的数据进行备份处理。The MongoDB replica set is used for backing up the data stored in the MongoDB database.

本发明中,分布式Session管理中间件包括Session生命周期管理模块和Session存储器;其中,Session生命周期管理模块用于当用户通过浏览器向服务器集群系统发送的本次会话请求为首次会话请求时,创建与本次会话请求对应的Session信息,并将该Session信息发送至Session存储器;Session存储器用于对每次Session生命周期管理模块发送的Session信息进行存储,并且当有新的节点服务器被添加到服务器集群系统中时,通过中心节点服务器,将自身存储的所有Session信息下发至新的节点服务器。可见,本发明中,当用户通过浏览器向服务器集群系统发送首次会话请求时,均通过Session生命周期管理模块创建相应的Session信息,并通过Session存储器对Session生命周期管理模块创建的Session信息进行存储,当有新的节点服务器被添加到服务器集群系统中时,便可通过中心节点服务器将Session存储器存储的所有Session信息下发至新的节点服务器,这样相当于在Session存储器中存储了所有的Session信息,当需要向新的节点服务器同步Session信息时,只需通过中心节点服务器将Session存储器中存储的Session信息下发至该新的节点服务器便可,从而避免了现有技术中由于采用组播的方式进行Session信息同步而造成的需要对大量信息进行同步的问题,从而提高了对Session信息的管理效率。In the present invention, the distributed Session management middleware includes a Session lifecycle management module and a Session memory; wherein, the Session lifecycle management module is used for when the session request sent by the user to the server cluster system through the browser is the first session request, Create the Session information corresponding to this session request, and send the Session information to the Session memory; the Session memory is used to store the Session information sent by the Session lifecycle management module each time, and when a new node server is added to When the server is in a cluster system, send all the session information stored by itself to the new node server through the central node server. It can be seen that in the present invention, when the user sends the first session request to the server cluster system through the browser, the corresponding Session information is created by the Session life cycle management module, and the Session information created by the Session life cycle management module is stored by the Session memory , when a new node server is added to the server cluster system, all the Session information stored in the Session memory can be sent to the new node server through the central node server, which is equivalent to storing all the Session information in the Session memory information, when it is necessary to synchronize Session information to a new node server, it is only necessary to send the Session information stored in the Session memory to the new node server through the central node server, thus avoiding the problem of using multicast in the prior art Synchronization of session information in a different way causes the problem that a large amount of information needs to be synchronized, thereby improving the management efficiency of session information.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only It is an embodiment of the present invention, and those skilled in the art can also obtain other drawings according to the provided drawings without creative work.

图1为本发明实施例公开的一种分布式Session管理中间件应用结构示意图;Fig. 1 is a schematic diagram of a distributed session management middleware application structure disclosed by an embodiment of the present invention;

图2为本发明实施例公开的一种具体的分布式Session管理中间件应用结构示意图;FIG. 2 is a schematic diagram of a specific distributed session management middleware application structure disclosed by an embodiment of the present invention;

图3为本发明实施例公开的另一种具体的分布式Session管理中间件应用结构示意图。FIG. 3 is a schematic diagram of another specific distributed session management middleware application structure disclosed by the embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.

本发明实施例公开了一种分布式Session管理中间件,应用于服务器集群系统,服务器集群系统包括N台节点服务器,N为正整数,其中,上述N台节点服务器中包括一台中心节点服务器;参见图1所示,本实施例中,分布式Session管理中间件包括Session生命周期管理模块11和Session存储器12;其中,The embodiment of the present invention discloses a distributed session management middleware, which is applied to a server cluster system. The server cluster system includes N node servers, where N is a positive integer, wherein the above N node servers include a central node server; Referring to Fig. 1, in the present embodiment, the distributed Session management middleware includes a Session lifecycle management module 11 and a Session memory 12; wherein,

Session生命周期管理模块11,用于当用户通过浏览器向上述服务器集群系统发送的本次会话请求为首次会话请求时,创建与本次会话请求对应的Session信息,并将该Session信息发送至Session存储器12;当用户通过浏览器向上述服务器集群系统发送的本次会话请求并非首次会话请求时,从Session存储器12中读取出与该用户通过当前浏览器发送的首次会话请求所对应的Session信息;Session lifecycle management module 11 is used to create session information corresponding to this session request when the session request sent by the user to the above-mentioned server cluster system through the browser is the first session request, and send the Session information to the Session Memory 12; when the session request sent by the user to the above-mentioned server cluster system through the browser is not the first session request, read out from the Session memory 12 the Session information corresponding to the first session request sent by the user through the current browser ;

Session存储器12,用于对每次Session生命周期管理模块11发送的Session信息进行存储,并且当有新的节点服务器被添加到上述服务器集群系统中时,通过上述服务器集群系统的中心节点服务器,将自身存储的所有Session信息下发至上述新的节点服务器。Session memory 12 is used to store the Session information sent by the Session life cycle management module 11 each time, and when a new node server is added to the above-mentioned server cluster system, through the central node server of the above-mentioned server cluster system, the All the session information stored by itself is sent to the above new node server.

本发明实施例中,分布式Session管理中间件包括Session生命周期管理模块和Session存储器;其中,Session生命周期管理模块用于当用户通过浏览器向服务器集群系统发送的本次会话请求为首次会话请求时,创建与本次会话请求对应的Session信息,并将该Session信息发送至Session存储器;Session存储器用于对每次Session生命周期管理模块发送的Session信息进行存储,并且当有新的节点服务器被添加到服务器集群系统中时,通过中心节点服务器,将自身存储的所有Session信息下发至新的节点服务器。In the embodiment of the present invention, the distributed session management middleware includes a session lifecycle management module and a session memory; wherein, the session lifecycle management module is used for the first session request when the session request sent by the user to the server cluster system through the browser , create the Session information corresponding to this session request, and send the Session information to the Session memory; the Session memory is used to store the Session information sent by the Session life cycle management module each time, and when a new node server is When added to the server cluster system, all the session information stored by itself will be sent to the new node server through the central node server.

可见,本发明实施例中,当用户通过浏览器向服务器集群系统发送首次会话请求时,均通过Session生命周期管理模块创建相应的Session信息,并通过Session存储器对Session生命周期管理模块创建的Session信息进行存储,当有新的节点服务器被添加到服务器集群系统中时,便可通过中心节点服务器将Session存储器存储的所有Session信息下发至新的节点服务器,这样相当于在Session存储器中存储了所有的Session信息,当需要向新的节点服务器同步Session信息时,只需通过中心节点服务器将Session存储器中存储的Session信息下发至该新的节点服务器便可,从而避免了现有技术中由于采用组播的方式进行Session信息同步而造成的需要对大量信息进行同步的问题,从而提高了对Session信息的管理效率。It can be seen that in the embodiment of the present invention, when the user sends the first session request to the server cluster system through the browser, the corresponding Session information is created by the Session life cycle management module, and the Session information created by the Session life cycle management module is passed through the Session memory. When a new node server is added to the server cluster system, all the Session information stored in the Session memory can be sent to the new node server through the central node server, which is equivalent to storing all the session information in the Session memory. Session information, when it is necessary to synchronize the Session information to a new node server, it is only necessary to send the Session information stored in the Session memory to the new node server through the central node server, thereby avoiding the use of Synchronization of session information in a multicast manner causes the problem that a large amount of information needs to be synchronized, thereby improving the management efficiency of session information.

本发明实施例还公开了一种具体的分布式Session管理中间件,相对于上一实施例,本实施例对技术方案作了进一步的说明和优化。具体的:The embodiment of the present invention also discloses a specific distributed session management middleware. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. specific:

参见图2所示,本实施例中的Session存储器12具体包括Session缓冲池121和MongoDB数据库122;其中,Referring to Fig. 2, the Session memory 12 in this embodiment specifically includes a Session buffer pool 121 and a MongoDB database 122; wherein,

Session缓冲池121可用于在每次接收到Session生命周期管理模块11发送的Session信息后,对该Session信息进行缓存处理,并将该Session信息转发至MongoDB数据库122;The Session buffer pool 121 can be used to cache the Session information after receiving the Session information sent by the Session life cycle management module 11 each time, and forward the Session information to the MongoDB database 122;

MongoDB数据库122可用于在每次接收到Session缓冲池121发送的Session信息后,对该Session信息进行持久化存储,并且当有新的节点服务器被添加到服务器集群系统中时,通过服务器集群系统的中心节点服务器,将自身存储的所有Session信息下发至上述新的节点服务器。The MongoDB database 122 can be used to persistently store the Session information after receiving the Session information sent by the Session buffer pool 121 each time, and when a new node server is added to the server cluster system, through the server cluster system The central node server sends all the session information stored by itself to the above-mentioned new node server.

本实施例中,由于MongoDB数据库相比于其他类型的数据库,具有访问速度、插入速度和读取速度,从而极大地提高了Session信息的同步速度和存储速度。In this embodiment, since the MongoDB database has access speed, insertion speed and read speed compared with other types of databases, the synchronization speed and storage speed of Session information are greatly improved.

另外,本实施例中,服务器集群系统的中心节点服务器可以包括指令接收单元和信息传输单元,其中,In addition, in this embodiment, the central node server of the server cluster system may include an instruction receiving unit and an information transmission unit, wherein,

指令接收单元可用于当有新的节点服务器被添加到服务器集群系统中时,获取上述新的节点服务器发送的Session信息请求指令;The instruction receiving unit can be used to obtain the Session information request instruction sent by the above-mentioned new node server when a new node server is added to the server cluster system;

信息传输单元可用于当指令接收单元接收到Session信息请求指令时,将MongoDB数据库122中存储的所有Session信息传输至上述新的节点服务器。The information transmission unit may be configured to transmit all the Session information stored in the MongoDB database 122 to the above-mentioned new node server when the instruction receiving unit receives the Session information request instruction.

本实施例中,Session生命周期管理模块11具体可以包括请求拦截单元111、请求判断单元112、Session创建单元113和Session读取单元114;其中,In this embodiment, the Session lifecycle management module 11 may specifically include a request interception unit 111, a request judgment unit 112, a Session creation unit 113, and a Session reading unit 114; wherein,

请求拦截单元111可用于对用户通过浏览器向服务器集群系统发送的本次会话请求进行拦截;The request interception unit 111 can be used to intercept the current session request sent by the user to the server cluster system through the browser;

请求判断单元112可用于判断请求拦截单元111拦截到的本次会话请求中是否携带SessionID,如果否,则判定本次会话请求为首次会话请求,如果是,则判定本次会话请求并非首次会话请求;The request judgment unit 112 can be used to judge whether the session request intercepted by the request interception unit 111 carries the SessionID, if not, then determine that the session request is the first session request, and if so, determine that the session request is not the first session request ;

Session创建单元113可用于当本次会话请求没有携带SessionID时,创建与本次会话请求对应的Session信息,并将该Session信息发送至Session缓冲池121,其中,每个Session信息均包含与其对应的SessionID;Session creation unit 113 can be used for when this session request does not carry SessionID, create the Session information corresponding to this session request, and send this Session information to Session buffer pool 121, wherein, each Session information all includes its corresponding SessionID;

Session读取单元114可用于当本次会话请求携带有SessionID时,利用该SessionID,确定当前Session缓冲池121中是否存储有与该SessionID对应的Session信息,如果是,则从Session缓冲池121中读取出与该SessionID对应的Session信息,如果否,则从MongoDB数据库122读取出与该SessionID对应的Session信息。可见,本实施例中,当需要从Session存储器12中读取相应的Session信息时,尽量选择从Session缓冲池121中进行读取,只有当Session缓冲池121中没有相关的Session信息时,才选择从MongoDB数据库122中读取,从而大大减少了对MongoDB数据库122的读取次数,降低了MongoDB数据库122的日常负担。Session reading unit 114 can be used for when this session request carries SessionID, utilizes this SessionID, determines whether to store the Session information corresponding to this SessionID in the current Session buffer pool 121, if yes, then reads from Session buffer pool 121 Take out the Session information corresponding to the SessionID, if not, read the Session information corresponding to the SessionID from the MongoDB database 122 . It can be seen that in this embodiment, when it is necessary to read the corresponding Session information from the Session memory 12, try to choose to read from the Session buffer pool 121, only when there is no relevant Session information in the Session buffer pool 121, select Read from the MongoDB database 122, thereby greatly reducing the number of times to read the MongoDB database 122, reducing the daily burden of the MongoDB database 122.

参见图3所示,本实施例中,分布式Session管理中间件还可以进一步包括超时Session销毁模块13,用于对Session缓冲池121的每个Session信息是否超时进行判断,当判断出Session缓冲池121的任一Session信息超时后,对该Session信息进行销毁处理。Referring to shown in Fig. 3, in the present embodiment, the distributed Session management middleware can also further include an overtime Session destruction module 13, which is used to judge whether each Session information of the Session buffer pool 121 is timed out, and when it is judged that the Session buffer pool After any session information of 121 times out, the session information is destroyed.

相应的,Session缓冲池121还可用于当超时Session销毁模块13对Session缓冲池121中的任一Session信息进行销毁后,发送相应指令到MongoDB数据库122,以通知MongoDB数据库122对相应的Session信息进行销毁处理,也即是通知MongoDB数据库122对自身存储的与在Session缓冲池121中被销毁的Session信息对应的Session信息进行销毁处理。Correspondingly, the Session buffer pool 121 can also be used to send corresponding instructions to the MongoDB database 122 after the overtime Session destruction module 13 destroys any Session information in the Session buffer pool 121, to notify the MongoDB database 122 to perform corresponding Session information The destruction process is to notify the MongoDB database 122 to destroy the Session information stored in itself corresponding to the Session information destroyed in the Session buffer pool 121 .

具体的,上述超时Session销毁模块13可以包括超时监控单元131和销毁指令发送单元132;其中,Specifically, the above-mentioned overtime Session destruction module 13 may include a timeout monitoring unit 131 and a destruction instruction sending unit 132; wherein,

超时监控单元131可用于对Session缓冲池121中的每个Session信息进行扫描,并计算当前时刻与每个Session信息对应的上一次会话请求的时刻之间的时间差,判断每个Session信息对应的时间差是否大于或等于预设值,其中,任一Session信息对应的上一次会话请求也即是当前与该Session信息对应的所有会话请求中的最近一次会话请求;The timeout monitoring unit 131 can be used to scan each Session information in the Session buffer pool 121, and calculate the time difference between the current time and the time of the last session request corresponding to each Session information, and determine the time difference corresponding to each Session information Whether it is greater than or equal to a preset value, wherein the last session request corresponding to any Session information is the latest session request among all session requests currently corresponding to the Session information;

销毁指令发送单元132可用于当超时监控单元131判断出任一Session信息对应的时间差大于或等于预设值时,向Session缓冲池121发送与该Session信息对应的Session销毁指令,以使Session缓冲池121根据该Session销毁指令对相应的Session信息进行销毁处理。Destruction instruction sending unit 132 can be used for when timeout monitoring unit 131 judges that the time difference corresponding to any Session information is greater than or equal to preset value, sends the Session destruction instruction corresponding to this Session information to Session buffer pool 121, so that Session buffer pool 121 The corresponding Session information is destroyed according to the Session destruction instruction.

进一步的,本实施例中,分布式Session管理中间件还包括Session属性更新单元、Session会话时间变更单元,和/或,Session监控模块;其中,Further, in this embodiment, the distributed session management middleware also includes a session attribute updating unit, a session session time changing unit, and/or a session monitoring module; wherein,

Session属性更新单元可用于当需要对已创建的任一Session信息的属性进行更新时,同时对Session缓冲池121和MongoDB数据库122中相应的Session信息的属性进行更新处理。The session attribute update unit can be used to update the attributes of the corresponding Session information in the Session buffer pool 121 and the MongoDB database 122 at the same time when the attribute of any created Session information needs to be updated.

Session会话时间变更单元可用于当需要对已创建的任一Session信息的会话时间进行变更时,仅对Session缓冲池121中的相应Session信息的会话时间进行变更。需要说明的是,由于在日常大量的请求会话过程中,通常只涉及到对Session信息的会话时间进行变更操作,而较少涉及到对Session信息的创建、属性变更和销毁操作,本实施例中的Session会话时间变更单元在需要对Session信息的会话时间进行变更时,仅对Session缓冲池121中的相应Session信息的会话时间进行变更,而不对MongoDB数据库122中的相应Session信息的会话时间进行变更,从而大大减少了对MongoDB数据库122的日常操作次数,降低了MongoDB数据库122的日常负担。The session time changing unit can be used to only change the session time of the corresponding session information in the session buffer pool 121 when the session time of any created session information needs to be changed. It should be noted that, in the process of a large number of daily session requests, usually only the session time change operation of the Session information is involved, and the creation, attribute change and destruction operations of the Session information are seldom involved. In this embodiment, When the Session session time change unit needs to change the session time of the Session information, only the session time of the corresponding Session information in the Session buffer pool 121 is changed, and the session time of the corresponding Session information in the MongoDB database 122 is not changed , thereby greatly reducing the number of daily operations on the MongoDB database 122 and reducing the daily burden on the MongoDB database 122 .

Session监控模块可用于对Session缓冲池121中的Session信息的数量以及占用内存情况进行监控,并对MongoDB数据库122的运行状态进行监控。The Session monitoring module can be used to monitor the number of Session information in the Session buffer pool 121 and the memory usage, and monitor the running status of the MongoDB database 122 .

为了提高数据库持续可靠的运行,本实施例中的分布式Session管理中间件还可进一步包括:MongoDB副本集,用于对MongoDB数据库122中存储的数据进行备份处理,当MongoDB数据库122发生故障后,可以利用MongoDB副本集来接替MongoDB数据库122的工作,从而提高了系统的可靠性。In order to improve the continuous and reliable operation of the database, the distributed Session management middleware in the present embodiment can further include: a MongoDB replica set, which is used to backup the data stored in the MongoDB database 122. When the MongoDB database 122 fails, The MongoDB replica set can be used to take over the work of the MongoDB database 122, thereby improving the reliability of the system.

最后,还需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。Finally, it should also be noted that in this document, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements not only includes those elements, but also other elements not expressly listed, or elements inherent in the process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.

以上对本发明所提供的一种分布式Session管理中间件进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。The above is a detailed introduction to a distributed session management middleware provided by the present invention. In this paper, specific examples are used to illustrate the principle and implementation of the present invention. The description of the above embodiments is only used to help understand the present invention. method and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation and application scope. Invention Limitations.

Claims (10)

1. A distributed Session management middleware is characterized in that the distributed Session management middleware is applied to a server cluster system, wherein the server cluster system comprises N node servers, N is a positive integer, wherein the N node servers comprise a central node server; the distributed Session management middleware comprises a Session life cycle management module and a Session memorizer; wherein,
the Session life cycle management module is used for creating Session information corresponding to the Session request when the Session request sent to the server cluster system by the user through the browser is a first Session request, and sending the Session information to the Session memory; when the Session request sent to the server cluster system by a user through a browser is not a first Session request, reading Session information corresponding to the first Session request sent by the user through the current browser from a Session memory;
the Session memory is used for storing the Session information sent by the Session life cycle management module each time, and when a new node server is added into the server cluster system, all the Session information stored by the central node server is sent to the new node server through the central node server.
2. The distributed Session management middleware of claim 1 wherein the Session store comprises a Session buffer pool and a MongoDB database; wherein,
the Session buffer pool is used for caching the Session information after receiving the Session information sent by the Session life cycle management module each time, and forwarding the Session information to the MongoDB database;
and the MongoDB is used for persistently storing the Session information after the Session information sent by the Session buffer pool is received each time, and issuing all the Session information stored by the MongoDB to a new node server through the central node server when the new node server is added into the server cluster system.
3. The distributed Session management middleware of claim 2, wherein the central node server comprises:
the instruction receiving unit is used for acquiring a Session information request instruction sent by a new node server when the new node server is added into the server cluster system;
and the information transmission unit is used for transmitting all the Session information stored in the MongoDB database to the new node server when the instruction receiving unit receives the Session information request instruction.
4. The distributed Session management middleware of claim 3, wherein the Session lifecycle management module comprises:
the request intercepting unit is used for intercepting the session request sent by the user to the server cluster system through the browser;
the request judging unit is used for judging whether the session request intercepted by the request intercepting unit carries the Session ID or not, if not, the session request is judged to be a first session request, and if so, the session request is judged not to be the first session request;
a Session creating unit, configured to create Session information corresponding to the Session request when the Session request does not carry a Session id, and send the Session information to the Session buffer pool, where each Session information includes a Session id corresponding to the Session information;
and the Session reading unit is used for determining whether Session information corresponding to the Session ID is stored in the Session buffer pool or not by using the Session ID when the Session request carries the Session ID, reading the Session information corresponding to the Session ID from the Session buffer pool if the Session information is stored in the Session buffer pool, and reading the Session information corresponding to the Session ID from the MongoDB database if the Session information is not stored in the Session buffer pool.
5. The distributed Session management middleware of claim 4, further comprising a timeout Session destruction module, wherein,
the Session destroying module is used for judging whether each Session information in the Session buffer pool is overtime, and destroying the Session information when any Session information in the Session buffer pool is judged to be overtime;
the Session buffer pool is further configured to send a corresponding instruction to the montgodb database to notify the montgodb database of performing destruction processing on the corresponding Session information after the timeout Session destruction module destroys any Session information in the Session buffer pool.
6. The distributed Session management middleware of claim 5, wherein the timeout Session destruction module comprises:
the timeout monitoring unit is used for scanning each Session information in the Session buffer pool, calculating the time difference between the current time and the time of the last Session request corresponding to each Session information, and judging whether the time difference corresponding to each Session information is greater than or equal to a preset value;
and the destruction instruction sending unit is used for sending a Session destruction instruction corresponding to the Session information to the Session buffer pool when the overtime monitoring unit judges that the time difference corresponding to any Session information is greater than or equal to the preset value, so that the Session buffer pool can process the corresponding Session information according to the Session destruction instruction.
7. The distributed Session management middleware of claim 6, further comprising:
and the Session attribute updating unit is used for updating the attributes of the Session information corresponding to the Session buffer pool and the MongoDB database when the attributes of any created Session information need to be updated.
8. The distributed Session management middleware of claim 7, further comprising:
and the Session time changing unit is used for changing the Session time of the corresponding Session information in the Session buffer pool only when the Session time of any created Session information needs to be changed.
9. The distributed Session management middleware of claim 8, further comprising:
and the Session monitoring module is used for monitoring the number of Session information in the Session buffer pool and the memory occupation condition and monitoring the running state of the MongoDB database.
10. The distributed Session management middleware of any of claims 2 to 9, further comprising:
and the MongoDB copy set is used for carrying out backup processing on the data stored in the MongoDB database.
CN201510894376.6A 2015-11-27 2015-11-27 A kind of distribution Session management middleware Active CN105357222B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510894376.6A CN105357222B (en) 2015-11-27 2015-11-27 A kind of distribution Session management middleware

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510894376.6A CN105357222B (en) 2015-11-27 2015-11-27 A kind of distribution Session management middleware

Publications (2)

Publication Number Publication Date
CN105357222A CN105357222A (en) 2016-02-24
CN105357222B true CN105357222B (en) 2018-11-06

Family

ID=55333086

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510894376.6A Active CN105357222B (en) 2015-11-27 2015-11-27 A kind of distribution Session management middleware

Country Status (1)

Country Link
CN (1) CN105357222B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109495587B (en) * 2018-12-25 2021-08-24 思必驰科技股份有限公司 Language model synchronization method and system for speech dialogue platform
CN110909076B (en) * 2019-10-31 2023-05-23 北京浪潮数据技术有限公司 Storage cluster data synchronization method, device, equipment and storage medium

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7370329B2 (en) * 2002-03-01 2008-05-06 Sun Microsystems, Inc. System and method for state saves in a distributed data system
CN201682522U (en) * 2010-02-08 2010-12-22 阿里巴巴集团控股有限公司 Conversation information storage system and application server
JP5660799B2 (en) * 2010-04-15 2015-01-28 株式会社ディー・ティー・ピー Three-tier core business system
CN102025550A (en) * 2010-12-20 2011-04-20 中兴通讯股份有限公司 System and method for managing data in distributed cluster
CN102523234B (en) * 2011-12-29 2015-12-02 山东中创软件工程股份有限公司 A kind of application server cluster implementation method and system
CN102571575A (en) * 2011-12-29 2012-07-11 奇智软件(北京)有限公司 Session information creation method, device and system
CN103514551A (en) * 2012-06-15 2014-01-15 北京力美科技有限公司 Mobile advertisement platform
CN104735098B (en) * 2013-12-18 2018-05-08 青岛海尔空调器有限总公司 The control method and control system of session information
CN103685304A (en) * 2013-12-25 2014-03-26 Tcl集团股份有限公司 Method and system for sharing session information

Also Published As

Publication number Publication date
CN105357222A (en) 2016-02-24

Similar Documents

Publication Publication Date Title
CN103530362B (en) A kind of computer data reading/writing method for many copies distributed system
CN111314479B (en) Data processing method and equipment
Bronson et al. {TAO}:{Facebook’s} distributed data store for the social graph
CN105493474B (en) System and method for supporting partition level logging for synchronizing data in a distributed data grid
US8788760B2 (en) Adaptive caching of data
CN101902473B (en) Method for synchronously updating data based on grid GIS (Geographic Information System)
CN106933548B (en) Global information obtaining, processing and updating method, device and system
JP5686034B2 (en) Cluster system, synchronization control method, server device, and synchronization control program
CN106933550B (en) Global information obtaining, processing and updating method, device and system
KR20130107280A (en) Directory leasing
WO2020063763A1 (en) Data storage method, apparatus and system, and server, control node and medium
WO2017097011A1 (en) Session synchronization method based on instant copy between cluster nodes
CN106934048A (en) Online data moving method, agent node
US20190340011A1 (en) Resource-governed protocol and runtime for distributed databases with consistency models
CN112235405A (en) Distributed storage system and data delivery method
CN113010549A (en) Data processing method based on remote multi-active system, related equipment and storage medium
CN105512171A (en) Database synchronizing method and apparatus
CN112015807A (en) Data synchronization processing method, device, electronic device and computer storage medium
CN107562882A (en) A kind of method of data synchronization and device based on log analysis
CN108965054B (en) A fast data interaction method between client and server
CN105357222B (en) A kind of distribution Session management middleware
WO2021135279A1 (en) Asymmetric configuration management method, apparatus and device, and readable storage medium
CN102904917A (en) Massive picture processing system and method
CN111274258B (en) Block chain data uplink method
CN113746641A (en) ODX protocol processing method based on distributed storage

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant