Add ioThreadCount config depends on grinder total thread count
*/
package org.ngrinder.http;
+import net.grinder.script.Grinder;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.HttpHost;
@@ -59,10 +60,21 @@ public class HTTPRequester extends HttpAsyncRequester {
private HttpVersionPolicy versionPolicy = HttpVersionPolicy.NEGOTIATE;
public HTTPRequester(SimpleConnPool<HttpHost, IOSession> connPool) {
- super(IOReactorConfig.DEFAULT, ioEventHandlerFactory(), null, null, null, connPool);
+ super(ioReactorConfig(), ioEventHandlerFactory(), null, null, null, connPool);
this.connPool = connPool;
}
+ private static IOReactorConfig ioReactorConfig() {
+ int totalProcessCount = Grinder.grinder.getProperties().getInt("grinder.processes", 1);
+ int totalThreadCount = Grinder.grinder.getProperties().getInt("grinder.threads", 1);
+
+ int ioThreadCount = totalProcessCount * totalThreadCount / 100 + 1;
+
+ return IOReactorConfig.custom()
+ .setIoThreadCount(ioThreadCount)
+ .build();
+ }
+
private static IOEventHandlerFactory ioEventHandlerFactory() {
final RequestHandlerRegistry<Supplier<AsyncPushConsumer>> registry = new RequestHandlerRegistry<>();
final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
