Management session using memcache

2010-08-27  来源:本站原创  分类:Internet  人气:281 

First, download the following package of several Jar
http://memcached-session-manager.googlecode.com/files/memcached-session-manager-1.3.0.jar
http://memcached-session-manager.googlecode.com/files/msm-javolution-serializer-jodatime-1.3.0.jar
http://memcached-session-manager.googlecode.com/files/msm-javolution-serializer-cglib-1.3.0.jar
http://spymemcached.googlecode.com/files/memcached-2.4.2.jar
http://memcached-session-manager.googlecode.com/files/javolution-5.4.3.1.jar

Copy the following Jar package to $ TOMCAT_HOME / lib-head, each Tomcat node needs to have.

Second, configure Tomcat's Server.xml configuration file, you can click here to download the sample, the main contents are as follows:
http://www.javabloger.com/images/2010-05/webcluster/server.xml.txt

<Context DocBase="D:\webapp" path="" reloadable="true">
<Manager className = "de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes = "n1: localhost: 11211"
requestUriIgnorePattern = ".* \. (png | gif | jpg | css | js) $"
sessionBackupAsync = "false"
sessionBackupTimeout = "100"
transcoderFactoryClass = "de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
copyCollectionsForSerialization = "false"
/>
</ Context>

Each node needs to modify the Tomcat.

Third, front-end distributed Ngixn also need to modify the configuration file, the sample can click here to download the following major elements:
http://www.javabloger.com/images/2010-05/webcluster/nginx.conf.txt
# Gzip on;
upstream www.docyeah.com (
server 192.168.1.103:81;
server 192.168.1.103:82;
)

Last visit to test the JSP page, to refresh:
http://www.javabloger.com/images/2010-05/webcluster/msem.jsp.txt
Page appears: SessionID: 292621C48C4D6B27F40290039081492A-n1 have the same show that you read the front-end Ngixn for distribution, jump to any one server are read from the Memcached session, this session on the web container in one place. And each machine can be calculated given the client's request, to achieve the session to share and pressure are set out in the next figure shows the Tomcat container each print 2 of each print a Hello World, shows the client distributed computing send request.

The advantage of using this program, if replaced most front-end load balancing IP strategy, such as: LVS, Iptables, or HA-Proxy can be, and front-end load balancer to increase work efficiency. Through this idea, this tool can also be changed to write to the database program.

As shown:
Management session using memcache

Reprinted http://www.javabloger.com/article/ngixn-j2ee-tomcat-memcache-session-share.html

相关文章
  • Management session using memcache 2010-08-27

    First, download the following package of several Jar http://memcached-session-manager.googlecode.com/files/memcached-session-manager-1.3.0.jar http://memcached-session-manager.googlecode.com/files/msm-javolution-serializer-jodatime-1.3.0.jar http://m

  • Session and memcache on a number of issues 2010-09-20

    All along, because php's own session mechanism can not cross-machine, many phper feel uncomfortable, and now popular solutions are: 1) Use the database to achieve 2) write your own server-side, through the rewrite session handling functions to reques

  • Conducive to ThreadLocal model management Session (change) 2010-03-29

    Hibernate development in the use of DAO module, we and most dealings Session fought, so how the rational management of Session, to avoid the frequent creation and destruction of Session for improving the performance of the system is very important, i

  • ThreadLocal Model Management Session (hibernate file) 2010-08-16

    public class HibernateUtil ( public static final SessionFactory sessionFactory; static ( try ( sessionFactory = new Configuration (). configure () . BuildSessionFactory (); ) Catch (Throwable ex) ( throw new ExceptionInInitializerError (ex); ) ) publ

  • tomcat session management 2010-08-10

    Recently looked at tomcat 6 free Source inside of the session management implementation, is written down for later examination, but also hoping to interested friends Some tips. Gossip talk less, first posted about tomcat6 the component level diagram

  • Turn to save the php memcache multi-server session session to resolve the problem 2011-10-26

    PECL:: Package:: memcache 2.1.1 Changelog version has a: - Added experimental session storage support. You can use memcached as session storage. That is directly used to make the PHP memcache session.save_handler. 1 install memcached, is still the sa

  • 基于php使用memcache存储session的详解 2013-12-07

    本篇文章是对php使用memcache存储session进行了详细的分析介绍,需要的朋友参考下 web服务器的php session都给memcached ,这样你不管分发器把 ip连接分给哪个web服务器都不会有问题了,配置方法很简单,就在php的配置文件内 增加一条语句就可以了,不过前提你需要装好memcache模块 1.设置session用memcache来存储方法I: 在 php.ini 中全局设置 session.save_handler = memcache session.save

  • PHP中使用memcache存储session的三种配置方法 2014-06-29

    下面简单说下PHP项目分布式部署中,SESSION的同步方案中的一种,使用Memcache来存储SESSION.并总结了三种配置方式,需要的朋友可以参考下 1.直接修改php.ini配置文件 session.save_handler = memcache //设置session的储存方式为memcache memcache.hash_strategy = "consistent"//设置memcache的hash算法 session.save_path = "tcp://12

  • 采用memcache在web集群中实现session的同步会话 2014-12-04

    这篇文章主要介绍了采用memcache在web集群中实现session的同步会话,需要的朋友可以参考下 使用memcache来同步session是还是不错的,当然也可以通过redis来保存session,可以php开启并将Session存储到Redis缓存,下面是设置利用memcache在web集群中同步会话session的实现过程: 1.模拟web集群 我启动了二个memcached进程,分别模拟二台服务器 /usr/local/bin/memcached -d -m 20 -u zhangy

  • 深入Memcache的Session数据的多服务器共享详解 2015-02-04

    本篇文章是对Memcache的Session数据的多服务器共享进行了详细的分析介绍,需要的朋友参考下 一相关介绍 1.memcache + memcache的多服务器数据共享的介绍,请参见http://www.guigui8.com/index.php/archives/206.html 2.session机制:session机制是一种服务器端的机制,服务器使用一种类似于散列表的结构(也可能就是使用散列表)来保存信息. 当程序需要为某个客户端的请求创建一个session的时候,服务器首先检查这个客户端的请

  • Memcache存储session,修改tomcat源码,实现全站二级域名session共享 2011-05-13

    上篇文章中的方案,在外部显式的使用memcache来替代session,虽然可以达到各个服务器session共享的目的,但是改变了开发人员获取session的方式. 本篇介绍的方法可以在不重构原来代码,不改变代码习惯的情况下,实现session共享的目的. 两种方法各有利弊,第一种方法编码方式改变比较大,开发人员可能不习惯,但是不受服务器类型的影响;第二种方法,针对tomcat服务器,需要修改tomcat源码,但是不需要重构代码,代码中对session的操作还和以前一样. 第二种方式主要做两处改

  • php使用 memcache 来存储 session 2012-01-29

    我没怎么用过memcache,看到一篇关于php使用 memcache 来存储 session 的 bolg觉得很喜欢,适当的使用memcache提高程序的用行速度是一种不错的方法! 原bolg讲的是在linux下装memecached然后再怎么用memecached储存session,我这里讲的是window下装memecached再使用memecached来储存session! 使用memchche代替php默认的file来存储session,能够实现更快的速度,而且很容易实现多主机共享se

  • PHP + Memcache 实现多服务器session共享 2012-04-26

    很多时候一个完整的系统可能运行在多个服务器上,如果这多个服务器之间需要共享session的话,那么php默认的files保存session的方式就无能为力了.这时我们可以考虑使用memcache 来接管session的保存与读取工作. 第一步:我们需要在服务器上搭建必要的环境, php .web server的安装不是主题就不多说了,其他还需要的是 memcached 服务端.php_memcache扩展 下面安装为centos 下的示例(注:以下安装命令跟服务器配置有关,不能保证通用性,请根据

  • web集群利用memcache来同步session 2012-09-04

    在做了web集群后,你肯定会首先考虑session同步问题,因为通过负载均衡后,同一个IP访问同一个页面会被分配到不同的服务器上,如果session不同步的话,一个登录用户,一会是登录状态,一会又不是登录状态.所以本文就根据这种情况给出三种不同的方法来解决这个问题: 一,利用数据库同步session 在做多服务器session同步时我没有用这种方法,如果非要用这种方法的话,我想过二种方法: 1,用一个低端电脑建个数据库专门存放web服务器的session,或者,把这个专门的数据库建在文件服务器上

  • php memcache保存session的一个设置误区 2013-09-22

    php中,使用memcache作为session的save handler 一般会使用如下设置: php.ini里: session.save_handler = memcache session.save_path = "localhost:11211″ 项目配置里: ini_set("session.save_handler", "memcache"); ini_set("session.save_path", "127.

  • memcache存入session数据 2014-08-25

    在平时的生成环境中,有可能会生成大量的session文件,占用了服务器一大部分资源. 且读取session文件数据会影响服务器的性能,因为有一个查询的过程. 由于某些时候session数据并不是非常重要,且并不是实时数据.数据安全性要求不是很高,并且可能是动态的数据,因此,我们可以将起保存到memcache当中即可.这样查询数据,和操作,crud都会比操作文件要快许多. 那么怎样将session数据存入到memcache中呢 需要以下几点 ①修改php.ini文件 ;save_handler可以

  • [Reserved] Implementation using memcached session remote distributed storage 2010-05-24

    To make web application can use large-scale access saas model, the application must implement the cluster deployment. To achieve the deployment of the main cluster sharing mechanisms need to achieve the session, making conversation between multiple a

  • memcache cluster service: memagent configured to use 2010-06-04

    magent is a source of memcached proxy server software address: http://code.google.com/p/memagent/ Install magent to / usr / local / under cd / usr / local mkdir magent cd magent / wget http://memagent.googlecode.com/files/magent-0.5.tar.gz tar zxvf m

  • Hibernate cache management 2009-08-20

    1. Cache Description: Cache (Cache) is the computer industry the concept is very common. Between its applications and permanent data storage source (such as hard disk file or database), with its direct application is to reduce the permanent data stor

  • Using memcached shared between multiple servers in PHP's session data 2010-06-08

    Recently, my articles are a bit of recent project experience ^ ^ The project started on the design of the "great", considering a lot of load balancing side of things, such as using nginx to php requests shared by a number of independent running