Redis FAQ and optimization

1. The fork

Fork operation time problem:

  • Fork is a synchronous operation, and while fork is very fast, it can block the main Redis process if too much data needs to be synchronized.

  • Memory dependent: The larger the memory, the longer the elapsed time (machine type dependent)

  • Query persistence execution time: late_fork_usec


To improve the fork

  • Limited use of physical machines or efficient support for fork virtualization technology

  • Controls the maximum available memory for Redis instances: maxMenory

  • Configure the Linux memory allocation policy properly: vm. Overcommit_memory = 1

  • Reduce the frequency of forking: for example, relax the automatic trigger time of AOF rewriting, unnecessary full copy

2. Out-of-process overhead

CPU:

  • Overhead: RDB and AOF file generation, which is CPU intensive
  • Optimization: No CPU binding, no CPU intensive deployment

Memory:

  • Cost: fork memory cost, copy-on-write
  • Optimization: echo never > / sys/kernel/mm/transparent_hugepage/enabled

Hard disk:

  • Overhead: AOF and RDB file writing, can be combined with ioSTAT, IOTOP analysis
  • Optimization:
  1. Do not deploy with high disk load servers, queues, storage services, etc
  2. no-appendfsync-on-rewrite= yes
  3. The disk type depends on the amount of data to be written, for example, SSD
  4. The standalone multi-instance persistent file directory can be divided into disks

3. AOF append is blocked

127.0. 01.:6379 > info persistence

-----
aof_delayed_fsync : 100   //aof blocks +1
-----
Copy the code

Personal blog: blog.yanxiaolu.cn /