netty io.netty.util.internal.OutOfDirectMemoryError

After adding a self-written code to the redis cache, this problem occurred when using JMeter for stress testing:
io out-of-heap memory overflow exception when using netty, this situation generally occurs in large concurrency situations

problem causes

  1. The reason for this: springboot integrates redis by default using lettuce to operate the redis client after 2.0, and he uses netty for network communication
  2. I did not specify the off-heap memory in the development, but specified -Xmx100m;
    Insert picture description here
  3. If netty does not specify off-heap memory, it uses -Xmx100m by default; however, no matter how large you set the memory, as long as there is sufficient concurrency, this exception will definitely occur! (Occurrence reason: we failed to get the immediate release of the memory)
    Insert picture description here
  4. Its default value can be set by -Dio.netty.maxDirectMemory (do not set the default to use -Xmx100m;)
    Insert picture description here

Solution

  1. Upgrading our lettuce client
    Lettuce advantages: huge throughput;
  2. Switch to using jedis to operate redis
    jedis Disadvantages: it has not been updated for a long time,
    just as follows: just change the dependency!Insert picture description here

Guess you like

Origin blog.csdn.net/lq1759336950/article/details/115263096