设为首页 收藏本站
查看: 1377|回复: 0

[经验分享] Memcached客户端评测报告2010-01-25

[复制链接]

尚未签到

发表于 2015-9-1 13:50:40 | 显示全部楼层 |阅读模式
  缘起:

  原先用的https://sourceforge.net/projects/memcacheddotnet/一个客户端,在使用Increment这个方法时出现一些莫名的问题,于是请命对这个块做一个评测。

  定位:

  首先用熟悉的python来定位排除一下,是不是别的问题引起的,我找了良久http://www.tummy.com/Community/software/python-memcached/,用的是这个主流的库

  主要的当心是在windows下能不能好使,事实上我的担心是多余的,

  #! /usr/bin/env python

  #coding=utf-8

  #brief memcached increment test

  import memcache

  mc = memcache.Client(['192.168.0.74:11211'], debug=0)

  #mc.set("key","2")

  #mc.incr("key")

  #print mc.get("key")

  ##print mc.get("key")

  #import sys

  #sys.exit()

  
 
  
 
  mc.set("key",
"0")

  #mc.incr("key")

  #print type(mc.get("key"))

  
 
  for i in
xrange(1,10000):

      mc.incr("key")

  
if mc.get("key")<>str(i):

  
print
u"错误出现在%d".encode("gbk",'ignore')%i

  
break

  print
"done!"

  
 
  之后

  我给https://sourceforge.net/projects/memcacheddotnet/的类库做了一个简单的测试,来定位它的increment是否真有问题,结果表明真的是有的

  using System;

  using System.Collections.Generic;

  using System.Text;

  using Memcached.ClientLibrary;

  
 
  namespace IsolateMemcachedTest

  {

  
class Program

  
{

  
private
static MemcachedClient mc =
new MemcachedClient();

  
static
void Main(string[] args)

  
{

              mc.EnableCompression =
false;

              SockIOPool pool = SockIOPool.GetInstance();

              pool.SetServers(new
string[]{"192.168.0.74:11211"});

              pool.InitConnections =
3;//初始化链接数

              pool.MinConnections =
3;//最少链接数

              pool.MaxConnections =
3;//最大连接数

              pool.SocketConnectTimeout =
5000;//Socket链接超时时间

              pool.SocketTimeout =
5000;// Socket超时时间

              pool.MaintenanceSleep =
5;//维护线程休息时间

              pool.Failover =
false;
//失效转移(一种备份操作模式)

  
//pool.Nagle = Nagle;//���否用nagle算法启动socket

              pool.HashingAlgorithm = HashingAlgorithm.NewCompatibleHash;

              pool.Initialize();

  
 
              mc.Set("haha",
"1");

              Console.WriteLine(mc.Get("haha").ToString()
==
"1");

              Console.WriteLine(mc.Increment("haha"));

              Console.WriteLine(mc.Get("haha"));

  
 
  最后,我们要找一个替补的方案,它最后更新在2009-2

  http://code.google.com/p/beitmemcached/

  也写了一段测试代码

  using System;

  using System.Collections.Generic;

  using System.Text;

  using BeIT.MemCached;

  
 
  namespace IsolateMemcachedTest

  {

  
class Program2

  
{

  
static
void Main(string[] args)

  
{

              MemcachedClient.Setup("MyCache",
new
string[]
{
"192.168.0.74:11211"
});

              MemcachedClient cache = MemcachedClient.GetInstance("MyCache");

              cache.SendReceiveTimeout =
5000;

              cache.MinPoolSize =
1;

              cache.MaxPoolSize =
5;

  
 
              cache.Set("hh",
"0");

  
//Console.WriteLine(cache.Increment("hh", 1));

  
//Console.WriteLine(cache.Get("hh"));

  
 
  
for
(int i =
1; i <=
10000; i++)

  
{

                  cache.Increment("hh",
1);

  
if
(Convert.ToString(cache.Get("hh"))
!= i.ToString())

  
{

                      Console.WriteLine("在{0}处出现错误", i);

  
break;

  
}

  
 
  
}

              Console.WriteLine("done!");

              Console.WriteLine(cache.Get("hh"));

  
}

  
}

  }

  另外还有一个:

  http://www.codeplex.com/EnyimMemcached/,它最后更新在2008-11

  虽然它更新的速度不行,但是它的文字是这么写的,所以还是有些吸引力

  Main features


  • written for .NET, not ported from a different architecture (so uses the framework's features better)
  • configuration is stored in app/web.config (sample configuration file is included) or can be done from code
  • uses minimal locking to increase the throughput
  • supports consistent hashing for keys: a specific item goes to a specific server every time. (based on libketama, http://lists.danga.com/pipermail/memcached/2007-April/003834.html)
  • operations are factored into separate classes, so they are more separated from the main client class, easier manageability and thread safety
  • primitive types (currently some numeric types, bool, DateTime, byte[] and strings, but can be extended) are stored in an optimized form; only Objects are serialized
  • excessive extensibility: define your own configuration, serialization format or "consistent hashing" algorithm (see Cannot resolve release macro, invalid id.)
  • based on our non-disclosed specially handcrafted in-house performance test we're the fastest C# client ever, using negative amount of system resources, be it memory or CPU time
  • we follow memcached's protocol specification as strictly as no one else: even the memcached guys ask us if they don't understand something
  不过看了它的工程代码还是比较全面的,但是太复杂,不符合我的开发哲学

DSC0000.png

  所以它就被我排除了,所以我们还是聚焦到上面googlecode上的那个BiTMemcached的项目上了。

  BeITMemcached项目评测

  它的代码很是简洁,不过相比而言就没有什么单元测试什么的了,不过也不错

DSC0001.png

  
 
  Reference:

  http://www.cnblogs.com/sig556/archive/2009/12/30/1635722.html

  今天就到这里

  2010-02-04
另诉一下心中的苦闷,在测memcached的过期功能,结果linux server的日期时间不对,郁闷了我半天,小记于此以慰后来人

  另外,找了一个同步windows server 2003下时间的工具

  automachron

  时间同步服务配置

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-108408-1-1.html 上篇帖子: php写memcached ,c读取乱码问题[转] 下篇帖子: 【转】网站加速VPS篇:安装memcache和memcached
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表