Memcached 几秒钟后停止响应

Memcached 几秒钟后停止响应

我的 memcached (v1.5.13) 实例出现了问题。它启动正常,但几秒后就无响应了。我使用当前已更新的 arch-linux 机器,尝试从本地主机访问它,因此不存在防火墙/网络问题。

我尝试使用“官方的“工具,这是结果:

$ systemctl start memcached.service 
$ ./mc_conn_tester.pl -s localhost -p 11211 -c 1000 --timeout 1
loop: (timeout: 1) (elapsed: 0.00663400) (conn: 0.00418401) (set: 0.00200486) (get: 0.00035810)
loop: (timeout: 1) (elapsed: 0.00163913) (conn: 0.00074816) (set: 0.00039697) (get: 0.00038695)
loop: (timeout: 1) (elapsed: 0.00193477) (conn: 0.00113797) (set: 0.00030398) (get: 0.00041795)
loop: (timeout: 1) (elapsed: 0.00166988) (conn: 0.00101185) (set: 0.00033712) (get: 0.00024605)
loop: (timeout: 1) (elapsed: 0.00124598) (conn: 0.00079703) (set: 0.00018406) (get: 0.00021100)
loop: (timeout: 1) (elapsed: 0.00123787) (conn: 0.00081491) (set: 0.00020504) (get: 0.00016499)
loop: (timeout: 1) (elapsed: 0.00171614) (conn: 0.00114703) (set: 0.00028014) (get: 0.00022793)
loop: (timeout: 1) (elapsed: 0.00115395) (conn: 0.00074410) (set: 0.00015283) (get: 0.00018811)
loop: (timeout: 1) (elapsed: 0.00132918) (conn: 0.00079608) (set: 0.00030398) (get: 0.00016999)
loop: (timeout: 1) (elapsed: 0.00126791) (conn: 0.00082994) (set: 0.00016093) (get: 0.00021601)
loop: (timeout: 1) (elapsed: 0.00120115) (conn: 0.00081515) (set: 0.00015998) (get: 0.00017190)
loop: (timeout: 1) (elapsed: 0.00153708) (conn: 0.00091696) (set: 0.00025797) (get: 0.00027800)
loop: (timeout: 1) (elapsed: 0.00208688) (conn: 0.00102091) (set: 0.00049210) (get: 0.00047183)
loop: (timeout: 1) (elapsed: 0.00124884) (conn: 0.00082898) (set: 0.00017500) (get: 0.00018001)
loop: (timeout: 1) (elapsed: 0.00228310) (conn: 0.00106001) (set: 0.00074816) (get: 0.00034499)
loop: (timeout: 1) (elapsed: 0.00214005) (conn: 0.00116301) (set: 0.00035381) (get: 0.00044703)
loop: (timeout: 1) (elapsed: 0.00207090) (conn: 0.00098491) (set: 0.00034094) (get: 0.00066209)
loop: (timeout: 1) (elapsed: 0.00130296) (conn: 0.00073791) (set: 0.00019097) (get: 0.00029707)
loop: (timeout: 1) (elapsed: 0.00242686) (conn: 0.00132298) (set: 0.00049806) (get: 0.00054789)
loop: (timeout: 1) (elapsed: 0.00280905) (conn: 0.00146294) (set: 0.00038409) (get: 0.00087500)
loop: (timeout: 1) (elapsed: 0.00151491) (conn: 0.00077105) (set: 0.00036383) (get: 0.00027919)
loop: (timeout: 1) (elapsed: 0.00125599) (conn: 0.00063396) (set: 0.00040388) (get: 0.00016403)
loop: (timeout: 1) (elapsed: 0.00157404) (conn: 0.00080013) (set: 0.00019789) (get: 0.00049305)
loop: (timeout: 1) (elapsed: 0.00114512) (conn: 0.00071216) (set: 0.00017500) (get: 0.00020289)
Fail: (timeout: 1) (elapsed: 1.00045800) (conn: 0.00885892) (set: 0.00000000) (get: 0.00000000)
Fail: (timeout: 1) (elapsed: 1.00032616) (conn: 0.00062394) (set: 0.00000000) (get: 0.00000000)
Fail: (timeout: 1) (elapsed: 1.00024891) (conn: 0.00064898) (set: 0.00000000) (get: 0.00000000)
Fail: (timeout: 1) (elapsed: 1.00029612) (conn: 0.00111318) (set: 0.00000000) (get: 0.00000000)
Fail: (timeout: 1) (elapsed: 1.00028920) (conn: 0.00076103) (set: 0.00000000) (get: 0.00000000)
Fail: (timeout: 1) (elapsed: 1.00022006) (conn: 0.00080514) (set: 0.00000000) (get: 0.00000000)
Fail: (timeout: 1) (elapsed: 1.00071883) (conn: 0.00067496) (set: 0.00000000) (get: 0.00000000)
Fail: (timeout: 1) (elapsed: 1.00066304) (conn: 0.00082493) (set: 0.00000000) (get: 0.00000000)
^CAverages: (conn: 0.03975320) (set: 0.00907159) (get: 0.00800204)

这是-vv每个 的输出Loop,此后 s 期间不会显示任何内容Fail

<28 new auto-negotiating client connection
28: Client using the ascii protocol
<28 set foo 0 0 2
>28 STORED
<28 set foo 0 0 2
>28 STORED
<28 set foo 0 0 2
>28 STORED
<28 get foo
>28 sending key foo
>28 END
<28 get foo
>28 sending key foo
>28 END
<28 get foo
>28 sending key foo
>28 END
<28 get foo
>28 sending key foo
>28 END
<28 get foo
>28 sending key foo
>28 END
<28 get foo
>28 sending key foo
>28 END
<28 connection closed.

同样的情况也发生了memcached-tool,我重新启动后可以正常连接,但只能持续几秒钟:

$ systemctl restart memcached.service
$ memcached-tool 127.0.0.1:11211 stats
#127.0.0.1:11211   Field       Value
         accepting_conns           1
               auth_cmds           0
             auth_errors           0
                   bytes           0
              bytes_read          14
           bytes_written        1878
              cas_badval           0
                cas_hits           0
              cas_misses           0
               cmd_flush           0
                 cmd_get           0
                 cmd_set           0
               cmd_touch           0
             conn_yields           0
   connection_structures           3
   crawler_items_checked           0
       crawler_reclaimed           0
        curr_connections           2
              curr_items           0
               decr_hits           0
             decr_misses           0
             delete_hits           0
           delete_misses           0
         direct_reclaims           0
          evicted_active           0
       evicted_unfetched           0
               evictions           0
       expired_unfetched           0
             get_expired           0
             get_flushed           0
                get_hits           0
              get_misses           0
              hash_bytes      524288
       hash_is_expanding           0
        hash_power_level          16
               incr_hits           0
             incr_misses           0
                libevent 2.1.8-stable
          limit_maxbytes    67108864
     listen_disabled_num           0
        log_watcher_sent           0
     log_watcher_skipped           0
      log_worker_dropped           0
      log_worker_written           0
       lru_bumps_dropped           0
     lru_crawler_running           0
      lru_crawler_starts         255
  lru_maintainer_juggles          52
       lrutail_reflocked           0
            malloc_fails           0
         max_connections        1024
           moves_to_cold           0
           moves_to_warm           0
        moves_within_lru           0
                     pid         921
            pointer_size          64
               reclaimed           0
    rejected_connections           0
            reserved_fds          20
           rusage_system    0.022412
             rusage_user    0.014347
   slab_global_page_pool           0
slab_reassign_busy_deletes           0
slab_reassign_busy_items           0
slab_reassign_chunk_rescues           0
slab_reassign_evictions_nomem           0
slab_reassign_inline_reclaim           0
   slab_reassign_rescues           0
   slab_reassign_running           0
             slabs_moved           0
                 threads           4
                    time  1558023648
time_in_listen_disabled_us           0
       total_connections           4
             total_items           0
              touch_hits           0
            touch_misses           0
                  uptime           5
                 version      1.5.13

然后,当我重试时,它只是挂在那里等待:

$ memcached-tool 127.0.0.1:11211 stats

我彻底迷路了。

答案1

遇到了同样的问题。日志没有显示任何有用的信息。

就我而言,问题在于太多打开的客户端连接处于(未关闭)状态,因此无法建立新的连接。在客户端,这通常不会显示或记录(尽管这取决于客户端库)。

memcached-tool停止工作,因为到最后它也只是另一个 TCP 连接,试图获取统计数据。

您可以使用 netstat 检查当前客户端列表,例如:

netstat | grep memcached | grep ESTAB | wc -l

看看这个是否太高(默认最大是 1024 左右?)和/或客户是谁。

相关内容