Memcache::set() broken pipe

♀尐吖头ヾ 提交于 2019-12-10 18:37:40

问题


In general, Memcache is working... but my log has many occurrences of this:

Memcache::set() [memcache.set]: send of 8192 bytes failed with errno=32 Broken pipe

(the number of bytes changes)

PHP5.3, Memcache class (v2.2.5 - the latest stable version)

What is a broken pipe, why is it happening so much, and can it be improved?


回答1:


I've been researching and reading on this for quite a bit and have been hearing a lot of confusion on this. There's very little documentation out there on Memcached options on the server side. I found a hidden gem, surprisingly hosted by MySQL. Check it out http://downloads.mysql.com/docs/mysql-memcached-en.pdf

There are a few potential causes, some quoted convincingly that:

  • ulimit on the OS level is set to a certain level that blocks additional connections
  • the number of connections have maxed out
  • it only happens during high load (sorry, but duh!)

I haven't been able to fathom nor imagine the above being true for most cases. For our case, it turns out we were switching to binary mode connection option when the app was running on auto mode prior (in -vv verbose mode, we say ascii writes). Once we turned on the binary option, writes were all failing, hence causing broken pipes.

As for max connections fallouts they can be detected when you take a look at the stats when you telnet into it. Look for the following

STAT accepting_conns 1
STAT listen_disabled_num 0

If listen disabled_num is 0, that's good. That means there are no drop connections since the start of the memcached instance.

Also try to optimize your connection with the following Memcached options, at least in PHP, we use the following:

$this->m = new Memcached();
$this->m->setOption(Memcached::OPT_TCP_NODELAY, true);
$this->m->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$this->m->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY);

All I can say is, tryout a few combination of settings, on the app side, the memcached server side and change other default settings on app (e.g. memcached.sess_lock_wait on memcached.ini file, see php -i|grep memcached for more info).

Good luck!




回答2:


I have similar case but for getextendedstats()

Notice: Memcache::getextendedstats(): send of 9 bytes failed with errno=32 Broken pipe in /usr/local/zend/share/ZendFramework/library/Zend/Cache/Backend/Memcached.php on line 382

Here is opinion which I find logical. http://unix.derkeiler.com/Newsgroups/comp.unix.programmer/2006-02/msg00348.html

My assumption is that memcached is not configured correctly or problem with networking, but I run memcached locally so not sure here I have networking problem.

I will try to solve problem and let you know what was the problem.




回答3:


Generally speaking when I see Broken Pipe errors it is during extremely high load. Is this the case with you? Some times simple parameter tuning can fix the issue. If you are allowing more connections into something than that something can handle, you will often get a broken pipe error.



来源:https://stackoverflow.com/questions/3714127/memcacheset-broken-pipe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!