提交 157ccc18 编写于 作者: T tuohai666

#1099, worker group and user group share the acceptor.size configuration

上级 b3971b6f
......@@ -42,6 +42,17 @@ public enum ShardingPropertiesConstant {
*/
SQL_SHOW("sql.show", Boolean.FALSE.toString(), boolean.class),
/**
* Worker group or user group thread max size.
*
* <p>
* Worker group accept tcp connection.
* User group accept MySQL command.
* Default: CPU cores * 2.
* </p>
*/
ACCEPTOR_SIZE("acceptor.size", String.valueOf(Runtime.getRuntime().availableProcessors() * 2), int.class),
/**
* Worker thread max size.
*
......
......@@ -75,6 +75,8 @@ public final class RuleRegistry {
private ConnectionMode connectionMode;
private int acceptorSize;
private int executorSize;
private BackendNIOConfiguration backendNIOConfig;
......@@ -108,6 +110,7 @@ public final class RuleRegistry {
connectionMode = ConnectionMode.valueOf(shardingProperties.<String>getValue(ShardingPropertiesConstant.CONNECTION_MODE));
transactionType = TransactionType.valueOf(shardingProperties.<String>getValue(ShardingPropertiesConstant.PROXY_TRANSACTION_MODE));
transactionManager = ProxyTransactionLoader.load(transactionType);
acceptorSize = shardingProperties.getValue(ShardingPropertiesConstant.ACCEPTOR_SIZE);
executorSize = shardingProperties.getValue(ShardingPropertiesConstant.EXECUTOR_SIZE);
// TODO :jiaqi force off use NIO for backend, this feature is not complete yet
boolean useNIO = false;
......
......@@ -101,8 +101,8 @@ public final class ShardingProxy {
}
private void groupsEpoll(final ServerBootstrap bootstrap) {
workerGroup = new EpollEventLoopGroup(RULE_REGISTRY.getExecutorSize());
userGroupContext.setUserGroup(new EpollEventLoopGroup(RULE_REGISTRY.getExecutorSize()));
workerGroup = new EpollEventLoopGroup(RULE_REGISTRY.getAcceptorSize());
userGroupContext.setUserGroup(new EpollEventLoopGroup(RULE_REGISTRY.getAcceptorSize()));
bootstrap.group(bossGroup, workerGroup)
.channel(EpollServerSocketChannel.class)
.option(EpollChannelOption.SO_BACKLOG, 128)
......@@ -114,8 +114,8 @@ public final class ShardingProxy {
}
private void groupsNio(final ServerBootstrap bootstrap) {
workerGroup = new NioEventLoopGroup(RULE_REGISTRY.getExecutorSize());
userGroupContext.setUserGroup(new NioEventLoopGroup(RULE_REGISTRY.getExecutorSize()));
workerGroup = new NioEventLoopGroup(RULE_REGISTRY.getAcceptorSize());
userGroupContext.setUserGroup(new NioEventLoopGroup(RULE_REGISTRY.getAcceptorSize()));
bootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.option(ChannelOption.SO_BACKLOG, 128)
......
......@@ -61,6 +61,7 @@
# # CONNECTION_STRICTLY: Proxy will release connections after get the overall rows from the ResultSet.
# # Meanwhile, the cost of the memory will be increased.
# connection.mode: MEMORY_STRICTLY
# acceptor.size: 16 # The default value is available processors count * 2.
# executor.size: 16 # The default value is available processors count.
# sql.show: false
#
......
......@@ -40,6 +40,7 @@
# # CONNECTION_STRICTLY: Proxy will release connections after get the overall rows from the ResultSet.
# # Meanwhile, the cost of the memory will be increased.
# connection.mode: MEMORY_STRICTLY
# acceptor.size: 16 # The default value is available processors count * 2.
# executor.size: 16 # The default value is available processors count.
# sql.show: false
......
......@@ -45,6 +45,7 @@ shardingRule:
props:
connection.mode: MEMORY_STRICTLY
acceptor.size: 16
executor.size: 16
sql.show: false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册