'okhttp Dispatcher throws executor rejected

I am using Okhttp Dispatcher in my application to send out HTTP2 request to a simulator which is an Reactor Netty HTTPSever . Actually we are doing a PT with 10 simulators , out of which 9 simulators have a delay of 50 ms , things work fine in this case , but when i introduce the 10th simulator with 10 seconds delay then immediately all of the requests are failing with executor rejected error response. Below is the dispatcher configuration used

Dispatcher dispatcher = new Dispatcher(new ThreadPoolExecutor( 1, 350, 60L, TimeUnit.SECONDS, new SynchronousQueue(), Util.threadFactory(HTTP_THREAD_NAME_DEFAULT, false)));

        dispatcher.setMaxRequestsPerHost(300);
        dispatcher.setMaxRequests(500);

I have tried increasing the ThreadPoolExecutor max threads to 500 , MaxRequestsPerHost to 500 and MaxRequests to 800, but things don't work

NOTE: we are testing with 4k tps and its an springboot application not mobile application



Solution 1:[1]

OkHttp uses the parameters maxRequests and maxRequestsPerHost to determine concurrency. You should keep the default dispatcher and use these tuning parameters instead.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jesse Wilson