Redis优化

网络相关优化

使用pipeline模式

pipeline有效地减少了round trip。同时ethernet网络的packet size通常为1500 bytes,在pipeline的请求总量不大的情况下,pipeline能有效地调高remote socket情况下的throughput.

使用unix socket

使用unix socket需要redis进行配置,设计的配置参数包括:

unixsocket /tmp/redis.sock

unixsocketperm 755
 

有效数据存储

有效使用Hash结构的内存空间

Hash结构在总字节数小于512byte的时候,申请的空间是一样的。可能的话,可以在hash结构中存储更多的数据,保证内存的高效使用。

性能优化

numa配置

让各种不同类型的任务使用不同的cpu core运行,提高L3 cache的命中率。

官方的 benchmarks

https://redis.io/topics/benchmarks

原文地址:https://www.cnblogs.com/machong/p/6902062.html