让我先说这是对
this topic的后续问题.
通过从Solaris(SmartOS)切换到用于memcached服务器的Ubuntu,“解决了”.现在我们将负载乘以约5倍,并再次遇到问题.
我们正在运行一个大约1000个请求/分钟的站点,每个请求命中Memcached大约3次读取和1次写入.因此负载大约是每秒65个请求.缓存中的总数据大约为37M,每个密钥包含非常少量的数据(JSON编码的整数数组小于1K).
我们在这些页面上设置了基准测试脚本,并将数据输入StatsD进行日志记录.问题是Memcached需要很长时间才能响应.这些似乎与流量高峰无关.
什么可能导致这些尖峰?为什么memcached会接管一秒钟回复?我们刚刚启动了第二台服务器进入池中,并没有在峰值的频率或严重程度上产生任何明显的差异.
这是服务器上getStats()的输出:
Array ( [-----------] => Array ( [pid] => 1364 [uptime] => 3715684 [threads] => 4 [time] => 1336596719 [pointer_size] => 64 [rusage_user_seconds] => 7924 [rusage_user_microseconds] => 170000 [rusage_system_seconds] => 187214 [rusage_system_microseconds] => 190000 [curr_items] => 12578 [total_items] => 53516300 [limit_maxbytes] => 943718400 [curr_connections] => 14 [total_connections] => 72550117 [connection_structures] => 165 [bytes] => 2616068 [cmd_get] => 450388258 [cmd_set] => 53493365 [get_hits] => 450388258 [get_misses] => 2244297 [evictions] => 0 [bytes_read] => 2138744916 [bytes_written] => 745275216 [version] => 1.4.2 ) [-----------:11211] => Array ( [pid] => 8099 [uptime] => 4687 [threads] => 4 [time] => 1336596719 [pointer_size] => 64 [rusage_user_seconds] => 7 [rusage_user_microseconds] => 170000 [rusage_system_seconds] => 290 [rusage_system_microseconds] => 990000 [curr_items] => 2384 [total_items] => 225964 [limit_maxbytes] => 943718400 [curr_connections] => 7 [total_connections] => 588097 [connection_structures] => 91 [bytes] => 562641 [cmd_get] => 1012562 [cmd_set] => 225778 [get_hits] => 1012562 [get_misses] => 125161 [evictions] => 0 [bytes_read] => 91270698 [bytes_written] => 350071516 [version] => 1.4.2 ) )
编辑:这是设置和检索10,000个值的结果.
正常:
Stored 10000 values in 5.6118 seconds. Average: 0.0006 High: 0.1958 Low: 0.0003 Fetched 10000 values in 5.1215 seconds. Average: 0.0005 High: 0.0141 Low: 0.0003
当Spiking:
Stored 10000 values in 16.5074 seconds. Average: 0.0017 High: 0.9288 Low: 0.0003 Fetched 10000 values in 19.8771 seconds. Average: 0.0020 High: 0.9478 Low: 0.0003