redis是一个很NB的nosql,吞吐量很高,在对服务器做benchmark的时候10W qps都没有问题。 但是这样一个大杀器要是用的地方不对就问题也挺多。 然后用了 redis-faina.py 这个工具去检查到底有多慢,发现真的很慢啊,这个时候还没有怀疑是这个python脚本的问题。这个是后话了 然后用strace -rp 进行检查,发现每个get, set都非常慢,有时候居然要100ms来完成,查询了一下,这个get的结果是空啊。 看了下这个redis的qps才2啊, 一台可以支持10W qps的redis服务器怎么在2个qps的情况下会那么慢呢。赶紧检查配置。从头看到尾就发现如下这个不熟悉的配置。 ```c

Redis calls an internal function to perform many background tasks, like # closing connections of clients in timeot, purging expired keys that are # never requested, and so forth. # # Not all tasks are perforemd with the same frequency, but Redis checks for # tasks to perform accordingly to the specified "hz" value. # # By default "hz" is set to 10. Raising the value will use more CPU when # Redis is idle, but at the same time will make Redis more responsive when # there are many keys expiring at the same time, and timeouts may be # handled with more precision. # # The range is between 1 and 500, however a value over 100 is usually not # a good idea. Most users should use the default of 10 and raise this up to # 100 only in environments where very low latency is required. hz 10

  • 本文作者: Timo
  • 本文链接: 3630.html
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!