Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Your teams call each other with a mix of the JAX-RS client, MicroProfile Rest Client, Spring RestClient and raw HttpClient. What would you standardise for service-to-service HTTP calls, and what would you leave to teams?

I would standardise the behaviour of service-to-service calls rather than force one library: timeouts, retry rules for idempotent calls, circuit breaking, tracing headers, token propagation, pool settings and metric names. Each framework gets one supported default with shared configuration, such as MicroProfile Rest Client for Jakarta services and Spring RestClient or HTTP interfaces for Spring services, clients are generated from OpenAPI where contracts are stable, and teams may choose another library for edge cases if it passes the same behaviour checklist and tests.

Why this question is asked

When every team calls other services in its own way, incidents become hard to compare and fixes do not travel. One team's client has no timeout, another retries POST requests, a third drops the trace header, and the outage report reads differently each time. Interviewers ask this design question to see whether we can separate what must be the same everywhere from what can safely differ. In this answer, we will look at why one library is the wrong target, list the behaviours worth standardising, see how a supported default per framework delivers them, where generated clients help, and how teams can still choose something else.

1Why Not Mandate One Library?

The tempting answer is to pick one client and ban the rest. It fails for a practical reason: the four clients in the question live in different frameworks. The JAX-RS client and MicroProfile Rest Client fit Jakarta EE and Quarkus services, Spring RestClient and HTTP interfaces fit Spring, and the JDK HttpClient is what a small library with no framework uses. Forcing a Spring service to use a JAX-RS client means fighting its configuration and its observability integration for no gain.

What actually causes incidents is not the library but its behaviour: a missing timeout, a retry on a non-idempotent call, a pool of 2 connections, a lost trace id. So the standard should describe behaviour, and each library is acceptable if it can be configured to behave that way.

2The Behaviour Every Call Must Have

This is the checklist that I would publish and test. Every value has a default, and teams may change a value but not leave it unset.

Standard behaviour for service-to-service HTTP
ConcernDefaultWhy it is standard
Connect timeout1 to 2 sa dead host must fail fast
Read timeoutset per call, below the caller's own timeouta slow host must not hold threads forever
Retriesidempotent only, max 2, backoff with jitter, one layeravoid duplicate writes and retry storms
Circuit breakeropen after a failure rate over a windowstop calling a dependency that is down
TracingW3C traceparent propagatedone trace across all services
Authtoken propagation or service token, per call typeno service invents its own scheme
Poolexplicit max total and per route, visibleexhaustion must be seen before outages
Metricshttp.client.requests with fixed tagsone dashboard and alert for all teams
Behaviour is fixed; the library that delivers it can vary.

Two points deserve explanation. Retries are limited to idempotent calls, the ones that can safely run twice, such as GET and PUT, because retrying a POST that created an order can create two orders unless the API supports an idempotency key. And metric names are standardised, for example http.client.requests with tags for target service, method, status and outcome, so a single dashboard and a single alert work for every team regardless of library.

3A Supported Default per Framework

Standards that teams must implement by hand drift within months. So the platform team ships a supported default for each framework, packaged as a small configuration module: a Spring Boot starter that configures RestClient.Builder with the timeouts, the Micrometer observation, the tracing propagation and the token interceptor, and a Jakarta or Quarkus extension that does the same for MicroProfile Rest Client through its configuration properties and providers.

The point is that the easy path and the correct path are the same path. A Spring team writing a new client declares an HTTP interface and gets the standard behaviour without reading the standard.

Java
// Spring service: the starter provides a pre-configured RestClient.Builder
@HttpExchange("/prices")
interface PricingApi {
@GetExchange("/{id}") Price price(@PathVariable long id);
}
@Bean
PricingApi pricingApi(RestClient.Builder standard) { // timeouts, tracing, auth, metrics already set
RestClient rc = standard.baseUrl("http://pricing").build();
return HttpServiceProxyFactory.builderFor(RestClientAdapter.create(rc)).build()
.createClient(PricingApi.class);
}
// Jakarta service: MicroProfile Rest Client, configured by the shared extension
@RegisterRestClient(configKey = "pricing")
@Path("/prices")
interface PricingClient {
@GET @Path("/{id}") Price price(@PathParam("id") long id);
}
// pricing/mp-rest/connectTimeout=2000, pricing/mp-rest/readTimeout=3000 (set by the shared defaults)

Notice that both declare the same interface shape. That makes the next step, generating these interfaces from a contract, natural. Spring Boot 4 and Spring Framework 7 add more built-in support for registering HTTP interface clients in groups (check your version), which makes the shared starter even thinner.

4Generated Clients Where Contracts Are Stable

Hand-written clients drift from the server: a renamed field, a new enum value, an optional field treated as required. Where a service publishes a stable OpenAPI contract, generating the client interface and DTOs from it removes that whole class of bugs, and the generator can target either Spring HTTP interfaces or MicroProfile Rest Client.

But there is a catch: generation only pays off when the contract is owned and versioned. For a young API that changes daily, generated code churns and teams start editing it by hand, which is worse than writing it by hand in the first place. So I would require generation for APIs consumed by three or more teams and leave it optional for the rest.

5What Teams Keep and How We Check It

Teams keep the library choice for edge cases: streaming large files with the JDK HttpClient, a reactive WebClient in a reactive service, or a vendor SDK for a third-party API. The rule is that the choice is theirs if the behaviour checklist is met and proven, not promised.

The proof is a shared contract test kit. It starts a fake server (WireMock, for example) that responds slowly, fails, or resets connections, and checks that the client times out within the configured read timeout, does not retry a POST, retries a GET at most twice with backoff, propagates the traceparent header and emits the standard metric. A team adds the kit to its build, and a red test is a clear, discussable fact, while a review comment is an opinion. Finally, pool sizes and timeouts must appear in a dashboard per service, so that a value someone set to 30 minutes is visible to everyone.

Step throughAccepting a client library
  1. Uses the framework's supported default?
    YesAccepted: shared config appliesNoCheck the behaviour kit
  2. Passes the behaviour test kit?timeouts, retries, tracing, metrics
    YesAccepted as an exception with an ownerNoFix the configuration or use the default
  3. Pool and timeout values on the dashboardreviewed quarterly

3 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Should we put retries and timeouts in a service mesh instead?

A mesh can enforce connection-level behaviour such as mTLS, outlier detection and connect timeouts consistently, which is valuable. But only the application knows which calls are idempotent and what the right read timeout is for its use case, so I keep request-level timeouts and retry decisions in the client and make sure that the mesh and the client do not both retry the same call.

How do you roll this out to existing services?

I start with measurement: a scan of each service's client configuration and the metric names it emits, ranked by traffic. New code must use the defaults immediately. Existing clients are fixed in order of risk, starting with clients that have no timeout, since those cause the worst incidents, and the behaviour kit is added to each build as the team touches it.

What if a team needs a longer timeout?

They set it explicitly in configuration, where it is visible on the dashboard and in review. The standard is that every value is chosen and visible, not that every value is the same. A report export may need 60 seconds; a price lookup should not.

7Conclusion

In this answer, we saw that the thing to standardise is behaviour, not a library: timeouts, retry rules for idempotent calls, circuit breaking, tracing, token propagation, pool settings and metric names. Each framework gets a supported default packaged as shared configuration, OpenAPI-generated clients remove drift where contracts are stable, pool and timeout values are visible on dashboards, and teams may pick a different library for edge cases as long as it passes the same behaviour tests.

What to say in the interviewAbout 80 seconds aloud

Open with

I would standardise behaviour, not one library, because the incidents come from behaviour: a missing timeout, a retried POST, a lost trace header, a tiny pool. So I would publish a short checklist: connect and read timeouts always set, retries only for idempotent calls with backoff and at one layer, a circuit breaker per dependency, W3C trace propagation, one documented way to pass identity, explicit pool limits, and one metric name with fixed tags.

Then, if they want more

Then I would make that the easy path by shipping one supported default per framework, for example a Spring Boot starter that configures RestClient and HTTP interfaces, and a MicroProfile Rest Client configuration for Jakarta and Quarkus services, so a team gets the standard just by using the default.

Where a contract is stable and used by several teams, I would generate the client from OpenAPI to stop mapping drift. Pool sizes and timeouts must show up on a dashboard per service.

What I leave to teams is the library for edge cases, like streaming or reactive code, but only if their client passes a shared test kit that checks timeouts, retries, tracing and metrics against a misbehaving fake server.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 4, Spring Framework 7
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Jakarta EE specifications
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your teams call each other with a mix of the JAX-RS client, MicroProfile Rest Client...": https://scrivio-interview-library.netlify.app/java/jax-rs/3f334bf2a3/