When one HAPI FHIR JPA server is no longer enough for high availability
A team whose FHIR API supports clinical or operational work cannot take that API offline for every patch or restart. The pattern to plan for is several HAPI FHIR JPA server nodes sharing one relational database, placed behind a load balancer, so that a single node can be drained, patched and returned to service while the others keep answering requests. A single server is usually the right starting point, but the moment downtime for maintenance becomes unacceptable, the design question shifts from how to run one server to how the nodes share state.
The reason this pattern works is that the JPA server keeps its resource data, search indexes, history and most operational state in the database, accessed through the JPA API rather than in a specific database technology. Each node is therefore a front end over the same data. The starter supports PostgreSQL and Microsoft SQL Server for production use and does not support MySQL, so the database choice is settled before any node is added. Confirm the exact database versions supported by your HAPI FHIR release in the HAPI FHIR JPA server introduction and the starter repository before you size the database tier.
Before you add a second node, check which parts of the deployment are not shared. Settings in application.yaml must match across nodes, the public server address must be the load balancer address on every node, and any component that holds state in memory, such as subscription handling or local caches, needs a review against the hapi-fhir-jpaserver-starter repository. Ask your vendor or implementer to confirm which in-memory state each enabled module keeps per node, because that determines how a node restart affects clients.
How the load balancer, HAPI FHIR nodes and shared database fit together
The diagram starts with clients sending FHIR requests to a load balancer, which spreads them across several HAPI FHIR JPA server nodes. Every node reads and writes the same PostgreSQL or SQL Server database, so the database is the single source of record. A separate box lists what each node keeps in its own memory, such as subscription state and caches, and the public server address set at the proxy, which must match what clients see. Check that every node points at the same database and that the public address is consistent on each node.
Several stateless-looking nodes share one database, but each keeps its own memory.
Deployment options for running several nodes and when each fits
This table compares the three practical ways to run several HAPI FHIR JPA server nodes behind one load balancer: Docker Compose on fixed hosts, Kubernetes with the Helm chart, and WAR deployments on an application server. Read each row against your own platform team's skills and change control, because the main takeaway is that the node count matters less than who patches, restarts and rolls out each node.
| Option | Operations effort | Maintenance control | When it fits |
|---|---|---|---|
| Docker Compose on fixed hosts | Manual: you script restarts, rolling updates and host patching yourself | High: you choose the image tag, the host and the timing of every change | Small estates with a few named hosts and a team that already runs Compose in production |
| Kubernetes with the Helm chart and multiple replicas | Higher upfront: you need a cluster, ingress, probes and a pod disruption budget | Medium to high: the chart and cluster policy set defaults, you still own values and upgrades | Organizations already operating Kubernetes that want scheduled restarts and rolling upgrades |
| WAR on Tomcat, Jetty or Wildfly | Depends on the existing application server team and its clustering setup | High: you control the servlet container, JVM settings and deployment windows | Hospital IT environments that standardize on an application server and require its change process |
| Any option with a shared external database | Database high availability and backups become a separate, required workstream | Shared across nodes: schema changes and maintenance affect every node at once | All multi-node designs, since each node must point to the same database |
| Any option with in-memory subscription or cache state | Requires a plan for draining, restarting and resubscribing clients node by node | Per-node behavior must be verified after each change | Deployments that use subscriptions or heavy search caching across several nodes |
How to set up a second HAPI FHIR node on a shared database
This sequence takes a single HAPI FHIR JPA server to two or more nodes that read and write the same database behind one load balancer. The result is a cluster where any node serves the same data, and you have evidence that a write on one node is visible from another.
Provision a production database
The platform or database team creates a PostgreSQL or Microsoft SQL Server instance that all nodes can reach over the network, with a dedicated schema owner account for the FHIR server. The JPA starter defaults to an embedded H2 database, which is not suitable for shared use, and MySQL is not supported. Confirm that the database has backups and a failover design in place before any node connects to it. Done when a test connection from a host in the node subnet succeeds with the application account and the database is reachable from every planned node.
Configure the starter identically on each node
Build or pull the same starter version and apply the same configuration to every node, using environment variables or a shared application.yaml. Database URL, credentials, FHIR version, enabled modules, partition mode and any interceptors must match exactly, because drift between nodes produces inconsistent search results and authorization behavior. Keep secrets in your secrets manager rather than in files copied by hand. Done when a diff of the effective configuration from each node shows no differences other than host-specific values.
Set the public server address through the load balancer
Set the public base URL to the load balancer address rather than the individual node address, so that links and Bundle entries returned by any node point to the shared entry point. Terminate TLS at the load balancer or proxy and confirm the forwarded headers that the server reads for scheme and host. Done when a request to each node directly and through the load balancer returns self links and next links that use the public address.
Run schema migration once and confirm ordering
Start exactly one node first and let it run the schema migration against the empty or existing database. Wait until that node reports a healthy state and the schema version is recorded, then start the remaining nodes so they validate against the migrated schema instead of racing to change it. Confirm the order in your deployment tooling, for example by making the other replicas wait for the first to pass readiness. Done when the migration log shows one run and every later node starts without attempting schema changes.
Add health checks to each node
Expose the health endpoint on every node and wire it into the load balancer so that a node is removed from rotation when its database connection or startup fails. Use separate liveness and readiness semantics where your platform supports them, and allow enough startup time for the first node to finish migrating. Use the health check configuration described in the dedicated topic on probes. Done when stopping the database connection or a node process causes the load balancer to stop routing to that node, and restoring it returns the node to rotation.
Test that a write on one node is visible from another
Create a test resource through the load balancer, then read it back through each node by address, bypassing the load balancer, to confirm the data is shared and not held in per-node state. Repeat with an update and a search that depends on the new value. Record the node that handled each request so the result is traceable. Done when the created, updated and searched results match on all nodes and the test is saved as a repeatable script.
Coordinate schema migration and upgrades across nodes
Treat every upgrade as a cluster-wide change: review the release notes for the target version, confirm the Java runtime requirement, and plan the schema migration as a single step run before the rest of the nodes move to the new version. Mixed versions on one database are not a supported pattern unless the release notes state it. Ask your vendor or partner to confirm the supported version mix in writing. Done when a rollout runbook names the migrating node, the order of restarts and the rollback point, and it has been rehearsed on a copy of the database.
Which background work must run once across the cluster
Behind a load balancer, every HAPI FHIR node runs the same code, so anything scheduled, cached or held in memory on one node can happen on all of them. The cards below list the background behaviours to confirm before you add a second instance, and they apply to any release you run.
Batch jobs and scheduled tasks
The JPA server runs batch jobs, such as reindexing and bulk operations, on a schedule or on request. Confirm in the documentation for your release whether each job claims work through the shared database or whether every node runs it. A duplicate run can double writes or corrupt index state, so check which jobs need a single active node and how that node is chosen during failover.
JPA server docsSubscription delivery and caches
Subscriptions depend on per-node state, including the resource subscription registry and delivery channels. Confirm how each node learns about new or changed subscriptions, which node delivers notifications, and whether a message can be sent twice after a node restarts. Plan for the cache window during rolling restarts, because a node that misses an update may serve stale subscription state.
Search and history caching
Search result caching and history counts can live in process memory on each node. Two nodes can therefore return different results for the same query for a short period after a write. Confirm the cache scope and expiry settings in the release you run, then test a write followed by a read through the load balancer to see whether clients observe the difference.
Partition configuration consistency
If you use partitioning for multitenancy or regional separation, every node must load the same partition definitions and interceptors. A node with an older configuration can route or authorize requests differently from its peers. Confirm the partition configuration is deployed as one versioned artifact, and verify each node's configuration after every change before routing traffic to it.
Partitioning docsSession and authentication state at the proxy
Authentication interceptors and OAuth tokens must validate on any node, so the server should not depend on in-memory sessions. Confirm which authentication state, if any, the proxy keeps with sticky sessions, and whether token validation needs the same signing keys and issuer settings on every node. Test a failover mid-session to confirm clients re-authenticate cleanly rather than failing silently.
How to plan rolling upgrades and maintenance without downtime
A rolling upgrade keeps a HAPI FHIR JPA cluster serving requests while each node is changed in turn. The rolling-restart sequence is: drain one node at the load balancer, stop it, patch or upgrade it, start it, confirm it is healthy, return it to the pool, and only then move to the next node. Keep at least one node serving at all times, and never take a second node out of rotation until the first has passed its health checks and is handling traffic again. Confirm with your load balancer how draining works (for example, whether in-flight requests finish before the node is removed) and what health endpoint it polls, since those details decide whether clients see errors during the window.
The hardest part of a rolling upgrade is that every node shares one database. Schema changes and version changes apply to that shared database, so nodes running different HAPI FHIR versions may briefly coexist against a schema that only one of them understands. Plan the order before you start: which node runs the schema migration, whether the new version is compatible with the old schema during the transition, and what you will do if a migration fails halfway. Review the upgrade notes for each version you cross in the HAPI FHIR versions documentation, and confirm with the project which combinations of old and new nodes are supported before you run them side by side. Take a verified database backup before the first node changes.
Java requirements apply to every node, not only the first one you upgrade. HAPI FHIR 8.2.0 requires JDK 17, so any node you move to that release, or any base image or application server that ships a different JDK, must meet the same requirement before it joins the pool. Check the JDK on each node and in each image tag during the rehearsal. The exact steps, including drain timing, migration order, rollback criteria and the commands you run on each node, must be validated in a test environment built from the same database engine and configuration as production. Record the results so the production runbook reflects what you actually tested, and confirm the exact procedure with your own platform team and your HAPI FHIR support provider before the change window.
Questions teams ask before running HAPI FHIR across several nodes
How much more effort does a multi-node HAPI FHIR setup add compared with one node?
A multi-node setup adds work in four places: the shared database must be highly available, the load balancer must route traffic and health checks correctly, every node must run the same configuration and version, and anything held in memory on one node must be checked for how it behaves when a peer handles the next request. A single node hides these questions because one process owns all state. With several nodes, the team also needs a rollout order for upgrades and a way to take one node out of service for maintenance without interrupting clients. The effort is front-loaded in design and testing, then recurs with each release and each change to the database or ingress.
Can our own team set up a multi-node HAPI FHIR deployment in-house?
A team with Java, Kubernetes or application server, and database operations experience can build it, provided it has time to test the behavior that only shows up under several nodes. The questions to answer honestly are whether the team already runs a highly available relational database, whether it has tested failover, and whether someone owns subscription behavior, batch jobs and maintenance windows. HAPI FHIR documentation and the JPA server introduction are the starting points for these checks. Teams that lack one of these skills often choose a fixed-scope engagement for the design and first build, then keep operating the system with their own staff.
What access and inputs does the work need from our team?
Plan to provide several things before design starts:
- Database: an existing or planned PostgreSQL or Microsoft SQL Server instance, with credentials, network paths and a decision on who runs its high availability and backups. The starter does not support MySQL.
- Load balancer and ingress: access to the current network path, TLS certificates and the public base address that clients use.
- Identity: the identity provider and the authentication design for clients and administrators.
- Monitoring and logging: access to the metrics and log systems your team already uses, plus alert recipients.
- Environments and change control: a non-production environment that matches production closely enough to test failover and upgrades.
Confirm each item with your own infrastructure owners, because the exact access model depends on your environment.
What drives the cost of a multi-node HAPI FHIR engagement?
The cost depends on how much of the work is one-time and how much recurs. One-time costs include the architecture and design, the build of the load balancer and deployment, the database high availability setup, and testing of failover, upgrades and scheduled jobs. Recurring costs include infrastructure for each node and the database replicas, monitoring, and support for upgrades and incidents. The main drivers are the chosen database high availability model, the number of environments, the amount of custom interceptors or identity integration, the depth of testing, and how many people must be trained. Ask any provider for a quote that separates these components, lists the infrastructure you pay for directly, and states what happens when scope changes.
How long does a multi-node HAPI FHIR setup take to deliver?
Duration depends on scope: the number of environments, whether the database high availability already exists, how many integrations and interceptors must be built, and how much testing the change board requires. DeployOpen does not publish timelines, and this page does not state a duration. In a fixed-scope engagement, the deliverables and timeline are agreed in writing before work starts, so the quote should name the phases, the dependencies on your database and network teams, and the acceptance tests. Ask for the schedule to show when your teams must approve access, changes and maintenance windows, because those approvals often set the pace.
Does DeployOpen support multi-node HAPI FHIR through a retainer?
DeployOpen offers ongoing support, upgrades and continuous testing as retainers, and most engagements are fixed-scope with scope, deliverables and timelines agreed in writing before work starts. A typical path is a fixed-scope design and build for the multi-node setup, followed by a retainer that covers upgrades, incident support and retesting after changes. DeployOpen implements, hardens, backs up, upgrades, documents and supports self-hosted platforms inside your own infrastructure, so the servers, databases and cloud accounts remain yours. Ask for the retainer terms in writing, including response expectations, which systems are covered and how upgrades are scheduled.
Limits to confirm in your environment before going live
A multi-node HAPI FHIR deployment is only as dependable as the assumptions behind it. The cards below cover the points where node behavior, load balancing, database failover, version compatibility and capacity can each differ from what a reference design assumes, and what to verify for your release and your infrastructure.
Per-node state in your version
Each HAPI FHIR node may hold caches and in-process state, such as subscription caches, search caching and batch job bookkeeping. Confirm for the exact release you pin which of these are local to a node, which are read from the shared database, and how a node that restarts or drops out rebuilds them. Do not assume that state is identical across nodes after a configuration change.
JPA server docsLoad balancer stickiness requirements
Determine whether any client flow, such as an SMART app login, a paginated search or an upload that spans several requests, depends on the same node answering each request. Confirm whether your load balancer needs session affinity, and whether your authentication setup works with round-robin distribution. Test pagination and token refresh across nodes before assuming stickiness is unnecessary.
Database failover behavior
Work with your DBA to confirm how the database cluster handles a primary failover, including the time connections take to reconnect, whether HAPI FHIR connection pools recover without a node restart, and how in-flight transactions fail. Confirm which failover mechanism your organization uses, because the answers differ between managed PostgreSQL services, self-run clusters and SQL Server availability groups.
JDK and database compatibility
Check that the release you pin supports your JDK and your database versions before you build the node image. The version page lists the JDK requirement for each release, for example JDK 17 for HAPI FHIR 8.2.0. Confirm the supported PostgreSQL or Microsoft SQL Server versions for that release with the vendor documentation, and plan the same versions in every environment that runs the cluster.
HAPI FHIR versionsRecovery and load targets through testing
Set your recovery time and peak load targets from your own service requirements, then verify them with failure tests. Stop a node under load, fail the database primary, and roll a configuration change across nodes while measuring response times and error rates. Record the results and repeat the tests after each upgrade. Targets that exist only in a design document are not evidence.
How DeployOpen scopes a multi-node HAPI FHIR setup
A DeployOpen engagement for a multi-node HAPI FHIR setup starts with a written scope that names every component the cluster depends on before any node is built. That scope lists the number of JPA server nodes, the database service and its high availability model, the reverse proxy or load balancer and how it routes traffic, the identity provider and which interceptors enforce access, the monitoring stack, and the test plan. Each item has an owner on the client side, such as a platform team for the nodes, a database team for PostgreSQL or SQL Server, and a security team for authentication. Because most engagements are fixed-scope, the scope, deliverables and timelines are agreed in writing before work starts, and any change to the node count or database choice is handled as a written scope change.
Scoping also means deciding what the client's team must confirm early. The reader should confirm which database engine the organization supports for production, since the starter supports PostgreSQL and Microsoft SQL Server and does not support MySQL, and whether the database platform already provides failover. The reader should also confirm the public server address that clients will use behind the load balancer, the TLS termination point, and which environment hosts the nodes, whether cloud accounts, data center virtualization or an air-gapped network. Timelines and effort depend on those answers, so ask for a scope that records them as assumptions rather than a single number.
The delivered result is a configured cluster and a runbook, both kept inside the client's infrastructure. The runbook should cover node start and stop order, rolling restarts, how to drain a node from the load balancer, the steps for applying a schema migration across nodes, how to verify health after maintenance, and the failure cases that were tested. The test plan produces evidence that the setup behaves correctly when a node is removed mid-request and when two nodes handle writes to the same resources. Ask for that evidence in the proposal, and ask who retains the configuration, the runbook and the test scripts once the engagement closes.
How DeployOpen delivers HAPI FHIR high availability
DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside the client's own infrastructure. For a HAPI FHIR JPA server running as several instances behind a load balancer, the work starts with a written scope covering the shared database, per-node state, batch job placement and maintenance procedures. Engagements are fixed-scope, with deliverables and timelines agreed before work begins.
How we scope
- Inventory the current HAPI FHIR version, JDK version and deployment method before any design decisions
- Agree which database platform, backup approach and network path the shared database will use
- Record which in-memory features, subscriptions and scheduled jobs each node runs, and which must run once
- Confirm the maintenance window, rollback expectations and who approves changes in your environment
How we build
- Configure the load balancer, public server address and TLS termination so links and Bundle entries resolve correctly
- Set up multiple instances against one database and test session-independent behavior under load
- Verify subscription delivery, batch job handling and search results while individual nodes restart
- Test planned rolling upgrades and node removal against a non-production copy of your data
How we hand over
- Deliver a written architecture document covering node topology, database dependencies and failure assumptions
- Provide runbooks for adding nodes, draining nodes for maintenance and recovering from a failed instance
- Document the health check, monitoring and alerting settings used for each instance
- Walk your platform and operations teams through the runbooks and record their sign-off
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover
- Retainers can cover HAPI FHIR version upgrades, including schema migration and Java requirement changes
- Support can include periodic failover tests so high availability claims stay verified over time
- Ask any provider to confirm response times and coverage in writing before you sign

