killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
757 stars 280 forks source link

求助,客户端初次建连时,执行build方法耗时很长 #76

Closed huangjinvv closed 6 years ago

huangjinvv commented 6 years ago

每次memcache客户端在初次建连时,执行XMemcachedClientBuilder.build()方法,发现耗时总需要5秒。求助帮忙看下原因,是哪个配置设置有问题吗?

执行日志: 2018-03-07 10:49:50,770 INFO [http-nio-8080-exec-1] net.rubyeye.xmemcached.XMemcachedClient.buildConnector(XMemcachedClient.java:729) XMemcachedClient is using Text protocol 2018-03-07 10:49:55,952 INFO [http-nio-8080-exec-1] com.google.code.yanf4j.nio.impl.SelectorManager.(SelectorManager.java:37) Creating 8 reactors...

cache1 cache2

cache3

huangjinvv commented 6 years ago

原因已找到,和xmemcache配置没有关系。主要是在macOS Sierra环境下,InetAddress.getlocalhost()在获取本机地址时耗时会超过5s,经测试必现。 解决方案:在/etc/hosts里配置2个本机hostname映射绑定,避免hostname走dns解析,经测试后耗时已正常。