Skip to content

Commit 7d3ad0b

Browse files
initial commit
1 parent 697394a commit 7d3ad0b

9 files changed

+19
-25
lines changed

README.md

+19-25
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ As stated in the official [ioredis documentation](https://github.com/redis/iored
1818

1919
> "All keys in a pipeline should belong to slots served by the same node, since ioredis sends all commands in a pipeline to the same node."
2020
21-
This means that when executing multiple commands in a pipeline, all keys must belong to the same Redis slot, as `ioredis` sends the pipeline commands to a single node. If the keys interact with different shards, pipeline commands would fail with error `All the keys in a pipeline command should belong to the same slot`
21+
This means that when executing multiple commands in a pipeline, all keys must belong to the same Redis slot, as `ioredis` sends the pipeline commands to a single node. If the keys interact with different shards, pipeline commands would fail with error.
2222

2323
Due to this limitation, pipelining cannot be reliably used in Redis clusters with ioredis, leading to increased network latency as each command is executed individually instead of being batched together.
2424

@@ -118,20 +118,6 @@ The `clusterPipeline` method takes an array of Redis commands (e.g., [['set', 'k
118118
- **Pipeline Execution**: Once the commands are grouped by node, they are executed in parallel on each node, ensuring better performance when dealing with large pipelines.
119119
- **Result Handling**: Results from each node are merged and returned in the same order as the original commands.
120120

121-
## API Documentation
122-
123-
`clusterPipeline(commands: [string, ...any][]): Promise<any[]>`
124-
125-
### Parameters:
126-
127-
- `commands`: An array of Redis commands, where each command is an array starting with the command name and followed by its arguments.
128-
- Example: [['set', 'key1', 'value1'], ['get', 'key1']].
129-
130-
### Returns:
131-
132-
- A Promise that resolves to an array of command results in the same order as they were provided.
133-
- Example: [ ['OK'], ['value1'] ].
134-
135121
## Redis and Cluster
136122

137123
All the normal ioredis Redis and Cluster functionality remains available. This library only adds the `clusterPipeline` method to Cluster.
@@ -162,11 +148,15 @@ After implementing partial pipeline optimization, we observed significant API re
162148
| With Pipeline | 42ms (↓19%) | 101ms (↓15%)| 224ms (↓15%)|
163149

164150
#### Latency Comparison
165-
![API 1 Avg Latency Comparison](./images/api1_avg_latency.png)
166-
167-
![API 1 P95 Latency Comparison](./images/api1_p95_latency.png)
168-
169-
![API 1 P99 Latency Comparison](./images/api1_p99_latency.png)
151+
<p align="center">
152+
<img src="./images/api1_avg_latency.png" alt="API 2 Avg Latency Comparison" width="80%"/>
153+
</p>
154+
<p align="center">
155+
<img src="./images/api1_p95_latency.png" alt="API 2 P95 Latency Comparison" width="80%"/>
156+
</p>
157+
<p align="center">
158+
<img src="./images/api1_p99_latency.png" alt="API 2 P99 Latency Comparison" width="80%"/>
159+
</p>
170160

171161
### API 2
172162

@@ -176,11 +166,15 @@ After implementing partial pipeline optimization, we observed significant API re
176166
| With Pipeline | 31ms (↓14%) | 57ms (↓27%) | 202ms (↓13%)|
177167

178168
#### Latency Comparison
179-
![API 2 Avg Latency Comparison](./images/api2_avg_latency.png)
180-
181-
![API 2 P95 Latency Comparison](./images/api2_p95_latency.png)
182-
183-
![API 2 P99 Latency Comparison](./images/api2_p99_latency.png)
169+
<p align="center">
170+
<img src="./images/api2_avg_latency.png" alt="API 2 Avg Latency Comparison" width="80%"/>
171+
</p>
172+
<p align="center">
173+
<img src="./images/api2_p95_latency.png" alt="API 2 P95 Latency Comparison" width="80%"/>
174+
</p>
175+
<p align="center">
176+
<img src="./images/api2_p99_latency.png" alt="API 2 P99 Latency Comparison" width="80%"/>
177+
</p>
184178

185179
## Key Learnings & Next Steps
186180
- **Pipeline execution improved response times** significantly in cluster mode.

images/api1_avg_latency.png

-345 KB
Loading

images/api1_p95_latency.png

-172 KB
Loading

images/api1_p99_latency.png

-202 KB
Loading

images/api2_avg_latency.png

-342 KB
Loading

images/api2_p95_latency.png

-387 KB
Loading

images/api2_p99_latency.png

-439 KB
Loading

images/onebyone_latency.png

98.3 KB
Loading

images/parallel_latency.png

96.8 KB
Loading

0 commit comments

Comments
 (0)