gpt4 book ai didi

php - Memcache 间歇性错误

转载 作者:搜寻专家 更新时间:2023-10-31 21:20:28 25 4
gpt4 key购买 nike

对于以下间歇性 Memcache 连接失败的可能原因的任何建议,我们将不胜感激:

Memcache::connect(): Server 127.0.0.1 (tcp 11211, udp 0) failed with: 
Only one usage of each socket address (protocol/network address/port) is normally permitted.

据我所知,PHP 脚本仅在构建 Controller 时尝试打开连接,即没有多次尝试打开连接。该错误仅在尝试连接的地方报告。

我还查看了 memcached 统计数据,看起来没有错:

array(36) {
["pid"]=> string(4) "5788"
["uptime"]=> string(6) "731274"
["time"]=> string(10) "1533137924"
["version"]=> string(16) "1.4.5_4_gaa7839e
["pointer_size"]=> string(2) "64"
["curr_connections"]=> string(1) "2"
["total_connections"]=> string(8) "31881420"
["connection_structures"]=> string(3) "163"
["cmd_get"]=> string(8) "26219501"
["cmd_set"]=> string(8) "17532714"
["cmd_flush"]=> string(4) "1110"
["get_hits"]=> string(8) "25834764"
["get_misses"]=> string(6) "384737"
["delete_misses"]=> string(1) "5"
["delete_hits"]=> string(7) "1252043"
["incr_misses"]=> string(1) "0"
["incr_hits"]=> string(1) "0"
["decr_misses"]=> string(1) "0"
["decr_hits"]=> string(1) "0"
["cas_misses"]=> string(1) "0"
["cas_hits"]=> string(1) "0"
["cas_badval"]=> string(1) "0"
["auth_cmds"]=> string(1) "0"
["auth_errors"]=> string(1) "0"
["bytes_read"]=> string(11) "12021422144"
["bytes_written"]=> string(12) "163830241155"
["limit_maxbytes"]=> string(10) "4294967296"
["accepting_conns"]=> string(1) "1"
["listen_disabled_num"]=> string(1) "0"
["threads"]=> string(1) "4"
["conn_yields"]=> string(1) "0"
["bytes"]=> string(8) "89537575"
["curr_items"]=> string(5) "15811"
["total_items"]=> string(7) "2871704"
["evictions"]=> string(1) "0"
["reclaimed"]=> string(6) "570282"
}

系统在 Windows Server 上运行(如果影响)

最佳答案

This article 似乎可以解决问题。

It means that you are exhausting all the available network ports on the machine. By default the OS only has around 4000 ports available that are not reserved by the system. What happens is that when any network connection is closed it goes into a TIME_WAIT state for 240 seconds and cannot be reused until this wait state is over. So as an example, if there are 16 connections per second for 4 minutes (16*4*60=3840), you will exhaust all the ports shortly there after. Now if you have HAS and the MTA on the same machine, this will get exhausted a lot sooner because in addition to them communicating with each other, which uses 2 ports (one for the MTA and one for HAS), the MTA uses up a lot of ports sending the mail.

解决方法如下:

You can fix this by modifying the below values.

  1. One of the ways is to increase the dynamic port range. The max by default is 5000. You can set this up to 65534. HKLM\System\CurrentControlSet\Services\Tcpip\Parameters\MaxUserPort is the key to use.

  2. The second thing you can do is, once the connection does get into an TIME_WAIT state, you can reduce the time it is in that state. Default is 4 minutes, but you can set this to 30 seconds. HKLM\System\CurrentControlSet\Services\Tcpip\Parameters\TCPTimedWaitDelay is the key to use.

After these changes are made the system must be restarted.

如果失败,请尝试使用 resmon(一种鲜为人知的 Windows 资源监视器)来检查您的端口使用情况是否存在冲突服务。您可以从 Cortana 搜索框或命令 shell 访问它...

(我想将此归功于此,但这是团队的努力!)

最后,当您连接到 Memcache 时,通过 connect 方法的返回来检查您的连接是否成功是很有用的。如果使用 Memcache::add_server,您可能必须采用不同的方法,因为此方法只会在第一次尝试访问内存缓存时发现连接失败。

关于php - Memcache 间歇性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51637842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com