Chaturmind
LearnDSASystem DesignInterview PrepDevOpsEngineering GrowthBlog
Start learning
Chaturmind

Structured learning paths for engineers who want to go deep. Written by practitioners.

Learn

  • Java
  • DSA
  • System Design
  • Spring Boot
  • AI / ML
  • DevOps
  • Engineering Growth
  • Java Interview Prep

Company

  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Chaturmind. All rights reserved.

Built for engineers who want to go deep.


← Java Interview Prep: 8+ Years (Senior & Lead)

Expert Core Java

  • Tricky Java Output, Operators & OOP Edge Cases — Interview Questions
  • Tricky Exceptions, Memory & Keyword Questions — Interview Questions
  • Classic Java Language Questions, Senior-Grade Answers — Interview Questions
  • Classic Collections, Threads & JDK APIs, Senior-Grade Answers — Interview Questions
  • Reflection, Dynamic Proxies, final & Modern OOP Design — Interview Questions

JVM Internals & Performance

  • Class Loading, Bytecode & Object Layout — Interview Questions
  • JIT Compilation & Runtime Optimisations — Interview Questions
  • Garbage Collectors Deep Dive — Interview Questions
  • JVM Tuning, GC Logs & Memory Footprint — Interview Questions
  • Memory Leaks, OutOfMemoryErrors & Profiling Tools — Interview Questions
  • Modules, Agents & Advanced JVM APIs — Interview Questions

Collections & Concurrency at Scale

  • Collections Internals & Complexity — Interview Questions
  • Iterators, Comparators & Ordering Contracts — Interview Questions
  • Concurrent Collections, Queues & Lock-Free Structures — Interview Questions
  • Threads, Executors & ForkJoin Internals — Interview Questions
  • Locks, Atomics, CAS & Synchronizers — Interview Questions
  • Java Memory Model, volatile, Fences & ThreadLocal — Interview Questions
  • Deadlock, Livelock, Starvation & Concurrent Design — Interview Questions
  • CompletableFuture, Parallel Streams & Non-Blocking I/O — Interview Questions

Modern Java (8 to 21+)

  • Lambdas & Functional Interfaces Internals — Interview Questions
  • Streams & Collectors Deep Dive — Interview Questions
  • Optional & Interface Default/Static Methods — Interview Questions
  • Java 9–25 Features & Virtual Threads — Interview Questions

Design Patterns, SOLID & Clean Code

  • Design Pattern Trade-offs & Combinations — Interview Questions
  • SOLID, Clean Code & Anti-Patterns — Interview Questions

Spring & Spring Boot Internals

  • IoC, Dependency Injection & Bean Lifecycle Internals — Interview Questions
  • Spring AOP, Proxies & @Async Internals — Interview Questions
  • Spring Configuration, Auto-Configuration & Custom Starters — Interview Questions
  • Spring MVC & REST Internals, Exception Frameworks — Interview Questions
  • Spring Security Advanced Internals — Interview Questions
  • Spring WebFlux, Reactor & R2DBC — Interview Questions
  • Spring Cloud, Observability & Distributed Tracing — Interview Questions
  • Spring Boot 3, Native Images & Production Scenarios — Interview Questions

JPA, Hibernate & Databases at Scale

  • Spring Data JPA — Queries, Projections, Custom Repositories & Locking — Interview Questions
  • JPA Entity Mapping, Associations & Cascades — Interview Questions
  • JPQL vs Native Queries in Depth — Interview Questions
  • Hibernate Caching — First-Level, Second-Level & Query Cache — Interview Questions
  • Lazy vs Eager Loading, LazyInitializationException & N+1 — Interview Questions
  • JPA Transactions, Propagation, Isolation & Dirty Checking — Interview Questions
  • SQL vs NoSQL, Indexing & Query Tuning — Interview Questions
  • Database Scaling, Replication, Pooling & Consistency Models — Interview Questions
  • Redis, Search, Time-Series, CDC & Transactional Data Modelling — Interview Questions

Testing Strategy & API Design

  • Spring Boot Test Slices, Context & Test Strategy — Interview Questions
  • Testing Web, Persistence, Security, Async & Messaging in Spring Boot — Interview Questions
  • JUnit 5 & Mockito, Advanced — Interview Questions
  • MockMvc, WebTestClient & Testcontainers in Depth — Interview Questions
  • REST Principles, Status Codes & Resource Design — Interview Questions
  • OpenAPI, Validation Errors, API Versioning & GraphQL — Interview Questions

Build, DevOps & Cloud

  • Maven & Gradle at Scale — Interview Questions
  • Git, CI/CD Pipelines & Release Safety — Interview Questions
  • Docker & Kubernetes for Java Engineers — Interview Questions
  • Quality Gates, Artifact Repositories & Secrets Management — Interview Questions
  • AWS Deployment & Scaling for Spring Boot — Interview Questions
  • Multi-Cloud Deployment, High Availability, Cost & Cloud Troubleshooting — Interview Questions

Kafka & Messaging

  • Kafka Internals & Delivery Semantics — Interview Questions
  • Spring Kafka — Error Handling, DLQs, Schemas & Operations — Interview Questions
  • RabbitMQ, JMS & Messaging Models — Interview Questions

Microservices & Architecture

  • Distributed Systems Fundamentals — CAP, Consistency, Availability & SLOs — Interview Questions
  • DDD, Hexagonal Architecture & Service Boundaries — Interview Questions
  • Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions
  • Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions
  • Files, Documents & Internationalisation in Java Backends — Interview Questions
  • WebSockets, Schedulers, Notifications & Real-Time Pipelines — Interview Questions

System Design Scenarios

  • Booking Systems, CRS, Inventory & Concurrency Control — Interview Questions
  • Dynamic Pricing & Rule Engines — Interview Questions
  • Partner Integrations — OTA Sync, Retries, Webhooks, Reconciliation & Bulk Data — Interview Questions
  • Designing Caches & Rate Limiters — Interview Questions
  • Event-Driven Architecture, Kafka at Scale, IoT & Real-Time Pipelines — Interview Questions
  • Observability, Logging, Alerting & Audit Systems — Interview Questions
  • Multi-Tenant SaaS, Identity & Platform Services — Interview Questions
  • Search, Notifications, Chat, Fraud Detection & Workflows — Interview Questions
  • Extreme Scale, 99.99% Availability, DR & Project Deep-Dive Stories — Interview Questions

Security for Senior Engineers

  • Tokens, OAuth2 PKCE, Web Attacks & API Security — Interview Questions
  • TLS, mTLS, Zero Trust, Secrets, DDoS & Privacy Compliance — Interview Questions

Leadership & Behavioural

  • Leadership Style, Motivation & Team Health — Interview Questions
  • Delivery, Planning & Decisions Under Uncertainty — Interview Questions
  • Problem Solving, Growth & Career Stories — Interview Questions
  • Stakeholder Communication, Ethics & Compliance — Interview Questions
  • Mentoring, Knowledge Sharing & Code Reviews — Interview Questions
  • Agile & Scrum Practices for Senior Engineers — Interview Questions
  • Architecture Decision-Making — Interview Questions
  • Conflict Resolution & Difficult Conversations — Interview Questions
Chaturmind
← Java Interview Prep: 8+ Years (Senior & Lead)

Expert Core Java

  • Tricky Java Output, Operators & OOP Edge Cases — Interview Questions
  • Tricky Exceptions, Memory & Keyword Questions — Interview Questions
  • Classic Java Language Questions, Senior-Grade Answers — Interview Questions
  • Classic Collections, Threads & JDK APIs, Senior-Grade Answers — Interview Questions
  • Reflection, Dynamic Proxies, final & Modern OOP Design — Interview Questions

JVM Internals & Performance

  • Class Loading, Bytecode & Object Layout — Interview Questions
  • JIT Compilation & Runtime Optimisations — Interview Questions
  • Garbage Collectors Deep Dive — Interview Questions
  • JVM Tuning, GC Logs & Memory Footprint — Interview Questions
  • Memory Leaks, OutOfMemoryErrors & Profiling Tools — Interview Questions
  • Modules, Agents & Advanced JVM APIs — Interview Questions

Collections & Concurrency at Scale

  • Collections Internals & Complexity — Interview Questions
  • Iterators, Comparators & Ordering Contracts — Interview Questions
  • Concurrent Collections, Queues & Lock-Free Structures — Interview Questions
  • Threads, Executors & ForkJoin Internals — Interview Questions
  • Locks, Atomics, CAS & Synchronizers — Interview Questions
  • Java Memory Model, volatile, Fences & ThreadLocal — Interview Questions
  • Deadlock, Livelock, Starvation & Concurrent Design — Interview Questions
  • CompletableFuture, Parallel Streams & Non-Blocking I/O — Interview Questions

Modern Java (8 to 21+)

  • Lambdas & Functional Interfaces Internals — Interview Questions
  • Streams & Collectors Deep Dive — Interview Questions
  • Optional & Interface Default/Static Methods — Interview Questions
  • Java 9–25 Features & Virtual Threads — Interview Questions

Design Patterns, SOLID & Clean Code

  • Design Pattern Trade-offs & Combinations — Interview Questions
  • SOLID, Clean Code & Anti-Patterns — Interview Questions

Spring & Spring Boot Internals

  • IoC, Dependency Injection & Bean Lifecycle Internals — Interview Questions
  • Spring AOP, Proxies & @Async Internals — Interview Questions
  • Spring Configuration, Auto-Configuration & Custom Starters — Interview Questions
  • Spring MVC & REST Internals, Exception Frameworks — Interview Questions
  • Spring Security Advanced Internals — Interview Questions
  • Spring WebFlux, Reactor & R2DBC — Interview Questions
  • Spring Cloud, Observability & Distributed Tracing — Interview Questions
  • Spring Boot 3, Native Images & Production Scenarios — Interview Questions

JPA, Hibernate & Databases at Scale

  • Spring Data JPA — Queries, Projections, Custom Repositories & Locking — Interview Questions
  • JPA Entity Mapping, Associations & Cascades — Interview Questions
  • JPQL vs Native Queries in Depth — Interview Questions
  • Hibernate Caching — First-Level, Second-Level & Query Cache — Interview Questions
  • Lazy vs Eager Loading, LazyInitializationException & N+1 — Interview Questions
  • JPA Transactions, Propagation, Isolation & Dirty Checking — Interview Questions
  • SQL vs NoSQL, Indexing & Query Tuning — Interview Questions
  • Database Scaling, Replication, Pooling & Consistency Models — Interview Questions
  • Redis, Search, Time-Series, CDC & Transactional Data Modelling — Interview Questions

Testing Strategy & API Design

  • Spring Boot Test Slices, Context & Test Strategy — Interview Questions
  • Testing Web, Persistence, Security, Async & Messaging in Spring Boot — Interview Questions
  • JUnit 5 & Mockito, Advanced — Interview Questions
  • MockMvc, WebTestClient & Testcontainers in Depth — Interview Questions
  • REST Principles, Status Codes & Resource Design — Interview Questions
  • OpenAPI, Validation Errors, API Versioning & GraphQL — Interview Questions

Build, DevOps & Cloud

  • Maven & Gradle at Scale — Interview Questions
  • Git, CI/CD Pipelines & Release Safety — Interview Questions
  • Docker & Kubernetes for Java Engineers — Interview Questions
  • Quality Gates, Artifact Repositories & Secrets Management — Interview Questions
  • AWS Deployment & Scaling for Spring Boot — Interview Questions
  • Multi-Cloud Deployment, High Availability, Cost & Cloud Troubleshooting — Interview Questions

Kafka & Messaging

  • Kafka Internals & Delivery Semantics — Interview Questions
  • Spring Kafka — Error Handling, DLQs, Schemas & Operations — Interview Questions
  • RabbitMQ, JMS & Messaging Models — Interview Questions

Microservices & Architecture

  • Distributed Systems Fundamentals — CAP, Consistency, Availability & SLOs — Interview Questions
  • DDD, Hexagonal Architecture & Service Boundaries — Interview Questions
  • Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions
  • Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions
  • Files, Documents & Internationalisation in Java Backends — Interview Questions
  • WebSockets, Schedulers, Notifications & Real-Time Pipelines — Interview Questions

System Design Scenarios

  • Booking Systems, CRS, Inventory & Concurrency Control — Interview Questions
  • Dynamic Pricing & Rule Engines — Interview Questions
  • Partner Integrations — OTA Sync, Retries, Webhooks, Reconciliation & Bulk Data — Interview Questions
  • Designing Caches & Rate Limiters — Interview Questions
  • Event-Driven Architecture, Kafka at Scale, IoT & Real-Time Pipelines — Interview Questions
  • Observability, Logging, Alerting & Audit Systems — Interview Questions
  • Multi-Tenant SaaS, Identity & Platform Services — Interview Questions
  • Search, Notifications, Chat, Fraud Detection & Workflows — Interview Questions
  • Extreme Scale, 99.99% Availability, DR & Project Deep-Dive Stories — Interview Questions

Security for Senior Engineers

  • Tokens, OAuth2 PKCE, Web Attacks & API Security — Interview Questions
  • TLS, mTLS, Zero Trust, Secrets, DDoS & Privacy Compliance — Interview Questions

Leadership & Behavioural

  • Leadership Style, Motivation & Team Health — Interview Questions
  • Delivery, Planning & Decisions Under Uncertainty — Interview Questions
  • Problem Solving, Growth & Career Stories — Interview Questions
  • Stakeholder Communication, Ethics & Compliance — Interview Questions
  • Mentoring, Knowledge Sharing & Code Reviews — Interview Questions
  • Agile & Scrum Practices for Senior Engineers — Interview Questions
  • Architecture Decision-Making — Interview Questions
  • Conflict Resolution & Difficult Conversations — Interview Questions
HomeLearnJava Interview PrepJava Interview Prep: 8+ Years (Senior & Lead)Microservices & Architecture
✓ FreeAdvanced· 11 min read

DDD, Hexagonal Architecture & Service Boundaries — Interview Questions

When not to use microservices, avoiding a distributed monolith, domain-driven design (bounded contexts, aggregates), hexagonal (ports and adapters) architecture, internal vs external API design, API gateway anti-patterns, Istio/service mesh vs API gateway, the sidecar pattern, polyglot persistence, team structure (Conway's law, team topologies), multi-tenant application design, and consumer-driven contracts.

Published September 25, 2026


How to use this lesson

Architecture questions at this level are about boundaries:

  • where to draw them (the domain);
  • how to enforce them (ports, contracts, ownership);
  • what they cost (distribution).

The best answers show restraint: the simplest architecture that meets the need, with a clear path to evolve.

Q1. When should you not use microservices?

Short answer:

  • A small team (one or two teams): the coordination benefits don't exist yet, and the operational overhead dominates.
  • An early-stage product, or an unclear domain: the boundaries will be wrong, and moving them across services is expensive. Start with a modular monolith, and extract services later.
  • No platform maturity: no CI/CD, observability, container platform or on-call practices. Distributed failures will overwhelm you.
  • Strong consistency across the whole domain (heavy cross-entity transactions): splitting forces sagas everywhere.
  • Low scale and change-rate differences between components: no component needs independent scaling or deployment.
  • Latency-sensitive, chatty workflows, where network hops hurt.

The alternative: a modular monolith (Spring Modulith, with module boundaries enforced by ArchUnit and events between modules). It gives most of the design benefits, with one deployment unit.

Learn it in depth → Monolith to Microservices Decomposition

Q2. How do you avoid a distributed monolith?

Short answer: A distributed monolith has all the costs of distribution, and none of the independence: services that must be deployed together, share a database, make long synchronous call chains, or share internal libraries with domain logic. Avoid it by:

  • drawing boundaries around business capabilities and bounded contexts (high cohesion inside, loose coupling between);
  • each service owns its data (no shared tables; integrate through APIs or events);
  • asynchronous, event-driven integration where possible, and minimal synchronous chains;
  • backward-compatible, versioned contracts, with consumer-driven contract tests, so services deploy independently;
  • no shared domain libraries (sharing technical starters is fine);
  • team ownership aligned to the services;
  • measuring coupling: co-change frequency, deployment coordination, and cross-service call graphs.

If services always change together, merge them.

Q3. What is domain-driven design (DDD)? What are aggregates and bounded contexts?

Short answer: DDD is an approach to software design that models the software on the business domain, built with domain experts through a shared ubiquitous language.

  • Strategic design:
    • Bounded context: an explicit boundary within which a model and its language are consistent. For example, "Customer" means different things in Billing (a payer) and Support (a ticket requester). Contexts are the natural microservice or module boundaries.
    • Context maps describe the relationships: customer/supplier, conformist, anti-corruption layer, shared kernel, open-host service, and published language.
  • Tactical design:
    • entities (identity), value objects (immutable, equality by value: Money, Address);
    • aggregates: a cluster of objects treated as one consistency unit, with a root as the only entry point, enforcing the invariants within one transaction (an Order aggregate with its lines, where the total must match the lines);
    • domain events, repositories, and domain services.
  • Aggregate design rules (Vaughn Vernon):
    • keep aggregates small;
    • reference other aggregates by ID;
    • one aggregate per transaction;
    • use eventual consistency between aggregates, through domain events.

Learn it in depth → Domain Decomposition

Q4. What is hexagonal architecture (ports and adapters)?

Short answer: Alistair Cockburn's pattern puts the application core (domain plus use cases) at the centre. The core talks to the outside world only through ports:

  • inbound (driving) ports: use-case interfaces, called by adapters such as REST controllers, message listeners, CLI or tests;
  • outbound (driven) ports: interfaces the core needs, such as OrderRepository, PaymentGateway and EventPublisher, implemented by adapters (JPA, a Stripe client, Kafka).

Dependencies point inward: the core has no framework imports. The benefits:

  • testing the core without infrastructure (fake adapters);
  • swapping technologies;
  • clear boundaries;
  • delaying technical decisions.

It's closely related to Onion and Clean Architecture. In Spring: packages or modules like domain, application (ports and use cases), adapter.in.web, adapter.out.persistence, and config (wiring), enforced with ArchUnit. Pragmatism: for simple CRUD services, a full hexagon adds mapping boilerplate, so apply it where the domain logic is rich.

// application (core)
public interface PlaceOrderUseCase { OrderId place(PlaceOrderCommand cmd); }          // inbound port
public interface PaymentPort { PaymentResult authorize(Money amount, String token); }  // outbound port

@Service @RequiredArgsConstructor
class PlaceOrderService implements PlaceOrderUseCase {
    private final OrderRepositoryPort orders; private final PaymentPort payments;
    public OrderId place(PlaceOrderCommand cmd) { /* domain logic only, no HTTP or JPA types */ return null; }
}
// adapter.out.payment
@Component class StripePaymentAdapter implements PaymentPort { /* Stripe SDK calls */ public PaymentResult authorize(Money m, String t) { return null; } }

Q5. How do you design internal versus external APIs?

Short answer:

  • External (public or partner) APIs:
    • a stable, carefully versioned contract (design-first OpenAPI), coarse-grained and business-oriented resources;
    • strong security (OAuth2 scopes, rate limits and quotas, WAF);
    • backward compatibility, and long deprecation periods;
    • consistent errors (Problem Details), pagination and idempotency;
    • developer experience (documentation, SDKs, sandbox);
    • exposed through an API gateway, often through a BFF per client type.
  • Internal (service-to-service) APIs:
    • optimised for efficiency: gRPC or Protobuf, or lean REST, and events for asynchronous integration;
    • contract-tested between the teams (consumer-driven contracts);
    • authenticated with mTLS or client credentials (zero trust, even inside the network);
    • can evolve faster (known consumers), but still need compatibility discipline, because services deploy independently.
  • Never expose internal APIs directly to the outside. A gateway or BFF translates and aggregates them, and hides the internal topology.

Q6. What are the anti-patterns of API gateways?

Short answer:

  • Business logic in the gateway: the gateway becomes a "god service" (a new monolith), and every team's change needs a gateway deployment.
  • Heavy orchestration or aggregation of many services in the gateway, instead of in dedicated BFFs owned by the client teams.
  • A single shared gateway team as a bottleneck: route configuration should be self-service (GitOps), with guardrails.
  • Stateful gateways: session state in the gateway hinders scaling.
  • The gateway as the only security layer: services must still authenticate and authorise (zero trust).
  • Over-transformation: protocol or payload mapping sprawl, which is hard to test.
  • Lack of resilience: no timeouts or circuit breakers per route, so one slow backend exhausts the gateway.
  • Too many hops (gateway → BFF → aggregator → service), adding latency and failure points.

Q7. Istio (service mesh) vs API gateway: what's the difference?

Short answer: They solve different traffic directions, and overlap a little:

  • An API gateway: north-south traffic (external clients → the system). It handles client-facing concerns: authentication with user tokens, API keys, rate limiting and quotas, request and response transformation, aggregation, a developer portal, and monetisation.

  • A service mesh (Istio, Linkerd): east-west traffic (service → service). Transparent, platform-level features for every call:

    • mTLS and workload identity;
    • authorisation policies between services;
    • retries, timeouts, circuit breaking;
    • traffic splitting (canaries);
    • fault injection;
    • uniform telemetry.

    No application code changes are needed.

  • Use both: the gateway at the edge (Istio even provides an ingress gateway, and the Kubernetes Gateway API unifies the configuration), and the mesh inside. Don't duplicate retry policies at both layers (they multiply).

Learn it in depth → Design Service Mesh Basics

Q8. What is the sidecar pattern?

Short answer: Deploy a helper container alongside the application container in the same pod. They share the network namespace (localhost) and volumes, so the helper adds cross-cutting capabilities without changing the application code. Examples:

  • service-mesh proxies (Envoy);
  • log shippers (Fluent Bit);
  • secret agents (Vault Agent);
  • config reloaders;
  • the OpenTelemetry Collector;
  • auth proxies (oauth2-proxy).

The benefits: language-agnostic reuse, a separate release cycle, and isolation. The costs: extra resources per pod, startup ordering (Kubernetes native sidecar containers, restartPolicy: Always init containers, fix this), more complex debugging, and latency hops. Ambient mesh or node-level agents reduce the per-pod overhead.

Q9. What is polyglot persistence?

Short answer: Using different storage technologies for different data needs, often per service or bounded context, instead of one database for everything:

  • PostgreSQL for transactional orders;
  • Redis for sessions and caching;
  • Elasticsearch for search;
  • Cassandra or a time-series database for telemetry;
  • Neo4j for relationship queries;
  • S3 for blobs;
  • a warehouse for analytics.

The benefits: each workload gets a fitting data model and scaling characteristics. The costs:

  • operational complexity (backups, security, expertise per technology);
  • data synchronisation between stores (use CDC or events, and handle the eventual consistency);
  • more places for data leaks.

Keep it justified: start with one strong general-purpose database (Postgres goes far: JSONB, full-text search, pgvector), and add specialised stores when a measured need appears.

Q10. How should teams be structured for microservices?

Short answer:

  • Conway's law: systems mirror the communication structures of the organisations that build them. Use it deliberately (the "inverse Conway manoeuvre"): shape the teams around the desired architecture.
  • Stream-aligned teams (Team Topologies) own services end to end (build, run, on-call), aligned to business capabilities or bounded contexts, not technical layers ("frontend team", "DBA team").
  • A platform team provides a paved road (CI/CD templates, observability, Kubernetes, security baselines, starters), reducing the cognitive load.
  • Enabling teams coach on new practices (SRE, security), and complicated-subsystem teams own specialised components (for example, a pricing engine or search).
  • Team size: "two-pizza" teams (5–9 people), each owning a few services (not one service per person).
  • Clear ownership: a service catalogue (Backstage) with owners, SLOs and runbooks. Interaction modes between teams: collaboration, X-as-a-service, facilitating.

Q11. How would you design a multi-tenant application?

Short answer:

  • Tenant identification: resolve the tenant from the authentication token claims (preferred), or the subdomain or header. Propagate a tenant context (a ScopedValue or request-scoped bean, plus MDC and trace attributes, plus message headers).

  • The data isolation model (per requirement):

    • a shared schema with tenant_id (cheapest, and needs strict filtering: Hibernate @TenantId/filters, and Postgres row-level security as defence in depth);
    • schema-per-tenant;
    • database-per-tenant (strongest isolation, for enterprise or regulated tenants);
    • or a hybrid.

    Spring or Hibernate multi-tenancy uses CurrentTenantIdentifierResolver and MultiTenantConnectionProvider.

  • Isolation beyond the data:

    • tenant-aware caching keys;
    • per-tenant rate limits, quotas and bulkheads (noisy-neighbour protection);
    • per-tenant encryption keys (BYOK);
    • separate queues or partitions for large tenants;
    • tenant-scoped authorisation checks everywhere.
  • Operations: tenant onboarding and offboarding automation (provisioning, migrations per schema or database), per-tenant metrics and billing, data residency (region pinning), and backup and restore per tenant.

  • Testing: automated tests proving that cross-tenant access is impossible.

Learn it in depth → Database Scaling Decision Framework

Q12. What is consumer-driven contract testing?

Short answer: Consumers define the expectations (the requests they send, and the response fields they rely on) as contracts. Providers verify that they satisfy all their consumers' contracts in CI:

  • Pact: the consumer tests generate pact files against a mock provider. The pacts are published to a Pact Broker. The provider build replays them against the real provider, and can-i-deploy checks the compatibility before release.
  • Spring Cloud Contract: the contracts (Groovy, YAML or Kotlin DSL) generate provider tests and consumer stubs (WireMock or messaging stubs).

The benefits: providers know exactly what consumers use, so they can evolve safely; it catches breaking changes before deployment; and it's faster and more reliable than end-to-end environments. It works for messaging too (message pacts). The limitation: it only covers what the consumers wrote down. It complements schema checks and a few end-to-end tests.

Follow-up questions this topic invites — and their answers

Q: What is an anti-corruption layer? A: A translation boundary (adapters, translators, facades) that protects your bounded context's model from an external or legacy system's model, so its concepts and quirks don't leak into your domain.

Q: What is Spring Modulith? A: A Spring project for building modular monoliths: it verifies module boundaries (application modules follow package structure), supports asynchronous application events between modules (with an event publication registry, an outbox-like mechanism), generates documentation, and supports module-scoped integration tests.

Q: How big should a microservice be? A: Big enough to own a cohesive business capability and its data, small enough for one team to understand and change quickly. Size by boundaries and ownership, not by lines of code.

Q: What's the difference between orchestration and choreography, from a team perspective? A: Orchestration centralises the workflow knowledge (one team owns it, and it's easier to see), but it couples the participants to the orchestrator. Choreography distributes the knowledge (more autonomy), but the end-to-end flow is harder to reason about and monitor.

Previous

Distributed Systems Fundamentals — CAP, Consistency, Availability & SLOs — Interview Questions

Next

Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions

AI Tutor

Lesson: DDD, Hexagonal Architecture & Service Boundaries — Interview Questions

Quick actions

AI responses can be inaccurate. Verify critical information.