This commit is contained in:
@@ -34,9 +34,9 @@
|
|||||||
<!--
|
<!--
|
||||||
【节点全局唯一】
|
【节点全局唯一】
|
||||||
transport节点只能有一个,用于配置所有Transport的池参数,没配置该节点将自动创建一个。
|
transport节点只能有一个,用于配置所有Transport的池参数,没配置该节点将自动创建一个。
|
||||||
threads: 线程总数, 默认: <group>节点数*CPU核数*8
|
threads: 线程总数, 默认: <group>节点数*CPU核数*2
|
||||||
bufferCapacity: ByteBuffer的初始化大小, 默认: 32K;
|
bufferCapacity: ByteBuffer的初始化大小, 默认: 32K;
|
||||||
bufferPoolSize: ByteBuffer池的大小,默认: <group>节点数*CPU核数*8
|
bufferPoolSize: ByteBuffer池的大小,默认: 线程总数*4
|
||||||
readTimeoutSecond: TCP读取超时秒数, 默认为6秒, 为0表示无超时限制
|
readTimeoutSecond: TCP读取超时秒数, 默认为6秒, 为0表示无超时限制
|
||||||
writeTimeoutSecond: TCP写入超时秒数, 默认为6秒, 为0表示无超时限制
|
writeTimeoutSecond: TCP写入超时秒数, 默认为6秒, 为0表示无超时限制
|
||||||
strategy: 远程请求的负载均衡策略, 必须是org.redkale.net.TransportStrategy的实现类
|
strategy: 远程请求的负载均衡策略, 必须是org.redkale.net.TransportStrategy的实现类
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
maxconns:最大连接数, 小于1表示无限制, 默认: 0
|
maxconns:最大连接数, 小于1表示无限制, 默认: 0
|
||||||
maxbody: request.body最大值, 默认: 64K
|
maxbody: request.body最大值, 默认: 64K
|
||||||
bufferCapacity: ByteBuffer的初始化大小, 默认: 32K; (HTTP 2.0、WebSocket,必须要16k以上)
|
bufferCapacity: ByteBuffer的初始化大小, 默认: 32K; (HTTP 2.0、WebSocket,必须要16k以上)
|
||||||
bufferPoolSize: ByteBuffer池的大小,默认: 线程总数*8
|
bufferPoolSize: ByteBuffer池的大小,默认: 线程总数*4
|
||||||
responsePoolSize: Response池的大小,默认: 线程总数*2
|
responsePoolSize: Response池的大小,默认: 线程总数*2
|
||||||
readTimeoutSecond: 读操作超时秒数, 默认0, 表示永久不超时
|
readTimeoutSecond: 读操作超时秒数, 默认0, 表示永久不超时
|
||||||
writeTimeoutSecond: 写操作超时秒数, 默认0, 表示永久不超时
|
writeTimeoutSecond: 写操作超时秒数, 默认0, 表示永久不超时
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ public final class Application {
|
|||||||
final AnyValue resources = config.getAnyValue("resources");
|
final AnyValue resources = config.getAnyValue("resources");
|
||||||
TransportStrategy strategy = null;
|
TransportStrategy strategy = null;
|
||||||
int bufferCapacity = 32 * 1024;
|
int bufferCapacity = 32 * 1024;
|
||||||
int bufferPoolSize = Runtime.getRuntime().availableProcessors() * 16;
|
int bufferPoolSize = Runtime.getRuntime().availableProcessors() * 8;
|
||||||
int readTimeoutSecond = TransportFactory.DEFAULT_READTIMEOUTSECOND;
|
int readTimeoutSecond = TransportFactory.DEFAULT_READTIMEOUTSECOND;
|
||||||
int writeTimeoutSecond = TransportFactory.DEFAULT_WRITETIMEOUTSECOND;
|
int writeTimeoutSecond = TransportFactory.DEFAULT_WRITETIMEOUTSECOND;
|
||||||
AtomicLong createBufferCounter = new AtomicLong();
|
AtomicLong createBufferCounter = new AtomicLong();
|
||||||
@@ -259,10 +259,10 @@ public final class Application {
|
|||||||
if (transportConf != null) {
|
if (transportConf != null) {
|
||||||
//--------------transportBufferPool-----------
|
//--------------transportBufferPool-----------
|
||||||
bufferCapacity = Math.max(parseLenth(transportConf.getValue("bufferCapacity"), bufferCapacity), 8 * 1024);
|
bufferCapacity = Math.max(parseLenth(transportConf.getValue("bufferCapacity"), bufferCapacity), 8 * 1024);
|
||||||
bufferPoolSize = parseLenth(transportConf.getValue("bufferPoolSize"), groupsize * Runtime.getRuntime().availableProcessors() * 8);
|
|
||||||
readTimeoutSecond = transportConf.getIntValue("readTimeoutSecond", readTimeoutSecond);
|
readTimeoutSecond = transportConf.getIntValue("readTimeoutSecond", readTimeoutSecond);
|
||||||
writeTimeoutSecond = transportConf.getIntValue("writeTimeoutSecond", writeTimeoutSecond);
|
writeTimeoutSecond = transportConf.getIntValue("writeTimeoutSecond", writeTimeoutSecond);
|
||||||
final int threads = parseLenth(transportConf.getValue("threads"), groupsize * Runtime.getRuntime().availableProcessors() * 8);
|
final int threads = parseLenth(transportConf.getValue("threads"), groupsize * Runtime.getRuntime().availableProcessors() * 2);
|
||||||
|
bufferPoolSize = parseLenth(transportConf.getValue("bufferPoolSize"), threads * 4);
|
||||||
final int capacity = bufferCapacity;
|
final int capacity = bufferCapacity;
|
||||||
transportPool = new ObjectPool<>(createBufferCounter, cycleBufferCounter, bufferPoolSize,
|
transportPool = new ObjectPool<>(createBufferCounter, cycleBufferCounter, bufferPoolSize,
|
||||||
(Object... params) -> ByteBuffer.allocateDirect(capacity), null, (e) -> {
|
(Object... params) -> ByteBuffer.allocateDirect(capacity), null, (e) -> {
|
||||||
@@ -287,7 +287,7 @@ public final class Application {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
logger.log(Level.INFO, Transport.class.getSimpleName() + " configure bufferCapacity = " + bufferCapacity/1024 + "K; bufferPoolSize = " + bufferPoolSize + "; threads = " + threads + ";");
|
logger.log(Level.INFO, Transport.class.getSimpleName() + " configure bufferCapacity = " + bufferCapacity / 1024 + "K; bufferPoolSize = " + bufferPoolSize + "; threads = " + threads + ";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (transportGroup == null) {
|
if (transportGroup == null) {
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
|
|||||||
int bufCapacity = parseLenth(config.getValue("bufferCapacity"), 32 * 1024);
|
int bufCapacity = parseLenth(config.getValue("bufferCapacity"), 32 * 1024);
|
||||||
this.bufferCapacity = bufCapacity < 8 * 1024 ? 8 * 1024 : bufCapacity;
|
this.bufferCapacity = bufCapacity < 8 * 1024 ? 8 * 1024 : bufCapacity;
|
||||||
this.threads = config.getIntValue("threads", Runtime.getRuntime().availableProcessors() * 8);
|
this.threads = config.getIntValue("threads", Runtime.getRuntime().availableProcessors() * 8);
|
||||||
this.bufferPoolSize = config.getIntValue("bufferPoolSize", this.threads * 8);
|
this.bufferPoolSize = config.getIntValue("bufferPoolSize", this.threads * 4);
|
||||||
this.responsePoolSize = config.getIntValue("responsePoolSize", this.threads * 2);
|
this.responsePoolSize = config.getIntValue("responsePoolSize", this.threads * 2);
|
||||||
this.name = config.getValue("name", "Server-" + protocol + "-" + this.address.getPort());
|
this.name = config.getValue("name", "Server-" + protocol + "-" + this.address.getPort());
|
||||||
if (!this.name.matches("^[a-zA-Z][\\w_-]{1,64}$")) throw new RuntimeException("server.name (" + this.name + ") is illegal");
|
if (!this.name.matches("^[a-zA-Z][\\w_-]{1,64}$")) throw new RuntimeException("server.name (" + this.name + ") is illegal");
|
||||||
|
|||||||
Reference in New Issue
Block a user