'netty'에 해당되는 글 2건

  1. 2020.03.20 [Reactor Netty] WebClient connection pool?
  2. 2013.08.13 [Elasticsearch] NettyTransport Setting...

[Reactor Netty] WebClient connection pool?

ITWeb/개발일반 2020. 3. 20. 19:12

RestTemplate 을 사용 할 까 하다, WebClient 로 변경 했습니다.

더불어 늘 Connection Pool 에 대한 고민을 하는데요.

 

https://projectreactor.io/docs/netty/snapshot/reference/index.html#_connection_pool

By default, the TCP client uses a “fixed” connection pool with 500 
as the maximum number of the channels, 
45s as the pending acquire timeout and 1000 as the maximum number of 
the registered requests for acquire to keep in the pending queue. 
This means that the implementation creates a new channel 
if someone tries to acquire a channel but none is in the pool. 
When the maximum number of the channels in the pool is reached, 
new tries to acquire a channel are delayed 
until a channel is returned to the pool again. 
The implementation uses FIFO order for channels in the pool. 
By default, there is no idle time specified for the channels in the pool.

Channel 500개

Queue 1000개

 

그냥 신경쓰지 말고 쓰라고 합니다.

:

[Elasticsearch] NettyTransport Setting...

Elastic/Elasticsearch 2013. 8. 13. 19:01


NettyTransport.java


this.workerCount = componentSettings.getAsInt("worker_count", Runtime.getRuntime().availableProcessors() * 2);

        this.bossCount = componentSettings.getAsInt("boss_count", 1);

        this.blockingServer = settings.getAsBoolean("transport.tcp.blocking_server", settings.getAsBoolean(TCP_BLOCKING_SERVER, settings.getAsBoolean(TCP_BLOCKING, false)));

        this.blockingClient = settings.getAsBoolean("transport.tcp.blocking_client", settings.getAsBoolean(TCP_BLOCKING_CLIENT, settings.getAsBoolean(TCP_BLOCKING, false)));

        this.port = componentSettings.get("port", settings.get("transport.tcp.port", "9300-9400"));

        this.bindHost = componentSettings.get("bind_host", settings.get("transport.bind_host", settings.get("transport.host")));

        this.publishHost = componentSettings.get("publish_host", settings.get("transport.publish_host", settings.get("transport.host")));

        this.compress = settings.getAsBoolean("transport.tcp.compress", false);

        this.connectTimeout = componentSettings.getAsTime("connect_timeout", settings.getAsTime("transport.tcp.connect_timeout", settings.getAsTime(TCP_CONNECT_TIMEOUT, TCP_DEFAULT_CONNECT_TIMEOUT)));

        this.tcpNoDelay = componentSettings.getAsBoolean("tcp_no_delay", settings.getAsBoolean(TCP_NO_DELAY, true));

        this.tcpKeepAlive = componentSettings.getAsBoolean("tcp_keep_alive", settings.getAsBoolean(TCP_KEEP_ALIVE, true));

        this.reuseAddress = componentSettings.getAsBoolean("reuse_address", settings.getAsBoolean(TCP_REUSE_ADDRESS, NetworkUtils.defaultReuseAddress()));

        this.tcpSendBufferSize = componentSettings.getAsBytesSize("tcp_send_buffer_size", settings.getAsBytesSize(TCP_SEND_BUFFER_SIZE, TCP_DEFAULT_SEND_BUFFER_SIZE));

        this.tcpReceiveBufferSize = componentSettings.getAsBytesSize("tcp_receive_buffer_size", settings.getAsBytesSize(TCP_RECEIVE_BUFFER_SIZE, TCP_DEFAULT_RECEIVE_BUFFER_SIZE));

        this.connectionsPerNodeLow = componentSettings.getAsInt("connections_per_node.low", settings.getAsInt("transport.connections_per_node.low", 2));

        this.connectionsPerNodeMed = componentSettings.getAsInt("connections_per_node.med", settings.getAsInt("transport.connections_per_node.med", 6));

        this.connectionsPerNodeHigh = componentSettings.getAsInt("connections_per_node.high", settings.getAsInt("transport.connections_per_node.high", 1));


        this.maxCumulationBufferCapacity = componentSettings.getAsBytesSize("max_cumulation_buffer_capacity", null);

        this.maxCompositeBufferComponents = componentSettings.getAsInt("max_composite_buffer_components", -1);


이 클래스 안에 보면 low, med, high 설정이 있내요. (이건 client 설정임)

private void connectToChannels(NodeChannels nodeChannels, DiscoveryNode node) {

        ChannelFuture[] connectLow = new ChannelFuture[nodeChannels.low.length];

        ChannelFuture[] connectMed = new ChannelFuture[nodeChannels.med.length];

        ChannelFuture[] connectHigh = new ChannelFuture[nodeChannels.high.length];

        InetSocketAddress address = ((InetSocketTransportAddress) node.address()).address();

.....

}


: