Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

Design a shared Spring Boot starter that gives 200 services a standard request filter chain: authentication, tenant resolution, rate limiting and request logging. How do you handle order, extension and rollout?

The starter defines the standard filters, authentication, tenant resolution, rate limiting and request logging, and their order, using published order constants with gaps between them. It provides named extension points at those gaps so teams add their own filters without reordering the standard ones, makes each filter configurable through properties with safe defaults, and tests the full chain inside the starter, including failures such as a missing tenant or a rejected token. New versions roll out through canaries with metrics per filter, under a published compatibility policy for changes to order or behaviour.

Why this question is asked

When 200 services each write their own request filters, small differences become security and operational problems: one service resolves the tenant before authenticating, so an attacker can pick a tenant; another logs request bodies with personal data; a third has no rate limit at all. A shared Spring Boot starter can give every service the same tested chain, but it also becomes a single point of change for 200 teams, so its design must make extension safe and upgrades boring. Interviewers ask this to see whether we can design a platform component with clear contracts, not just a set of filters. In this answer, we will set the order of the standard filters, design the extension points, make the filters configurable, test the chain, and plan rollout and compatibility.

1Ordering the Standard Filters

Each filter depends on the ones before it. Request logging, or at least the part that assigns a request id and starts a timer, comes first so that every request is logged, even ones rejected later. Authentication comes next, so that we know who the caller is. Tenant resolution follows, because the tenant must be checked against the authenticated identity: a token for tenant acme must not be allowed to act as tenant globex just by sending a header. Rate limiting comes after tenant resolution, so limits apply per tenant and per client rather than per IP only, and before the application, so rejected requests cost little.

We express the order as public constants with gaps of 100, so there is room between them. Authentication itself is best done through Spring Security, so the starter contributes a SecurityFilterChain configuration and places the tenant and rate limit filters relative to Spring Security's filters; for simplicity we describe them as one ordered list here.

Java
public final class StandardFilterOrder {
public static final int REQUEST_ID_AND_LOGGING = 100;
public static final int AUTHENTICATION = 200;
public static final int AFTER_AUTHENTICATION = 250; // extension point
public static final int TENANT_RESOLUTION = 300;
public static final int AFTER_TENANT = 350; // extension point
public static final int RATE_LIMITING = 400;
public static final int BEFORE_APPLICATION = 450; // extension point
private StandardFilterOrder() {}
}
Step throughThe standard chain with extension points
  1. Request id and logging (100)Every request, even rejected ones
  2. Authentication (200)Rejects bad tokens with 401
  3. Extension: after authentication (250)Team filters that need the caller
  4. Tenant resolution (300)Tenant checked against the token; 400 or 403 if wrong
  5. Extension: after tenant (350)Team filters that need the tenant
  6. Rate limiting (400)Per tenant and client; 429 when exceeded
  7. Extension: before application (450)Last team filters
  8. ApplicationControllers

8 layers, from the top down. Step through them one at a time.

2Extension Points Instead of Free Ordering

Teams will need their own filters, such as a feature flag context or a legacy header translation. If they could use any order value, someone would put a filter before authentication and read an unauthenticated header as trusted. So the starter defines named extension points and a small interface for team filters, and it places each one at its point. Team filters cannot run before authentication, and they cannot replace standard filters.

Java
public interface ExtensionFilter {
ExtensionPoint point(); // AFTER_AUTHENTICATION, AFTER_TENANT, BEFORE_APPLICATION
void filter(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
throws IOException, ServletException;
}
@Component
class FeatureFlagContextFilter implements ExtensionFilter {
public ExtensionPoint point() { return ExtensionPoint.AFTER_TENANT; }
public void filter(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
throws IOException, ServletException {
FlagContext.set(TenantContext.current()); // the tenant is guaranteed to be resolved here
try { chain.doFilter(req, res); } finally { FlagContext.clear(); }
}
}

The starter collects all ExtensionFilter beans and wraps them in its own chain at each point, ordered among themselves by @Order. Because they are not plain Filter beans, Spring Boot does not register them with the container, which avoids the classic double registration. At startup the starter logs the full chain, standard and extension filters with their positions, which is the first thing anyone debugging a request should read.

3Configuration With Safe Defaults

Each standard filter is controlled by properties under one prefix, bound to a @ConfigurationProperties class with validation, so a typo fails startup instead of being ignored. The defaults are the safe choice: authentication on, tenant required, a conservative rate limit, and logging of method, path, status and duration but never bodies or authorization headers. Turning a protection off is possible but explicit, and the starter logs a warning and exposes a metric so the platform team can see which services run with weakened settings.

YAML
# application.yml in one service
platform:
filters:
tenant:
header: X-Tenant-Id
required: true # default
public-paths: [/actuator/health]
rate-limit:
requests-per-second: 50 # default 20
burst: 100
logging:
include-query-string: false # default
# platform.filters.authentication.enabled=false -> startup WARN and metric filters_disabled{filter="auth"} 1

4Testing the Whole Chain in the Starter

Each filter has unit tests, but the bugs that matter come from the combination, so the starter has integration tests that boot a minimal web application with the starter on the classpath and send real requests with MockMvc or a test HTTP client. They cover the happy path and every failure: no token gives 401 and is logged with a request id; a valid token without a tenant gives 400; a token for tenant acme with header globex gives 403; the 21st request in a second gives 429 with a Retry-After header; an extension filter at AFTER_TENANT sees the tenant; and the public health path skips the tenant check.

We also publish a small test kit, a JUnit extension or test slice, so each service can run the same checks against its own configuration in its build. That catches a service whose overrides break the chain before it is deployed.

Chain tests every release must pass
RequestExpected resultFilter that decides
No token401, logged with request idAuthentication
Valid token, no tenant header400 missing tenantTenant resolution
Token for acme, header globex403 tenant mismatchTenant resolution
21st request in one second429 with Retry-AfterRate limiting
Valid request200, extension filters ran in orderApplication
GET /actuator/health200 without tenantPublic path rule

5Rolling Out New Versions

A change to the starter reaches 200 services, so it ships like a risky deployment. Every standard filter records metrics through Micrometer: requests seen, requests rejected with the reason, and time spent. After a release, a few low-risk services adopt the new version first as canaries, and dashboards compare rejection rates and latency per filter before and after. A jump in 403 tenant mismatches after an upgrade is a signal to stop before it reaches payments. Behaviour changes that could reject traffic ship behind a property, off by default in the first release, then on by default once the canaries are quiet, and services are moved forward by automated dependency update pull requests rather than by hand.

6A Compatibility Policy for Order and Behaviour

The order of the standard filters and the meaning of the extension points are a contract, so we publish a policy using semantic versioning. Patch and minor versions may fix bugs and add properties or extension points, but must not change the relative order of standard filters, the default of any property, or which requests are rejected. Changing those requires a major version, with release notes that say exactly what changes, an opt-in flag in the preceding minor release, and a support window during which the previous major version still gets security fixes. Deprecations log a warning with the property or API to use instead, so teams learn from their own logs before the major version removes anything.

7Follow-up questions

Why not let each service write its own filters with a guideline document?

Guidelines drift, and the dangerous mistakes, such as trusting a tenant header before authentication, are exactly the ones a document does not prevent. A starter gives a tested default that is easier to use than to bypass, while extension points keep teams free to add what they need.

How do you handle a service that needs a completely different chain, such as a public webhook receiver?

The starter can offer profiles, such as an internal API profile and a webhook profile with signature verification instead of tokens, each with its own tested order. A service that truly needs something else can opt out explicitly, and the opt-out is visible in metrics so it can be reviewed.

Where should rate limit state live for a service with many instances?

For limits per tenant across instances, a shared store such as Redis, or a gateway in front of the services, is needed; a local in-memory limiter only limits per instance. The starter can support both through configuration, with the local one as a safe fallback.

8Conclusion

In this answer, we designed a shared starter whose standard filters, logging, authentication, tenant resolution and rate limiting, run in an order defined by published constants with gaps. Named extension points let teams add filters without reordering the standard ones, properties with safe defaults and validation configure each filter, and integration tests in the starter cover the whole chain including failures. New versions roll out through canaries with per-filter metrics, under a compatibility policy that treats order and behaviour changes as major changes.

What to say in the interviewAbout 100 seconds aloud

Open with

I would put the chain in a starter that fixes the order of the standard filters with public constants spaced a hundred apart: request id and logging first, so every request is traced, then authentication, then tenant resolution, which checks the tenant against the token rather than trusting a header, then rate limiting per tenant before the application.

Then, if they want more

Authentication would go through Spring Security, with the other filters placed relative to its filters. For extension, I would not let teams pick arbitrary order values, because someone would end up before authentication.

Instead the starter offers named extension points, after authentication, after tenant and before the application, and teams implement a small ExtensionFilter interface that says which point it belongs to. The starter wires those in and logs the full chain at startup.

Every filter is configured under one property prefix with validation and safe defaults, like tenant required and no body logging, and disabling a protection logs a warning and shows up in a metric.

The starter has integration tests for the whole chain, including a missing token, a missing tenant, a tenant mismatch, rate limit exceeded and public paths, and it ships a test kit so services can run the same checks with their config.

For rollout, each filter emits metrics on rejections and latency, new versions go to canary services first, and risky behaviour ships behind a flag. Finally, I would publish a compatibility policy: order and rejection behaviour only change in a major version, with an opt-in period and clear release notes.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
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 "Design a shared Spring Boot starter that gives 200 services a standard request filter...": https://scrivio-interview-library.netlify.app/java/behavioral-patterns/46ec145128/