Q:

VertX Proxy Performance

I am trying to implement a proxy using Vertx and Vertx client similar to https://github.com/vert-x/vertx-examples/blob/master/src/raw/java/proxy/ProxyServer.java but with router.
The exceptions are that it connects to multiple servers rather than a single one.
I have two types of services I connect to

Simple echo service
A service that sleeps for 5 seconds before echoing back

If I use a shared HttpClient for the proxy and I connect to a simple echo service I have no big latency issues, it's median is less than a second, but if I connect to a sleeping service the latency goes higher over time and load 
If I hit the service directly, I get the expected latency which is on average 5100ms
Now if I change to create a new HttpClient per request it is able to give a good latency around 5110ms.  However, if I use it to hit the echo version it breaks and the artillery app gives me a EADDRINUSE error (which is weird because that's usually on the listen side)
I'm using HTTP not HTTP/2 since the services are not on SSL so I have not tried the single connection multiplexing
I'm also using a conservative 64MB heap size for the proxy.
Is it more proper to create a new HttpClient and perhaps the reason for the failure is because I am just testing on an inadequate machine for ridiculous loads?

A:

To get around this I had to apply a back-pressure pattern on the client when it tries to get a response
    final HttpClientRequest clientRequest = httpClient
        .request(contextRequest.method(), clientRequestOptions, clientResponse -> {
            contextRequest.response().setChunked(clientResponse.getHeader(HttpHeaders.CONTENT_LENGTH) == null)
                .setStatusCode(clientResponse.statusCode());
            clientResponse.headers().forEach(e -> contextRequest.response().putHeader(e.getKey(), e.getValue()));
            clientResponse.endHandler(v -> {
                contextRequest.response().end();
            });
            // back pressure here
            Pump.pump(clientResponse, contextRequest.response()).start();
        }).exceptionHandler(context::fail)

