Skip to content

Commit 84112ac

Browse files
DOC-4340 added conn/mux page diagrams and links
1 parent 26d7654 commit 84112ac

File tree

9 files changed

+372
-19
lines changed

9 files changed

+372
-19
lines changed

content/develop/connect/clients/dotnet.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,6 @@ IJsonCommands json = db.JSON();
8484
ITimeSeriesCommands ts = db.TS();
8585
```
8686

87-
### Multiplexing
88-
89-
Although example code typically works with a single connection,
90-
real-world code often uses multiple connections at the same time.
91-
Opening and closing connections repeatedly is inefficient, so it is best
92-
to manage open connections carefully to avoid this.
93-
94-
Several other
95-
Redis client libraries use *connection pools* to reuse a set of open
96-
connections efficiently. NRedisStack uses a different approach called
97-
*multiplexing*, which sends all client commands and responses over a
98-
single connection. NRedisStack manages multiplexing for you automatically.
99-
This gives high performance without requiring any extra coding.
100-
10187
## Connect to a Redis cluster
10288

10389
To connect to a Redis cluster, you just need to specify one or all cluster endpoints in the client configuration:
@@ -183,6 +169,23 @@ conn.StringSet("foo", "bar");
183169
Console.WriteLine(conn.StringGet("foo"));
184170
```
185171

172+
## Multiplexing
173+
174+
Although example code typically works with a single connection,
175+
real-world code often uses multiple connections at the same time.
176+
Opening and closing connections repeatedly is inefficient, so it is best
177+
to manage open connections carefully to avoid this.
178+
179+
Several other
180+
Redis client libraries use *connection pools* to reuse a set of open
181+
connections efficiently. NRedisStack uses a different approach called
182+
*multiplexing*, which sends all client commands and responses over a
183+
single connection. NRedisStack manages multiplexing for you automatically.
184+
This gives high performance without requiring any extra coding.
185+
See
186+
[Connection pools and multiplexing]({{< relref "/develop/connect/clients/pools-and-muxing" >}})
187+
for more information.
188+
186189
## Example: Indexing and querying JSON documents
187190

188191
This example shows how to convert Redis search results to JSON format using `NRedisStack`.

content/develop/connect/clients/java/jedis.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ efficiently. When you open a connection from a pool, the pool allocates you
312312
one of its open connections. When you subsequently close the same connection,
313313
it is not actually closed but simply returned to the pool for reuse.
314314
This avoids the overhead of repeated connecting and disconnecting.
315+
See
316+
[Connection pools and multiplexing]({{< relref "/develop/connect/clients/pools-and-muxing" >}})
317+
for more information.
315318

316319
Use the following code to connect with a connection pool:
317320

content/develop/connect/clients/java/lettuce.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ try (RedisClient client = RedisClient.create(redisURI)) {
234234

235235
A typical approach with Lettuce is to create a single `RedisClient` instance and reuse it to establish connections to your Redis server(s).
236236
These connections are multiplexed; that is, multiple commands can be run concurrently over a single or a small set of connections, making explicit pooling less practical.
237+
See
238+
[Connection pools and multiplexing]({{< relref "/develop/connect/clients/pools-and-muxing" >}})
239+
for more information.
237240

238241
Lettuce provides pool config to be used with Lettuce asynchronous connection methods.
239242

content/develop/connect/clients/pools-and-muxing.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,24 @@ supports both approaches.
3838
## Connection pooling
3939

4040
When you initialize a connection pool, the client opens a small number
41-
of connections and adds them to the pool. Each time you "open" a connection
41+
of connections and adds them to the pool.
42+
43+
{{< image filename="/images/dev/connect/pool-and-mux/ConnPoolInit.drawio.svg" >}}
44+
45+
Each time you "open" a connection
4246
from the pool, the client actually justs returns one of these existing
43-
connections and notes the fact that it is in use. When you later "close"
47+
connections and notes the fact that it is in use.
48+
49+
{{< image filename="/images/dev/connect/pool-and-mux/ConnPoolInUse.drawio.svg" >}}
50+
51+
When you later "close"
4452
the connection, the client puts it back into the pool of available
4553
connections without actually closing it.
4654

55+
{{< image filename="/images/dev/connect/pool-and-mux/ConnPoolDiscon.drawio.svg" >}}
56+
4757
If all connections in the pool are in use but the app needs more then
48-
the client can simply add new ones as necessary. In this way, the client
58+
the client can simply open new ones as necessary. In this way, the client
4959
eventually finds the right number of connections to satisfy your
5060
app's demands.
5161

@@ -56,8 +66,10 @@ single connection open and uses it for all traffic between the
5666
client and the server. The "connections" returned to your code are
5767
simply to identify where to send the response data from your commands.
5868

59-
When the multiplexer receives several commands in quick succession, it
60-
can often combine them into a
69+
{{< image filename="/images/dev/connect/pool-and-mux/ConnMux.drawio.svg" >}}
70+
71+
Note that it is not a problem if the multiplexer receives several commands close
72+
together in time. When this happens, the multiplexer can often combine the commands into a
6173
[pipeline]({{< relref "/develop/use/pipelining" >}}), which
6274
improves efficiency even more.
6375

content/develop/connect/clients/python/redis-py.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ efficiently. When you open a connection from a pool, the pool allocates you
241241
one of its open connections. When you subsequently close the same connection,
242242
it is not actually closed but simply returned to the pool for reuse.
243243
This avoids the overhead of repeated connecting and disconnecting.
244+
See
245+
[Connection pools and multiplexing]({{< relref "/develop/connect/clients/pools-and-muxing" >}})
246+
for more information.
244247

245248
Use the following code to connect with a connection pool:
246249

0 commit comments

Comments
 (0)