Skip to content

Commit 6abd40c

Browse files
Merge pull request #33 from redis-performance/updated.docs
Updated docs to match the current features.
2 parents dd66c88 + c670748 commit 6abd40c

File tree

2 files changed

+98
-24
lines changed

2 files changed

+98
-24
lines changed

README.md

Lines changed: 86 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,33 @@ Usage of ./pubsub-sub-bench:
9191
-client-output-buffer-limit-pubsub string
9292
Specify client output buffer limits for clients subscribed to at least one pubsub channel or pattern. If the value specified is different that the one present on the DB, this setting will apply.
9393
-client-update-tick int
94-
client update tick. (default 1)
94+
client update tick in seconds. (default 1)
9595
-clients int
9696
Number of parallel connections. (default 50)
9797
-cpuprofile string
9898
write cpu profile to file
99+
-data-size int
100+
Payload size in bytes. In RTT mode, timestamp (13 bytes) + space + padding to reach this size. (default 128)
99101
-host string
100102
redis host. (default "127.0.0.1")
101103
-json-out-file string
102104
Name of json output file, if not set, will not print to json.
103105
-max-number-channels-per-subscriber int
104106
max number of channels to subscribe to, per connection. (default 1)
105107
-max-reconnect-interval int
106-
max reconnect interval. if 0 disable (s)unsubscribe/(s)ubscribe.
108+
max reconnect interval in milliseconds. if 0 disable (s)unsubscribe/(s)ubscribe.
109+
-measure-rtt-latency
110+
Enable RTT latency measurement. Publisher sends timestamp in message, subscriber measures round-trip time.
107111
-messages int
108-
Number of total messages per subscriber per channel.
112+
Number of total messages per subscriber per channel. Mutually exclusive with --test-time.
109113
-min-number-channels-per-subscriber int
110114
min number of channels to subscribe to, per connection. (default 1)
111115
-min-reconnect-interval int
112-
min reconnect interval. if 0 disable (s)unsubscribe/(s)ubscribe.
116+
min reconnect interval in milliseconds. if 0 disable (s)unsubscribe/(s)ubscribe.
113117
-mode string
114-
Subscribe mode. Either 'subscribe' or 'ssubscribe'. (default "subscribe")
118+
Mode: 'subscribe', 'ssubscribe', 'publish', or 'spublish'. (default "subscribe")
115119
-oss-cluster-api-distribute-subscribers
116-
read cluster slots and distribute subscribers among them.
120+
read cluster slots and distribute subscribers among them (Redis OSS Cluster mode).
117121
-pool_size int
118122
Maximum number of socket connections per node.
119123
-port string
@@ -126,14 +130,18 @@ Usage of ./pubsub-sub-bench:
126130
determines the timeout to pass to redis connection setup. It adjust the connection, read, and write timeouts. (default 30s)
127131
-resp int
128132
redis command response protocol (2 - RESP 2, 3 - RESP 3) (default 2)
133+
-rps int
134+
Max rps for publisher mode. If 0 no limit is applied and the DB is stressed up to maximum.
135+
-rps-burst int
136+
Max rps burst for publisher mode. If 0 the allowed burst will be the amount of clients.
129137
-subscriber-prefix string
130-
prefix for subscribing to channel, used in conjunction with key-minimum and key-maximum. (default "channel-")
138+
prefix for subscribing to channel, used in conjunction with channel-minimum and channel-maximum. (default "channel-")
131139
-subscribers-per-channel int
132140
number of subscribers per channel. (default 1)
133141
-subscribers-placement-per-channel string
134142
(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner. (default "dense")
135143
-test-time int
136-
Number of seconds to run the test, after receiving the first message.
144+
Number of seconds to run the test, after receiving the first message. Mutually exclusive with --messages.
137145
-user string
138146
Used to send ACL style 'AUTH username pass'. Needs -a.
139147
-verbose
@@ -142,17 +150,83 @@ Usage of ./pubsub-sub-bench:
142150
print version and exit.
143151
```
144152

145-
### Example usage: create 10 subscribers that will subscribe to 2000 channels
153+
## Examples
154+
155+
### Example 1: Create 10 subscribers that will subscribe to 2000 channels
146156

147157
Subscriber
148158

159+
```bash
160+
./pubsub-sub-bench --clients 10 --channel-maximum 2000 --channel-minimum 1 \
161+
--min-number-channels-per-subscriber 2000 --max-number-channels-per-subscriber 2000
149162
```
150-
./pubsub-sub-bench --clients 10 --channel-maximum 2000 --channel-minimum 1 -min-number-channels-per-subscriber 2000 -max-number-channels-per-subscriber 2000
163+
164+
Publisher (using memtier_benchmark)
165+
166+
```bash
167+
memtier_benchmark --key-prefix "channel-" --key-maximum 2000 --key-minimum 1 \
168+
--command "PUBLISH __key__ __data__" --test-time 60 --pipeline 10
169+
```
170+
171+
### Example 2: Built-in publisher mode with rate limiting
172+
173+
Publisher (using pubsub-sub-bench)
174+
175+
```bash
176+
./pubsub-sub-bench --mode publish --clients 5 --channel-maximum 100 --channel-minimum 1 \
177+
--min-number-channels-per-subscriber 10 --max-number-channels-per-subscriber 10 \
178+
--rps 10000 --data-size 256 --test-time 60
151179
```
152180

153-
Publisher
181+
Subscriber
154182

183+
```bash
184+
./pubsub-sub-bench --mode subscribe --clients 10 --channel-maximum 100 --channel-minimum 1 \
185+
--subscribers-per-channel 1 --test-time 60
155186
```
156-
memtier_benchmark --key-prefix "channel-" --key-maximum 2000 --key-minimum 1 --command "PUBLISH __key__ __data__" --test-time 60 --pipeline 10
187+
188+
### Example 3: RTT latency measurement with configurable payload size
189+
190+
Publisher with RTT measurement
191+
192+
```bash
193+
./pubsub-sub-bench --mode publish --clients 5 --channel-maximum 50 --channel-minimum 1 \
194+
--measure-rtt-latency --data-size 512 --rps 5000 --test-time 30
157195
```
158196

197+
Subscriber with RTT measurement
198+
199+
```bash
200+
./pubsub-sub-bench --mode subscribe --clients 10 --channel-maximum 50 --channel-minimum 1 \
201+
--measure-rtt-latency --test-time 30
202+
```
203+
204+
The RTT mode will display average round-trip latency in milliseconds. The `--data-size` parameter ensures messages are 512 bytes (timestamp + padding).
205+
206+
### Example 4: Sharded Pub/Sub (SSUBSCRIBE/SPUBLISH)
207+
208+
Publisher using sharded pub/sub
209+
210+
```bash
211+
./pubsub-sub-bench --mode spublish --clients 5 --channel-maximum 100 --channel-minimum 1 \
212+
--data-size 128 --test-time 60
213+
```
214+
215+
Subscriber using sharded pub/sub
216+
217+
```bash
218+
./pubsub-sub-bench --mode ssubscribe --clients 10 --channel-maximum 100 --channel-minimum 1 \
219+
--subscribers-per-channel 2 --test-time 60
220+
```
221+
222+
### Example 5: Redis OSS Cluster with distributed subscribers
223+
224+
```bash
225+
./pubsub-sub-bench --mode subscribe --host cluster-node-1 --port 6379 \
226+
--oss-cluster-api-distribute-subscribers \
227+
--clients 50 --channel-maximum 1000 --channel-minimum 1 \
228+
--subscribers-placement-per-channel sparse --test-time 120
229+
```
230+
231+
This will distribute subscribers across cluster nodes in a round-robin manner.
232+

subscriber.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ func main() {
241241
host := flag.String("host", "127.0.0.1", "redis host.")
242242
port := flag.String("port", "6379", "redis port.")
243243
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file")
244-
rps := flag.Int64("rps", 0, "Max rps. If 0 no limit is applied and the DB is stressed up to maximum.")
245-
rpsburst := flag.Int64("rps-burst", 0, "Max rps burst. If 0 the allowed burst will be the ammount of clients.")
244+
rps := flag.Int64("rps", 0, "Max rps for publisher mode. If 0 no limit is applied and the DB is stressed up to maximum.")
245+
rpsburst := flag.Int64("rps-burst", 0, "Max rps burst for publisher mode. If 0 the allowed burst will be the amount of clients.")
246246
password := flag.String("a", "", "Password for Redis Auth.")
247-
dataSize := flag.Int("data-size", 128, "Payload size in bytes for publisher messages when RTT mode is disabled")
248-
mode := flag.String("mode", "subscribe", "Subscribe mode. Either 'subscribe' or 'ssubscribe'.")
247+
dataSize := flag.Int("data-size", 128, "Payload size in bytes. In RTT mode, timestamp (13 bytes) + space + padding to reach this size.")
248+
mode := flag.String("mode", "subscribe", "Mode: 'subscribe', 'ssubscribe', 'publish', or 'spublish'.")
249249
username := flag.String("user", "", "Used to send ACL style 'AUTH username pass'. Needs -a.")
250250
subscribers_placement := flag.String("subscribers-placement-per-channel", "dense", "(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner.")
251251
channel_minimum := flag.Int("channel-minimum", 1, "channel ID minimum value ( each channel has a dedicated thread ).")
@@ -254,19 +254,19 @@ func main() {
254254
clients := flag.Int("clients", 50, "Number of parallel connections.")
255255
min_channels_per_subscriber := flag.Int("min-number-channels-per-subscriber", 1, "min number of channels to subscribe to, per connection.")
256256
max_channels_per_subscriber := flag.Int("max-number-channels-per-subscriber", 1, "max number of channels to subscribe to, per connection.")
257-
min_reconnect_interval := flag.Int("min-reconnect-interval", 0, "min reconnect interval. if 0 disable (s)unsubscribe/(s)ubscribe.")
258-
max_reconnect_interval := flag.Int("max-reconnect-interval", 0, "max reconnect interval. if 0 disable (s)unsubscribe/(s)ubscribe.")
259-
messages_per_channel_subscriber := flag.Int64("messages", 0, "Number of total messages per subscriber per channel.")
257+
min_reconnect_interval := flag.Int("min-reconnect-interval", 0, "min reconnect interval in milliseconds. if 0 disable (s)unsubscribe/(s)ubscribe.")
258+
max_reconnect_interval := flag.Int("max-reconnect-interval", 0, "max reconnect interval in milliseconds. if 0 disable (s)unsubscribe/(s)ubscribe.")
259+
messages_per_channel_subscriber := flag.Int64("messages", 0, "Number of total messages per subscriber per channel. Mutually exclusive with --test-time.")
260260
json_out_file := flag.String("json-out-file", "", "Name of json output file, if not set, will not print to json.")
261-
client_update_tick := flag.Int("client-update-tick", 1, "client update tick.")
262-
test_time := flag.Int("test-time", 0, "Number of seconds to run the test, after receiving the first message.")
261+
client_update_tick := flag.Int("client-update-tick", 1, "client update tick in seconds.")
262+
test_time := flag.Int("test-time", 0, "Number of seconds to run the test, after receiving the first message. Mutually exclusive with --messages.")
263263
randSeed := flag.Int64("rand-seed", 12345, "Random deterministic seed.")
264-
subscribe_prefix := flag.String("subscriber-prefix", "channel-", "prefix for subscribing to channel, used in conjunction with key-minimum and key-maximum.")
264+
subscribe_prefix := flag.String("subscriber-prefix", "channel-", "prefix for subscribing to channel, used in conjunction with channel-minimum and channel-maximum.")
265265
client_output_buffer_limit_pubsub := flag.String("client-output-buffer-limit-pubsub", "", "Specify client output buffer limits for clients subscribed to at least one pubsub channel or pattern. If the value specified is different that the one present on the DB, this setting will apply.")
266-
distributeSubscribers := flag.Bool("oss-cluster-api-distribute-subscribers", false, "read cluster slots and distribute subscribers among them.")
266+
distributeSubscribers := flag.Bool("oss-cluster-api-distribute-subscribers", false, "read cluster slots and distribute subscribers among them (Redis OSS Cluster mode).")
267267
printMessages := flag.Bool("print-messages", false, "print messages.")
268268
verbose := flag.Bool("verbose", false, "verbose print.")
269-
measureRTT := flag.Bool("measure-rtt-latency", false, "Enable RTT latency measurement mode")
269+
measureRTT := flag.Bool("measure-rtt-latency", false, "Enable RTT latency measurement. Publisher sends timestamp in message, subscriber measures round-trip time.")
270270
version := flag.Bool("version", false, "print version and exit.")
271271
timeout := flag.Duration("redis-timeout", time.Second*30, "determines the timeout to pass to redis connection setup. It adjust the connection, read, and write timeouts.")
272272
poolSizePtr := flag.Int(redisPoolSize, redisPoolSizeDefault, "Maximum number of socket connections per node.")

0 commit comments

Comments
 (0)