How should I wrap and reuse the RestClient behind in a web service facade?

I have a JAVA service that wraps ES for specific queries behind an API. This means all requests are inspected by the facade and translated into ES queries via the JAVA API.

Creating a fresh RestClient for each incoming request seems a bit of an overhead to me. On the other hand I am not sure whether it is wise to channel all incoming requests through the same RestClient instance. On the other hand the implementation seems to be quite robust, thread-safe and provides some failover logic.

So what would be the recommended approach for this kind of setup? Channel all requests through a single instance? Create a pool of RestClients (Like an HTTP connection pool) or do something else? Should I do some kind of manual health check? Or is that already performed by the underlying HttpClient?

p.s.: Load on the facade is usually not very heavy and I don't assume more than 50 concurrent requests.

You should use one client only. It's threadsafe.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.