经测试启动正常,测试数据库mysql,数据量为150万,测试方法是使用模糊查询找出一个类型为text的字段中包含“12”字符的记录
不用memcached下使用hibernate hql和JDBC均耗时1100ms左右,使用memcached做hibernate二级缓存后初始查询耗时在1100ms左右
后续查询最低0ms,最高32ms,大多数维持在16ms左右。
在服务器程序运行过程中结束memcached服务再进行查询,myeclipse控制台持续打印出以下错误
2015-03-06 14:17:03.546 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=3, #iq=0, topRop=null, topWop=net.spy.memcached.protocol.ascii.GetOperationImpl@18437e5, toWrite=0, interested=0}, attempt 2.
2015-03-06 14:17:11.562 INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=7, #iq=0, topRop=null, topWop=net.spy.memcached.protocol.ascii.GetOperationImpl@18437e5, toWrite=0, interested=0}
2015-03-06 14:17:12.484 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@1e171e9
2015-03-06 14:17:12.484 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to failure to connect to {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=7, #iq=0, topRop=null, topWop=net.spy.memcached.protocol.ascii.GetOperationImpl@18437e5, toWrite=0, interested=0}
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:701)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:322)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:219)
at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:1591)
查询过程陷入等待,耗时135047ms后查询到数据。
在安装memcached的服务器宕机后,二级缓存将不可用,查询过程慢到一个无法忍受的地步,时间大量耗费在重连memcached服务上,暂未找到解决办法
本文地址:http://www.cnblogs.com/wangjiajun/p/4332495.html
参考文章http://blog.sina.com.cn/s/blog_67b9ad8d01011xsd.html