ahww520 / xmemcached

Automatically exported from code.google.com/p/xmemcached
Apache License 2.0
0 stars 0 forks source link

频繁报TimeoutException #181

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

小弟初学memcache,客户端使用xmc1.3.5,服务端是1.4版本,启动�
��令是

[code="shell"]memcached -m 1024 -u root -p 11211 -c 2048[/code]

现在发现老频繁的报TimeoutException,不知道如何解决
配置文件如下:
[code="xml"]
<bean name="baseMemcachedClientBuilder" 
class="net.rubyeye.xmemcached.XMemcachedClientBuilder" abstract="true">

        <property name="connectionPoolSize" value="30"/>
        <property name="commandFactory">
            <bean class="net.rubyeye.xmemcached.command.TextCommandFactory"/>
        </property>
        <property name="sessionLocator">
            <bean class="net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator"/>
        </property>
        <property name="transcoder">
            <bean class="net.rubyeye.xmemcached.transcoders.SerializingTranscoder"/>
        </property>
        <property name="configuration" ref="configuration"/>
    </bean>

    <bean name="showMemCacheBuilder" class="net.rubyeye.xmemcached.XMemcachedClientBuilder"
          parent="baseMemcachedClientBuilder">               <constructor-arg name="addressList">
                    <list>
                        <bean class="java.net.InetSocketAddress">
                            <constructor-arg>
                                <value>${memcache.show.client1.ip}</value>
                            </constructor-arg>
                            <constructor-arg>
                                <value>${memcache.show.client1.port}</value>
                            </constructor-arg>
                        </bean>
                    </list>
                </constructor-arg>
                <constructor-arg name="weights">
                    <list>
                        <value>1</value>
                    </list>
                </constructor-arg>
    </bean>

    <!-- Use factory bean to build memcached client -->
    <bean name="showCachedClient" factory-bean="showMemCacheBuilder"
          factory-method="build" destroy-method="shutdown">
    </bean>

    <bean name="configuration" class="com.google.code.yanf4j.config.Configuration">
    </bean>

    <bean name="showCacheWrapper" class="com.youku.recommend.cache.memcache.impl.RecommendCacheWrapper">
        <property name="client" ref="showCachedClient"/>
        <property name="exp" value="2592000"/>
    </bean>
[/code]
完整的异常堆栈如下:
[code="java"]
2012-03-06 11:19:08,950 [20226877@qtp-31711672-0] WARN  
[com.youku.recommend.action.LoadDataAction] - file not 
found:d:/data/recommend/interfacefile/b_v_0_20120305
java.util.concurrent.TimeoutException: Timed out(200) waiting for operation
    at net.rubyeye.xmemcached.XMemcachedClient.latchWait(XMemcachedClient.java:2528)
    at net.rubyeye.xmemcached.XMemcachedClient.sendStoreCommand(XMemcachedClient.java:2511)
    at net.rubyeye.xmemcached.XMemcachedClient.set(XMemcachedClient.java:1278)
    at net.rubyeye.xmemcached.XMemcachedClient.set(XMemcachedClient.java:1336)
    at com.youku.recommend.cache.memcache.MemCacheWrapper.set(MemCacheWrapper.java:52)
    at com.youku.recommend.cache.service.RecommendCacheService.putShows(RecommendCacheService.java:84)
    at com.youku.recommend.async.task.file.ShowRecommendReadTask.handleFileLine(ShowRecommendReadTask.java:103)
    at com.youku.recommend.async.task.file.ShowRecommendReadTask.loadFile(ShowRecommendReadTask.java:70)
    at com.youku.recommend.async.task.file.ShowRecommendReadTask.run(ShowRecommendReadTask.java:45)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
[/code]

把连接池大小和等待时间设置长也不能解决这个问题,请高��
�们帮忙解决下

Original issue reported on code.google.com by Dannis.R...@gmail.com on 6 Mar 2012 at 4:04

GoogleCodeExporter commented 8 years ago
我也遇到了和你一样的情况,我客户端的版本是xmc1.3.5.2,服务��
�的版本是1.4.5,我这边出现这种情况是在我从memcache批量获取��
�量数据的时候就会出现,之后,无论获取什么数据,都会出现这�
��异常了

Original comment by lyys...@gmail.com on 14 Mar 2012 at 3:08

GoogleCodeExporter commented 8 years ago
连接池通常不要设置,使用默认的1就足够了。
加大opTimeout到5000,也就是5秒。

Original comment by killme2...@gmail.com on 14 Mar 2012 at 3:12

GoogleCodeExporter commented 8 years ago
回2楼的兄弟,我这个对响应时间和性能要求比较高,不能设�
��这么长的等待时间,否则并发量高的时候会使resin僵死

Original comment by Dannis.R...@gmail.com on 14 Mar 2012 at 3:18

GoogleCodeExporter commented 8 years ago
5秒是最大的等待时间,而非平均等待时间,这是为了防止偶�
��几次的长响应时间影响到后续的请求(例如gc暂停引起、网�
��瞬断等)。

Original comment by killme2...@gmail.com on 14 Mar 2012 at 3:30

GoogleCodeExporter commented 8 years ago
没有后续问题我关闭了,谢谢。如果你希望控制响应延迟,��
�可以将mergeFactor设小一些。1.3.6发布将这个参数默认从150设置
成50,并且禁止了nagle算法。如果你还在用1.3.5,可以自己编程调
整下参数。

Original comment by killme2...@gmail.com on 26 Mar 2012 at 10:32

GoogleCodeExporter commented 8 years ago
看了源代码,mergeFactor并不能解决根本问题,mergeFactor只是list
的初始化大小,应该在mergeBuffer加入合包超时,当数据包小数
量大的时候,如果没有达到sendBufferSize,但是到了合包超时时
间也应该把信息发出去

Original comment by huxbm...@gmail.com on 27 Jun 2012 at 3:18

GoogleCodeExporter commented 8 years ago
@huxbmail
不到sendBufferSize大小当然会发出去,你看看代码,不需要什么
超时。
这个合并只做尽量合并,如果不够也没关系。

Original comment by killme2...@gmail.com on 27 Jun 2012 at 3:21