redis-smq-benchmarks 9.0.9-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +22 -0
- package/README.md +192 -0
- package/README.template.md +186 -0
- package/dist/esm/bin/cli.d.ts +2 -0
- package/dist/esm/bin/cli.d.ts.map +1 -0
- package/dist/esm/bin/cli.js +121 -0
- package/dist/esm/bin/cli.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/src/common/base-benchmark.d.ts +39 -0
- package/dist/esm/src/common/base-benchmark.d.ts.map +1 -0
- package/dist/esm/src/common/base-benchmark.js +83 -0
- package/dist/esm/src/common/base-benchmark.js.map +1 -0
- package/dist/esm/src/common/redis-server.d.ts +13 -0
- package/dist/esm/src/common/redis-server.d.ts.map +1 -0
- package/dist/esm/src/common/redis-server.js +22 -0
- package/dist/esm/src/common/redis-server.js.map +1 -0
- package/dist/esm/src/consumer-benchmark.d.ts +9 -0
- package/dist/esm/src/consumer-benchmark.d.ts.map +1 -0
- package/dist/esm/src/consumer-benchmark.js +61 -0
- package/dist/esm/src/consumer-benchmark.js.map +1 -0
- package/dist/esm/src/e2e-benchmark.d.ts +4 -0
- package/dist/esm/src/e2e-benchmark.d.ts.map +1 -0
- package/dist/esm/src/e2e-benchmark.js +159 -0
- package/dist/esm/src/e2e-benchmark.js.map +1 -0
- package/dist/esm/src/helpers/create-worker.d.ts +13 -0
- package/dist/esm/src/helpers/create-worker.d.ts.map +1 -0
- package/dist/esm/src/helpers/create-worker.js +24 -0
- package/dist/esm/src/helpers/create-worker.js.map +1 -0
- package/dist/esm/src/helpers/ensure-queue.d.ts +4 -0
- package/dist/esm/src/helpers/ensure-queue.d.ts.map +1 -0
- package/dist/esm/src/helpers/ensure-queue.js +10 -0
- package/dist/esm/src/helpers/ensure-queue.js.map +1 -0
- package/dist/esm/src/helpers/prefill-queue.d.ts +4 -0
- package/dist/esm/src/helpers/prefill-queue.d.ts.map +1 -0
- package/dist/esm/src/helpers/prefill-queue.js +23 -0
- package/dist/esm/src/helpers/prefill-queue.js.map +1 -0
- package/dist/esm/src/producer-benchmark.d.ts +8 -0
- package/dist/esm/src/producer-benchmark.d.ts.map +1 -0
- package/dist/esm/src/producer-benchmark.js +47 -0
- package/dist/esm/src/producer-benchmark.js.map +1 -0
- package/dist/esm/src/threads/consumer-worker-thread.d.ts +2 -0
- package/dist/esm/src/threads/consumer-worker-thread.d.ts.map +1 -0
- package/dist/esm/src/threads/consumer-worker-thread.js +59 -0
- package/dist/esm/src/threads/consumer-worker-thread.js.map +1 -0
- package/dist/esm/src/threads/producer-worker-thread.d.ts +2 -0
- package/dist/esm/src/threads/producer-worker-thread.d.ts.map +1 -0
- package/dist/esm/src/threads/producer-worker-thread.js +54 -0
- package/dist/esm/src/threads/producer-worker-thread.js.map +1 -0
- package/dist/esm/src/types/index.d.ts +57 -0
- package/dist/esm/src/types/index.d.ts.map +1 -0
- package/dist/esm/src/types/index.js +6 -0
- package/dist/esm/src/types/index.js.map +1 -0
- package/package.json +69 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [9.0.9-next.0](https://github.com/weyoss/redis-smq/compare/v9.0.8...v9.0.9-next.0) (2026-01-08)
|
|
7
|
+
|
|
8
|
+
### 🐛 Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **redis-smq-benchmarks:** update bin script name to match pkg name ([b277b88](https://github.com/weyoss/redis-smq/commit/b277b887ee62f6eb3bf2dce69a4df8e6b99ae1bf))
|
|
11
|
+
|
|
12
|
+
### 📝 Documentation
|
|
13
|
+
|
|
14
|
+
- **redis-smq-benchmarks:** fix installation command ([173bb75](https://github.com/weyoss/redis-smq/commit/173bb755b140bc61a77fc3662934e312b7f87e36))
|
|
15
|
+
- **redis-smq-benchmarks:** update configuration default values ([37d38f1](https://github.com/weyoss/redis-smq/commit/37d38f1e9196ffa701f773e15d4d1aed128b0ddb))
|
|
16
|
+
|
|
17
|
+
### ⚡ Performance Improvements
|
|
18
|
+
|
|
19
|
+
- **redis-smq-benchmarks:** add benchmarking tool to assess performance and throughput ([57f672c](https://github.com/weyoss/redis-smq/commit/57f672cfbcf221cde3d75c0946741759bf52b742))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Weyoss <weyoss@outlook.com>, https://github.com/weyoss
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# RedisSMQ Benchmarks
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> You are viewing the documentation for the "next" branch. These docs describe unreleased changes published under the npm "next" dist-tag.
|
|
5
|
+
> For the latest stable documentation, see:
|
|
6
|
+
>
|
|
7
|
+
> - Master (stable) README: https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq-benchmarks
|
|
8
|
+
> - Latest release notes/tags: https://github.com/weyoss/redis-smq/releases/latest
|
|
9
|
+
> - Install stable packages with @latest; pre-release with @next.
|
|
10
|
+
|
|
11
|
+
A comprehensive benchmarking suite for RedisSMQ message queue system, measuring throughput, latency, and end-to-end performance under various workloads.
|
|
12
|
+
|
|
13
|
+
## 📊 Overview
|
|
14
|
+
|
|
15
|
+
This benchmark suite provides tools to measure RedisSMQ performance across different scenarios:
|
|
16
|
+
|
|
17
|
+
1. **Producer Throughput** - Measure message production rates
|
|
18
|
+
2. **Consumer Throughput** - Measure message consumption rates
|
|
19
|
+
3. **End-to-End Throughput** - Measure complete system performance with concurrent producers and consumers
|
|
20
|
+
|
|
21
|
+
**Note**: These benchmarks are for performance testing and should be run in a controlled environment. Always test with production-like data and conditions.
|
|
22
|
+
|
|
23
|
+
## 🚀 Quick Start
|
|
24
|
+
|
|
25
|
+
### Prerequisites
|
|
26
|
+
|
|
27
|
+
- Node.js 20+
|
|
28
|
+
- Redis server running (default: localhost:6379)
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install redis-smq@@next redis-smq-common@@next redis-smq-benchmarks@@next --save
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Basic Usage
|
|
37
|
+
|
|
38
|
+
## ⚙️ Configuration
|
|
39
|
+
|
|
40
|
+
Benchmarks can be configured using environment variables:
|
|
41
|
+
|
|
42
|
+
| Variable | Description | Default |
|
|
43
|
+
|-----------------------|-----------------------------------|------------|
|
|
44
|
+
| `BENCH_MESSAGES` | Total messages to process | `100000` |
|
|
45
|
+
| `BENCH_PRODUCERS` | Number of producer worker threads | `0` |
|
|
46
|
+
| `BENCH_CONSUMERS` | Number of consumer worker threads | `0` |
|
|
47
|
+
| `BENCH_SHOW_PROGRESS` | Benchmark progress reporting | `0` |
|
|
48
|
+
| `REDIS_HOST` | Redis server host | `localhost` |
|
|
49
|
+
| `REDIS_PORT` | Redis server port | `6379` |
|
|
50
|
+
| `REDIS_DB` | Redis server database | `0` |
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Example Configuration
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Run with custom configuration
|
|
57
|
+
REDIS_HOST=127.0.0.1 \
|
|
58
|
+
BENCH_PRODUCERS=10 \
|
|
59
|
+
BENCH_CONSUMERS=5 \
|
|
60
|
+
npx redis-smq-benchmarks
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 📈 Benchmark Types
|
|
64
|
+
|
|
65
|
+
### 1. Producer Throughput Benchmark
|
|
66
|
+
|
|
67
|
+
Measures how quickly producers can enqueue messages.
|
|
68
|
+
|
|
69
|
+
**Features:**
|
|
70
|
+
|
|
71
|
+
- Even distribution of messages across producers
|
|
72
|
+
- Real-time progress reporting
|
|
73
|
+
- Individual producer statistics
|
|
74
|
+
- Aggregate throughput calculation
|
|
75
|
+
|
|
76
|
+
**Usage:**
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
BENCH_MESSAGES=50000 BENCH_PRODUCERS=4 npx redis-smq-benchmarks
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2. Consumer Throughput Benchmark
|
|
83
|
+
|
|
84
|
+
Measures how quickly consumers can process messages.
|
|
85
|
+
|
|
86
|
+
**Features:**
|
|
87
|
+
|
|
88
|
+
- Pre-fills queue with messages
|
|
89
|
+
- Even distribution across consumers
|
|
90
|
+
- Individual consumer statistics
|
|
91
|
+
- Complete consumption tracking
|
|
92
|
+
|
|
93
|
+
**Usage:**
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
BENCH_MESSAGES=50000 BENCH_CONSUMERS=4 npx redis-smq-benchmarks
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 3. End-to-End Throughput Benchmark
|
|
100
|
+
|
|
101
|
+
Measures complete system performance with concurrent producers and consumers.
|
|
102
|
+
|
|
103
|
+
**Features:**
|
|
104
|
+
|
|
105
|
+
- Concurrent producer and consumer execution
|
|
106
|
+
- Production vs consumption phase tracking
|
|
107
|
+
- System backlog monitoring
|
|
108
|
+
- Complete throughput analysis
|
|
109
|
+
|
|
110
|
+
**Usage:**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
BENCH_MESSAGES=100000 BENCH_PRODUCERS=8 BENCH_CONSUMERS=8 npx redis-smq-benchmarks
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 📊 Output Metrics
|
|
117
|
+
|
|
118
|
+
Each benchmark provides detailed metrics:
|
|
119
|
+
|
|
120
|
+
### Individual Worker Metrics
|
|
121
|
+
|
|
122
|
+
- Messages processed per worker
|
|
123
|
+
- Time taken per worker
|
|
124
|
+
- Throughput per worker (messages/second)
|
|
125
|
+
|
|
126
|
+
### Aggregate Metrics
|
|
127
|
+
|
|
128
|
+
- Total messages processed
|
|
129
|
+
- Total time elapsed
|
|
130
|
+
- Overall throughput
|
|
131
|
+
- Average time per worker
|
|
132
|
+
|
|
133
|
+
### E2E-Specific Metrics
|
|
134
|
+
|
|
135
|
+
- Production throughput
|
|
136
|
+
- Consumption throughput
|
|
137
|
+
- System backlog (produced vs consumed)
|
|
138
|
+
- End-to-end latency
|
|
139
|
+
|
|
140
|
+
## 📊 Sample Output
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
Starting end-to-end throughput benchmark...
|
|
144
|
+
Queue: benchmarking/queue-1767808640925 | Messages: 100000 | Producers: 10 | Consumers: 5
|
|
145
|
+
Setting up producers and consumers...
|
|
146
|
+
|
|
147
|
+
========== E2E BENCHMARK COMPLETE ==========
|
|
148
|
+
Production Phase:
|
|
149
|
+
Total produced: 100000
|
|
150
|
+
Production time: 3.35s
|
|
151
|
+
Production throughput: 29824 msg/s
|
|
152
|
+
|
|
153
|
+
Consumption Phase:
|
|
154
|
+
Total consumed: 100000
|
|
155
|
+
Consumption time: 6.37s
|
|
156
|
+
Consumption throughput: 15689 msg/s
|
|
157
|
+
|
|
158
|
+
End-to-End:
|
|
159
|
+
Total time: 6.37s
|
|
160
|
+
Overall throughput: 15689 msg/s
|
|
161
|
+
System backlog: 0 messages
|
|
162
|
+
Status: All messages processed successfully ✓
|
|
163
|
+
============================================
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## 🏗️ Architecture
|
|
167
|
+
|
|
168
|
+
### Design Principles
|
|
169
|
+
|
|
170
|
+
1. **Worker-Based Architecture**: Each producer/consumer runs in its own worker thread
|
|
171
|
+
2. **Even Distribution**: Messages are evenly distributed across all workers
|
|
172
|
+
3. **Real-time Monitoring**: Progress updates during execution
|
|
173
|
+
4. **Graceful Shutdown**: Clean termination of all resources
|
|
174
|
+
5. **Extensible**: Easy to add new benchmark types
|
|
175
|
+
|
|
176
|
+
## Performance Tuning Tips
|
|
177
|
+
|
|
178
|
+
1. **Worker Count**: Increase worker count to leverage multi-core CPUs
|
|
179
|
+
3. **Redis Configuration**: Ensure Redis has sufficient memory and connection limits
|
|
180
|
+
4. **Network**: Local Redis provides the best performance. Network latency impacts throughput
|
|
181
|
+
|
|
182
|
+
## 📊 Interpreting Results
|
|
183
|
+
|
|
184
|
+
### Key Metrics to Monitor
|
|
185
|
+
|
|
186
|
+
1. **Throughput Plateau**: Point where adding more workers doesn't increase throughput
|
|
187
|
+
2. **CPU Utilization**: Monitor CPU usage during benchmarks
|
|
188
|
+
3. **Memory Usage**: Watch for memory leaks in long-running tests
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
RedisSMQ Benchmarks is released under the [MIT License](https://github.com/weyoss/redis-smq/tree/next/LICENSE).
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# RedisSMQ Benchmarks
|
|
2
|
+
|
|
3
|
+
__IS_NEXT_NOTE__
|
|
4
|
+
|
|
5
|
+
A comprehensive benchmarking suite for RedisSMQ message queue system, measuring throughput, latency, and end-to-end performance under various workloads.
|
|
6
|
+
|
|
7
|
+
## 📊 Overview
|
|
8
|
+
|
|
9
|
+
This benchmark suite provides tools to measure RedisSMQ performance across different scenarios:
|
|
10
|
+
|
|
11
|
+
1. **Producer Throughput** - Measure message production rates
|
|
12
|
+
2. **Consumer Throughput** - Measure message consumption rates
|
|
13
|
+
3. **End-to-End Throughput** - Measure complete system performance with concurrent producers and consumers
|
|
14
|
+
|
|
15
|
+
**Note**: These benchmarks are for performance testing and should be run in a controlled environment. Always test with production-like data and conditions.
|
|
16
|
+
|
|
17
|
+
## 🚀 Quick Start
|
|
18
|
+
|
|
19
|
+
### Prerequisites
|
|
20
|
+
|
|
21
|
+
- Node.js 20+
|
|
22
|
+
- Redis server running (default: localhost:6379)
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install redis-smq@__TAG_SUFFIX__ redis-smq-common@__TAG_SUFFIX__ redis-smq-benchmarks@__TAG_SUFFIX__ --save
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Basic Usage
|
|
31
|
+
|
|
32
|
+
## ⚙️ Configuration
|
|
33
|
+
|
|
34
|
+
Benchmarks can be configured using environment variables:
|
|
35
|
+
|
|
36
|
+
| Variable | Description | Default |
|
|
37
|
+
|-----------------------|-----------------------------------|------------|
|
|
38
|
+
| `BENCH_MESSAGES` | Total messages to process | `100000` |
|
|
39
|
+
| `BENCH_PRODUCERS` | Number of producer worker threads | `0` |
|
|
40
|
+
| `BENCH_CONSUMERS` | Number of consumer worker threads | `0` |
|
|
41
|
+
| `BENCH_SHOW_PROGRESS` | Benchmark progress reporting | `0` |
|
|
42
|
+
| `REDIS_HOST` | Redis server host | `localhost` |
|
|
43
|
+
| `REDIS_PORT` | Redis server port | `6379` |
|
|
44
|
+
| `REDIS_DB` | Redis server database | `0` |
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Example Configuration
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Run with custom configuration
|
|
51
|
+
REDIS_HOST=127.0.0.1 \
|
|
52
|
+
BENCH_PRODUCERS=10 \
|
|
53
|
+
BENCH_CONSUMERS=5 \
|
|
54
|
+
npx redis-smq-benchmarks
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 📈 Benchmark Types
|
|
58
|
+
|
|
59
|
+
### 1. Producer Throughput Benchmark
|
|
60
|
+
|
|
61
|
+
Measures how quickly producers can enqueue messages.
|
|
62
|
+
|
|
63
|
+
**Features:**
|
|
64
|
+
|
|
65
|
+
- Even distribution of messages across producers
|
|
66
|
+
- Real-time progress reporting
|
|
67
|
+
- Individual producer statistics
|
|
68
|
+
- Aggregate throughput calculation
|
|
69
|
+
|
|
70
|
+
**Usage:**
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
BENCH_MESSAGES=50000 BENCH_PRODUCERS=4 npx redis-smq-benchmarks
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 2. Consumer Throughput Benchmark
|
|
77
|
+
|
|
78
|
+
Measures how quickly consumers can process messages.
|
|
79
|
+
|
|
80
|
+
**Features:**
|
|
81
|
+
|
|
82
|
+
- Pre-fills queue with messages
|
|
83
|
+
- Even distribution across consumers
|
|
84
|
+
- Individual consumer statistics
|
|
85
|
+
- Complete consumption tracking
|
|
86
|
+
|
|
87
|
+
**Usage:**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
BENCH_MESSAGES=50000 BENCH_CONSUMERS=4 npx redis-smq-benchmarks
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3. End-to-End Throughput Benchmark
|
|
94
|
+
|
|
95
|
+
Measures complete system performance with concurrent producers and consumers.
|
|
96
|
+
|
|
97
|
+
**Features:**
|
|
98
|
+
|
|
99
|
+
- Concurrent producer and consumer execution
|
|
100
|
+
- Production vs consumption phase tracking
|
|
101
|
+
- System backlog monitoring
|
|
102
|
+
- Complete throughput analysis
|
|
103
|
+
|
|
104
|
+
**Usage:**
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
BENCH_MESSAGES=100000 BENCH_PRODUCERS=8 BENCH_CONSUMERS=8 npx redis-smq-benchmarks
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 📊 Output Metrics
|
|
111
|
+
|
|
112
|
+
Each benchmark provides detailed metrics:
|
|
113
|
+
|
|
114
|
+
### Individual Worker Metrics
|
|
115
|
+
|
|
116
|
+
- Messages processed per worker
|
|
117
|
+
- Time taken per worker
|
|
118
|
+
- Throughput per worker (messages/second)
|
|
119
|
+
|
|
120
|
+
### Aggregate Metrics
|
|
121
|
+
|
|
122
|
+
- Total messages processed
|
|
123
|
+
- Total time elapsed
|
|
124
|
+
- Overall throughput
|
|
125
|
+
- Average time per worker
|
|
126
|
+
|
|
127
|
+
### E2E-Specific Metrics
|
|
128
|
+
|
|
129
|
+
- Production throughput
|
|
130
|
+
- Consumption throughput
|
|
131
|
+
- System backlog (produced vs consumed)
|
|
132
|
+
- End-to-end latency
|
|
133
|
+
|
|
134
|
+
## 📊 Sample Output
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Starting end-to-end throughput benchmark...
|
|
138
|
+
Queue: benchmarking/queue-1767808640925 | Messages: 100000 | Producers: 10 | Consumers: 5
|
|
139
|
+
Setting up producers and consumers...
|
|
140
|
+
|
|
141
|
+
========== E2E BENCHMARK COMPLETE ==========
|
|
142
|
+
Production Phase:
|
|
143
|
+
Total produced: 100000
|
|
144
|
+
Production time: 3.35s
|
|
145
|
+
Production throughput: 29824 msg/s
|
|
146
|
+
|
|
147
|
+
Consumption Phase:
|
|
148
|
+
Total consumed: 100000
|
|
149
|
+
Consumption time: 6.37s
|
|
150
|
+
Consumption throughput: 15689 msg/s
|
|
151
|
+
|
|
152
|
+
End-to-End:
|
|
153
|
+
Total time: 6.37s
|
|
154
|
+
Overall throughput: 15689 msg/s
|
|
155
|
+
System backlog: 0 messages
|
|
156
|
+
Status: All messages processed successfully ✓
|
|
157
|
+
============================================
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 🏗️ Architecture
|
|
161
|
+
|
|
162
|
+
### Design Principles
|
|
163
|
+
|
|
164
|
+
1. **Worker-Based Architecture**: Each producer/consumer runs in its own worker thread
|
|
165
|
+
2. **Even Distribution**: Messages are evenly distributed across all workers
|
|
166
|
+
3. **Real-time Monitoring**: Progress updates during execution
|
|
167
|
+
4. **Graceful Shutdown**: Clean termination of all resources
|
|
168
|
+
5. **Extensible**: Easy to add new benchmark types
|
|
169
|
+
|
|
170
|
+
## Performance Tuning Tips
|
|
171
|
+
|
|
172
|
+
1. **Worker Count**: Increase worker count to leverage multi-core CPUs
|
|
173
|
+
3. **Redis Configuration**: Ensure Redis has sufficient memory and connection limits
|
|
174
|
+
4. **Network**: Local Redis provides the best performance. Network latency impacts throughput
|
|
175
|
+
|
|
176
|
+
## 📊 Interpreting Results
|
|
177
|
+
|
|
178
|
+
### Key Metrics to Monitor
|
|
179
|
+
|
|
180
|
+
1. **Throughput Plateau**: Point where adding more workers doesn't increase throughput
|
|
181
|
+
2. **CPU Utilization**: Monitor CPU usage during benchmarks
|
|
182
|
+
3. **Memory Usage**: Watch for memory leaks in long-running tests
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
RedisSMQ Benchmarks is released under the [MIT License](https://github.com/weyoss/redis-smq/tree/__BRANCH_NAME__/LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../bin/cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { RedisSMQ } from 'redis-smq';
|
|
2
|
+
import { redisConfig, shutdownRedisServer, startRedisServer, } from '../src/common/redis-server.js';
|
|
3
|
+
import { async, EConsoleLoggerLevel, env, ERedisConfigClient, } from 'redis-smq-common';
|
|
4
|
+
import { ConsumerBenchmark } from '../src/consumer-benchmark.js';
|
|
5
|
+
import { ProducerBenchmark } from '../src/producer-benchmark.js';
|
|
6
|
+
import { runE2EBenchmark } from '../src/e2e-benchmark.js';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
const __dirname = env.getCurrentDir();
|
|
9
|
+
const consumerWorkerPath = path.resolve(__dirname, `../src/threads/consumer-worker-thread.js`);
|
|
10
|
+
const producerWorkerPath = path.resolve(__dirname, `../src/threads/producer-worker-thread.js`);
|
|
11
|
+
const ns = 'benchmarking';
|
|
12
|
+
const name = `queue-${Date.now()}`;
|
|
13
|
+
const totalMessages = Number(process.env.BENCH_MESSAGES || 100000);
|
|
14
|
+
const consumerCount = Math.min(Infinity, Number(process.env.BENCH_CONSUMERS || 0));
|
|
15
|
+
const producerCount = Math.min(Infinity, Number(process.env.BENCH_PRODUCERS || 0));
|
|
16
|
+
const showProgress = process.env.BENCH_SHOW_PROGRESS === '1';
|
|
17
|
+
const isDevelopment = process.env.NODE_ENV === 'development' ||
|
|
18
|
+
process.env.BENCH_ENV === 'development';
|
|
19
|
+
let useRedisConfig = redisConfig;
|
|
20
|
+
if (!isDevelopment) {
|
|
21
|
+
const redisHost = process.env.REDIS_HOST || '127.0.0.1';
|
|
22
|
+
const redisPort = process.env.REDIS_PORT || '6379';
|
|
23
|
+
const redisDB = process.env.REDIS_DB || '0';
|
|
24
|
+
useRedisConfig = {
|
|
25
|
+
client: ERedisConfigClient.IOREDIS,
|
|
26
|
+
options: {
|
|
27
|
+
host: redisHost,
|
|
28
|
+
port: parseInt(redisPort, 10),
|
|
29
|
+
db: parseInt(redisDB, 10),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (!consumerCount && !producerCount) {
|
|
34
|
+
console.log(`No benchmark type provided. Exiting...`);
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
async.series([
|
|
38
|
+
(cb) => {
|
|
39
|
+
if (isDevelopment) {
|
|
40
|
+
startRedisServer()
|
|
41
|
+
.then(() => cb())
|
|
42
|
+
.catch(cb);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
cb();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
(cb) => {
|
|
49
|
+
RedisSMQ.initializeWithConfig({
|
|
50
|
+
redis: useRedisConfig,
|
|
51
|
+
eventBus: { enabled: false },
|
|
52
|
+
logger: {
|
|
53
|
+
enabled: false,
|
|
54
|
+
options: { logLevel: EConsoleLoggerLevel.DEBUG },
|
|
55
|
+
},
|
|
56
|
+
}, cb);
|
|
57
|
+
},
|
|
58
|
+
(cb) => {
|
|
59
|
+
if (!consumerCount || producerCount)
|
|
60
|
+
return cb();
|
|
61
|
+
const config = {
|
|
62
|
+
redisConfig: useRedisConfig,
|
|
63
|
+
queue: { ns, name },
|
|
64
|
+
totalMessages,
|
|
65
|
+
workerCount: consumerCount,
|
|
66
|
+
workerPath: consumerWorkerPath,
|
|
67
|
+
workerLabel: 'Consumer',
|
|
68
|
+
showProgress,
|
|
69
|
+
};
|
|
70
|
+
const benchmark = new ConsumerBenchmark(config);
|
|
71
|
+
benchmark.run(cb);
|
|
72
|
+
},
|
|
73
|
+
(cb) => {
|
|
74
|
+
if (!producerCount || consumerCount)
|
|
75
|
+
return cb();
|
|
76
|
+
const config = {
|
|
77
|
+
redisConfig: useRedisConfig,
|
|
78
|
+
queue: { ns, name },
|
|
79
|
+
totalMessages,
|
|
80
|
+
workerCount: producerCount,
|
|
81
|
+
workerPath: producerWorkerPath,
|
|
82
|
+
workerLabel: 'Producer',
|
|
83
|
+
showProgress,
|
|
84
|
+
};
|
|
85
|
+
const benchmark = new ProducerBenchmark(config);
|
|
86
|
+
benchmark.run(cb);
|
|
87
|
+
},
|
|
88
|
+
(cb) => {
|
|
89
|
+
if (!consumerCount || !producerCount)
|
|
90
|
+
return cb();
|
|
91
|
+
const config = {
|
|
92
|
+
redisConfig,
|
|
93
|
+
queue: { ns, name },
|
|
94
|
+
totalMessages,
|
|
95
|
+
consumerCount,
|
|
96
|
+
producerCount,
|
|
97
|
+
producerWorkerPath,
|
|
98
|
+
consumerWorkerPath,
|
|
99
|
+
showProgress,
|
|
100
|
+
};
|
|
101
|
+
runE2EBenchmark(config, cb);
|
|
102
|
+
},
|
|
103
|
+
(cb) => {
|
|
104
|
+
RedisSMQ.shutdown(cb);
|
|
105
|
+
},
|
|
106
|
+
(cb) => {
|
|
107
|
+
if (isDevelopment) {
|
|
108
|
+
shutdownRedisServer()
|
|
109
|
+
.then(() => cb())
|
|
110
|
+
.catch(() => cb());
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
cb();
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
], (err) => {
|
|
117
|
+
if (err)
|
|
118
|
+
throw err;
|
|
119
|
+
process.exit(0);
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../bin/cli.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,GAAG,EACH,kBAAkB,GAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EA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AAC;QACP,CAAC;IACH,CAAC;CACF,EACD,CAAC,GAAG,EAAE,EAAE;IACN,IAAI,GAAG;QAAE,MAAM,GAAG,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AASA,OAAO,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AASA,OAAO,cAAc,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IQueueParams } from 'redis-smq';
|
|
2
|
+
import { ICallback, IRedisConfig } from 'redis-smq-common';
|
|
3
|
+
import { EWorkerMessageType, IBenchmarkConfig, IBenchmarkResult } from '../types/index.js';
|
|
4
|
+
import { Worker } from 'worker_threads';
|
|
5
|
+
export interface IWorkerMessage {
|
|
6
|
+
type: EWorkerMessageType;
|
|
7
|
+
data: {
|
|
8
|
+
workerId: number;
|
|
9
|
+
processed?: number;
|
|
10
|
+
timeTaken?: number;
|
|
11
|
+
expected?: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export type MessageHandler = (msg: IWorkerMessage) => void;
|
|
15
|
+
export declare abstract class BaseBenchmark {
|
|
16
|
+
protected showProgress: boolean;
|
|
17
|
+
protected redisConfig: IRedisConfig;
|
|
18
|
+
protected queue: IQueueParams;
|
|
19
|
+
protected totalMessages: number;
|
|
20
|
+
protected workerCount: number;
|
|
21
|
+
protected workerPath: string;
|
|
22
|
+
protected workerLabel: string;
|
|
23
|
+
protected workers: Worker[];
|
|
24
|
+
protected completedWorkers: number;
|
|
25
|
+
protected totalProcessed: number;
|
|
26
|
+
protected totalProcessingTime: number;
|
|
27
|
+
protected startTime: number;
|
|
28
|
+
constructor(config: IBenchmarkConfig);
|
|
29
|
+
protected abstract ensureQueue(): Promise<void> | void;
|
|
30
|
+
protected calculateMessageDistribution(): {
|
|
31
|
+
count: number;
|
|
32
|
+
remainder: number;
|
|
33
|
+
};
|
|
34
|
+
protected createMessageHandler(onComplete: (result: IBenchmarkResult) => void): MessageHandler;
|
|
35
|
+
protected createWorkers(onMessage: MessageHandler): Promise<void>;
|
|
36
|
+
protected shutdownWorkers(): Promise<void>;
|
|
37
|
+
abstract run(cb: ICallback<IBenchmarkResult>): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=base-benchmark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-benchmark.d.ts","sourceRoot":"","sources":["../../../../src/common/base-benchmark.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;AAE3D,8BAAsB,aAAa;IACjC,SAAS,CAAC,YAAY,UAAS;IAC/B,SAAS,CAAC,WAAW,EAAE,YAAY,CAAC;IACpC,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC;IAC9B,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,WAAW,EAAE,M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