memcached

memcached全面剖析–5. memcached的应用和兼容程序

风流意气都作罢 提交于 2019-12-04 03:21:53
版权声明 :可以任意转载,但转载时必须标明原作者charlee、原始链接 http://tech.idv2.com/2008/07/31/memcached-005/ 以及本声明。 memcached的连载终于要结束了。 到 上次 为止, 我们介绍了与memcached直接相关的话题,本次介绍一些mixi的案例和 实际应用上的话题,并介绍一些与memcached兼容的程序。 mixi案例研究 mixi在提供服务的初期阶段就使用了memcached。 随着网站访问量的急剧增加,单纯为数据库添加slave已无法满足需要,因此引入了memcached。 此外,我们也从增加可扩展性的方面进行了验证,证明了memcached的速度和稳定性都能满足需要。 现在,memcached已成为mixi服务中非常重要的组成部分。 图1 现在的系统组件 服务器配置和数量 mixi使用了许许多多服务器,如数据库服务器、应用服务器、图片服务器、 反向代理服务器等。单单memcached就有将近200台服务器在运行。 memcached服务器的典型配置如下: CPU:Intel Pentium 4 2.8GHz 内存:4GB 硬盘:146GB SCSI 操作系统:Linux(x86_64) 这些服务器以前曾用于数据库服务器等。随着CPU性能提升、内存价格下降, 我们积极地将数据库服务器

Benefits of multiple memcached instances

[亡魂溺海] 提交于 2019-12-04 03:19:04
问题 Is there any difference between having 4 .5GB memcache servers running or one 2GB instance? Does running multiple instances offer any benifits? 回答1: If one instance fails, you're still get advantages of using the cache. This is especially true if you are using the Consistenthashing that will bring the same data to the same instance, rather than spreading new reads/writes among the machines that are still up. You may also elect to run servers on 32 bit operating systems, that cannot address

Simple Java caching library or design pattern?

断了今生、忘了曾经 提交于 2019-12-04 02:08:09
I need to frequently access the result of a time-consuming calculation. The result changes infrequently, so I have to recalculate the data from time to time but it is ok to use the outdated result for a while. What would be the easiest way to do this and is there an existing library method or design pattern? I am thinking of something like private static List myCachedList = null; ... // refresh list once in 3600 seconds if (needsRefresh(myCachedList, 3600)) { // run the calculation myCachedList = ... } // use either updated or previous value from here on A proper implementation might not be

PHP, Memcached works from command line but not from the web

天涯浪子 提交于 2019-12-04 01:46:26
I have PHP 5.3.3 installed on Centos 6.4 with the memcached.so extension, and httpd is running with version 2.2.15-26. Here is my index.php : $mc = new \Memcached(); $mc->addServer('127.0.0.1', 11211); $mc->set("test", "blah"); var_dump($mc->getResultCode()); var_dump($mc->getResultMessage()); var_dump($mc->get("test")); die; When I run it from the command line, it works . I get the following: 10:22:33 $ php index.php int(0) string(7) "SUCCESS" string(4) "blah" The memcache server also works from telnet. However, when I run index.php from the web, it fails. I get the following (from viewing

what is the max key length and max size of value in memcached?

前提是你 提交于 2019-12-03 23:54:33
I am using the memcached latest , may i know what is the max key length ,and max size of the value we can store in the memcached ? How to integrate the memcached with spring , any idea please . If you look at the source the max size of the key is 250 bytes. (look for the KEY_MAX_LENGTH key) The Maximum size of the object is 1MB by default. But there is an easy way where you can change that by making minor changes in the config. You can look at this . On integrating memcached with spring, Am not very sure, But you can look at this . It has details on how to use it here . Hope this helps. 来源:

如何通过 J2Cache 实现分布式 session 存储

痞子三分冷 提交于 2019-12-03 22:33:51
做 Java Web 开发的人多数都会需要使用到 session (会话),我们使用 session 来保存一些需要在两个不同的请求之间共享数据。一般 Java 的 Web 容器像 Tomcat、Resin、Jetty 等等,它们会在内存中保存 session 数据。这样做会有两个不足: 服务重启后 session 数据丢失 应用做集群部署的时候,不同的节点无法共享 session 数据 我们以使用比例最高的 Tomcat 为例,针对第二个问题 Tomcat 提供了集群 session 复制的解决方案,详情请看 官方文档 。看完文档你会发现 Tomcat 自带的方法配置非常复杂,而且它没有解决第一个问题 —— 服务重启导致 session 数据丢失的问题。 现在还有另外一种方案就是使用 memcached 或者是 redis 来存储 session 数据,于是就有了这么一些开源项目: https://www.oschina.net/p/tomcat-redis-session-manager https://www.oschina.net/p/redis-manager https://www.oschina.net/p/memcached-session-manager 这些开源项目使用和配置都比较简单,而且对应用完全透明,只需要在 server.xml 中配置好 Manager

Memcached set() fails: WRITE FAILURE

偶尔善良 提交于 2019-12-03 21:41:48
So Memcached fails to write certain keys, getResultMessage() says WRITE FAILURE I'm using this in setup: $this->mmcache = new Memcached(); $this->mmcache->addServer('localhost',11211, 100); $this->mmcache->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $this->mmcache->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY); $this->mmcache->setOption(Memcached::OPT_COMPRESSION, false); Some keys work every time, some fail everytime. I even tried base64 encoding the keys but they fail anyway, even simple function like for($i=1;$i<100;$i++) { $this->mmcache->set('testkey'.$i,$i*100

NHibernate.Caches.MemCache web.config for cache expiration time

元气小坏坏 提交于 2019-12-03 21:29:56
I'm migrating to Nhibernate 2.0 GA but have some trouble with setting cache expirations in memcached provider. I see in the NHibernate.Caches.MemCache sources that there is a property for expiration and a default value for 300 seconds. There are also properties for cache regions but the config section handler does not seem to map them. Is there some other way cache expiration times are set that is not provider specific -- Here is functional web config section (without an expiration settings obviously). <memcache> <memcached host="127.0.0.1" port="11211"/> <!-- or multiples --> </memcache>

How to improve PHP performance?

那年仲夏 提交于 2019-12-03 20:21:04
I've created PHP application for Facebook. It uses MySQL, Memcached and works on Lighttpd on Centos 2,6 Ghz and 2 GB RAM. it's basically one PHP file that after first run is cached and every next time it's served in 0,8 ms directly from Memcached. What more can I do to shorten this time? Once you get to 0.8 ms, I'm not sure you can go any lower. However, you can set up multiple servers to handle many concurrent requests (with a common memcached). You will then be able to scale very high by simply adding a new server when you reach limits. Run XDebug and run the profiler . There you can see if

Memcached vs SQL Server cache

﹥>﹥吖頭↗ 提交于 2019-12-03 19:24:59
问题 I've been reading a lot of articles that suggest putting a Memcached (or Velocity, etc) in front of a database is more efficient than hitting the database directly. It will reduce the number of hits on the database by looking up the data in a memory cache, which is faster than hitting the database. However, SQL Server has it's own memory cache for objects in the database. When data is retrieved, SQL Server maintains its cache and will (if necessary) pull the row from it's memory and not hit