Skip to content

Commit 8d85b04

Browse files
committed
Polishing
1 parent 68e842b commit 8d85b04

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

docs/advanced-usage.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,19 @@ instance needs to be shut down once it’s not used anymore.
9797

9898
The basic configuration options are listed in the table below:
9999

100-
| Name | Method | Default |
101-
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|------------------------|
102-
| **I/O Thread Pool Size** | `ioThreadPoolSize` | `Number of processors` |
103-
| The number of threads in the I/O thread pools. The number defaults to the number of available processors that the runtime returns (which, as a well-known fact, sometimes does not represent the actual number of processors). Every thread represents an internal event loop where all I/O tasks are run. The number does not reflect the actual number of I/O threads because the client requires different thread pools for Network (NIO) and Unix Domain Socket (EPoll) connections. The minimum I/O threads are `3`. A pool with fewer threads can cause undefined behavior. | | |
104-
| **Computation Thread Pool Size** | `comput ationThreadPoolSize` | `Number of processors` |
105-
| The number of threads in the computation thread pool. The number defaults to the number of available processors that the runtime returns (which, as a well-known fact, sometimes does not represent the actual number of processors). Every thread represents an internal event loop where all computation tasks are run. The minimum computation threads are `3`. A pool with fewer threads can cause undefined behavior. | | |
100+
| Name | Method | Default |
101+
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|-------------|
102+
| **I/O Thread Pool Size** | `ioThreadPoolSize` | `See below` |
103+
| The number of threads in the I/O thread pools. Every thread represents an internal event loop where all I/O tasks are run. The number does not reflect the actual number of I/O threads because the client requires different thread pools for Network (NIO) and Unix Domain Socket (EPoll) connections. The minimum I/O threads are `2`. | | |
104+
| **Computation Thread Pool Size** | `comput ationThreadPoolSize` | `See below` |
105+
| The number of threads in the computation thread pool. Every thread represents an internal event loop where all computation tasks are run. The minimum computation threads are `2`. | | |
106+
107+
#### Default thread pool size
108+
109+
Unless configured otherwise by the settings above, the number of threads (for both computation and I/O) is determined in the following order:
110+
* if there is an environment variable setting for `io.netty.eventLoopThreads` we use it as default setting
111+
* otherwise we take the number of available processors, retrieved by `Runtime.getRuntime().availableProcessors()` _(which, as a well-known fact, sometimes does not represent the actual number of processors)_
112+
* in any case if the chosen number is lower than the minimum, which is `2` threads, then we use the minimum.
106113

107114
### Advanced settings
108115

src/main/java/io/lettuce/core/AbstractRedisClient.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,26 @@
6060
import io.netty.channel.EventLoopGroup;
6161
import io.netty.channel.group.ChannelGroup;
6262
import io.netty.channel.group.DefaultChannelGroup;
63-
import io.netty.channel.nio.NioEventLoopGroup;
6463
import io.netty.util.concurrent.EventExecutorGroup;
6564
import io.netty.util.concurrent.Future;
6665
import io.netty.util.internal.logging.InternalLogger;
6766
import io.netty.util.internal.logging.InternalLoggerFactory;
6867

6968
/**
7069
* Base Redis client. This class holds the netty infrastructure, {@link ClientOptions} and the basic connection procedure. This
71-
* class creates the netty {@link EventLoopGroup}s for NIO ({@link NioEventLoopGroup}) with a default of
72-
* {@code SystemPropertyUtil.getInt("io.netty.eventLoopThreads", Math.max(MIN_IO_THREADS, Runtime.getRuntime().availableProcessors()))}
73-
* threads and EPoll ({@link io.netty.channel.epoll.EpollEventLoopGroup}) with a default of
74-
* {@code Runtime.getRuntime().availableProcessors() * 4} threads. Reuse the instance as much as possible since the
75-
* {@link EventLoopGroup} instances are expensive and can consume a huge part of your resources, if you create multiple
76-
* instances.
70+
* class creates different Netty {@link EventLoopGroup}s depending on the {@link NativeTransports} used.
7771
* <p>
78-
* You can set the number of threads per {@link NioEventLoopGroup} by setting the {@code io.netty.eventLoopThreads} system
79-
* property to a reasonable number of threads.
72+
* You can set the number of threads by using the {@link ClientResources} configuration.
73+
* For more details, check the documentation of the {@link DefaultClientResources} class.
8074
* </p>
8175
*
8276
* @author Mark Paluch
8377
* @author Jongyeol Choi
8478
* @author Poorva Gokhale
79+
* @author Tihomir Mateev
8580
* @since 3.0
8681
* @see ClientResources
82+
* @see DefaultClientResources
8783
*/
8884
public abstract class AbstractRedisClient implements AutoCloseable {
8985

0 commit comments

Comments
 (0)