Client-side load-balancing with Apache HTTP Client
<p>We are building a scalable point-to-point microservice architecture with client-side load-balancing and fail-over. The base idea is to manage service discovery with DNS SRV records, just as HashiCorps' Consul does.</p>

<p>As HTTP client we use Apache http-components.</p>

<p>The algorithm I envision looks something like this:</p>

<ul>
<li>On start-up the client looks up the SRV records for the service it wants to consume.</li>
<li>The client configures an instance of <code>HttpClient</code> to round-robin through the available services.</li>
<li>The client periodically queries the DNS server for updates (governed by the DNS record's TTL) and updates the <code>HttpClient</code> if hosts are added or removed.</li>
<li>Code that invokes the client only uses absolute paths without scheme, host or port.</li>
</ul>

<p>Constraints:</p>

<ul>
<li>Respect priority and weight fields of SRV records.</li>
<li>Implement fail-over with a back-off strategy and temporary host disabling.</li>
</ul>

<p>Is there a pretty way to configure Apache's http-components this way that I haven't found yet? Is there any better library for this kind of requirements?</p>

<p>Thanks a lot for input and ideas.</p>