Skip to content

The issue does not belong to node-redis repo but sharing it here to get recommendations as ioredis is deprecated #2777

Open
@vgnanasekaran

Description

@vgnanasekaran

Description

redis/ioredis#1866

Issue Title - Multiple set commands are sent in single packet to server - no pipeline in code - auto pipeline is also not enabled. #1866

Please find below the code that sends 100 set commands in a for loop. For some execution each set command is sent as individual packet to redis server and each response ("ok") is received as individual packet.

one-set-one-packet

On some executions multiple set commands are sent in one packet to redis server and the responses are grouped into one packet.

multiple-set-one-packet

const Redis = require('ioredis');

let endpoints = new Array(1)
endpoints[0] = { host: "ip", port: 26379};

const redis = new Redis({
sentinels: endpoints,
password: '',
name: 'mymaster',
role: 'master',
});
console.log(redis)
redis.on('connect', function(err) {
if(err) {
console.log('error: ' + JSON.stringify(err));
return;
}
console.log('[Redis] up and running!');
return;
});
for (let i = 0; i < 100; i++) {
redis.set('hello' + i, 'test' + i, 'EX', 60, function(err,result) {
console.log('set command error response: ' + err)
console.log('set command result: ' + result)
});
}

When the volume of requests is high to the node.js microservice, less packets with more number of set commands are sent to redis sentinel host. The microservice memory keeps growing and crashes with OOM.

Trying to understand how the grouping of commands happens when pipeline is not used and also the auto pipeline is not enabled.

can this grouping behavior cause memory issues as observed in my case? Is there a way to force one command per request?

ioredis version - 4.11.2

Please advice. Any pointers will be of great help. Thank you

Node.js Version

v11.10.1

Redis Server Version

5.0.7

Node Redis Version

No response

Platform

EC2

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions