How to scale HAPI FHIR for national and regional health data volumes
Scaling a self-hosted HAPI FHIR repository for national or regional data volumes is a set of design choices, not a single configuration setting. The main choices are how data is partitioned, which relational database and storage layout sit underneath, how search and history results are cached, whether read replicas serve query traffic, and how heavy batch work is scheduled so it does not compete with clinical use. A program should start this design work when it expects the repository to hold very large resource counts across several regions, organizations or data sources, because decisions about partitioning and database layout are hard to reverse once data is loaded. The HAPI FHIR JPA server introduction describes a complete RESTful FHIR server backed by a database through the JPA API, and its documentation covers FHIR DSTU2, DSTU3, R4, R4B and R5, plus terminology services, validation, MDM and partitioning. That breadth means the program must choose which FHIR versions, modules and storage model it will actually operate.
The most consequential early decision is partitioning. According to the HAPI FHIR JPA partitioning documentation, partitioning places each resource in a partition, which can serve multitenancy, separate data sources or group data by region. A regional program should decide before go-live whether regions, data providers or purposes map to partitions, and who owns the mapping rules. Confirm with the HAPI FHIR documentation for your release how partition mode interacts with the database schema, search behavior and reindexing, because changing it later usually means a migration rather than a setting change. The database choice also matters: the JPA server starter supports PostgreSQL and Microsoft SQL Server for production and does not support MySQL, so the storage platform, backup approach and staff skills should be settled in the same review.
Caching, replicas and batch work come next. Search caching trades result freshness for database load, so the program should set cache behavior with clinical users in the room. Read replicas can absorb query traffic, but the team must confirm how the HAPI FHIR version in use handles replica routing and how replication lag affects users. Batch jobs such as reindexing, export and expunge can run for long periods, so they should be scheduled away from peak hours and sized for the database. Ask your delivery partner or a load test to show the expected behavior at your planned volume before you commit to a design.
Scaling options and when each fits
This table compares five levers for growing a HAPI FHIR JPA server beyond a single-database setup: partition mode, index storage, search cache tuning, read replicas and batch scheduling. Read each row as a question of which problem you have, which configuration area it touches and what you must test before committing. The main takeaway is that partitioning changes data layout and is hard to reverse, so it should be decided first, while the other levers can usually be adjusted later.
| Option | Problem it addresses | Trade-off | Confirm before choosing |
|---|---|---|---|
| Partition mode | Separating data by region, tenant or source in one server, as described in HAPI FHIR partitioning | Resources are placed in partitions, which adds design work for query scope, access rules and data movement between regions | Which partition key matches your regional or tenant model, and how cross-partition searches behave in your HAPI FHIR version |
| Index storage optimization | Keeping search index tables and their storage growing in proportion to data volume | Index choices speed some searches and add write cost and storage; indexes should follow measured query patterns | Which search parameters your clients use most, and which indexes your database version and schema support in a test environment |
| Search cache tuning | Reducing repeated database work for common searches and paging across large result sets | Cached results can be stale, so a longer cache lowers database load while showing older data to clients | Acceptable staleness for each client group, and the cache timeout and per-request cache control options in your release |
| Read replicas | Spreading read-heavy search and read traffic away from the primary write database | Replicas add infrastructure, replication lag and routing logic, and the server must be configured to send reads to them | Whether your HAPI FHIR version and deployment route reads to replicas, and how lag affects clinical workflows |
| Batch scheduling | Keeping heavy jobs such as reindexing, export and expunge from competing with daytime clinical traffic | Jobs compete for database and JVM capacity, and long runs need monitoring, recovery planning and a maintenance window | Which batch2 jobs your volumes require, how they recover after failure, and how many instances can run them safely |
Choosing the database for very large repositories
The database behind a HAPI FHIR JPA server sets the limits for storage growth, backups and high availability. The starter supports PostgreSQL and Microsoft SQL Server for production, so the choice between them should be made early, with the replica and recovery design in view.
Supported production databases only
The starter documentation names PostgreSQL and Microsoft SQL Server for production. MySQL is not supported, and the embedded H2 default is meant for evaluation, not for a national or regional repository. Confirm the exact database versions your chosen HAPI FHIR release supports before you size hardware, since version support changes between releases. Treat the database platform as a fixed input to the rest of the design.
Starter repositoryStorage sizing for resource growth
Storage needs grow with stored resources, their versions, search parameter indexes and audit or provenance data. Each write adds rows to several tables, so growth is not linear with resource count. Ask your team to measure storage per thousand representative resources in a test load, then project from the volumes your programs expect. Plan for free space headroom so that large reindexing or export jobs do not stall the database.
Index growth and maintenance
Search index tables often become the largest part of the database as the number of search parameters and stored values increases. Index size affects vacuum or maintenance windows on PostgreSQL and rebuild or statistics jobs on SQL Server. Confirm how index maintenance will run during business hours, and whether reindexing jobs can be scheduled to avoid peak load. Review index choices against the queries your applications actually send.
Backup windows and restore time
Backup duration and restore time scale with database size, so a repository that is large enough to need partitioning may also need a backup design that avoids long full backups during the day. Define your recovery point and recovery time targets, then test a full restore to a separate environment. Record how long a restore takes, because that figure, not the backup job's success, is what your recovery plan depends on.
Replicas and high availability constraints
The database platform determines which replication, failover and read-scaling patterns are available to your team. Read replicas for search traffic need a replication setup that your HAPI FHIR configuration and your application's consistency needs can tolerate. Check how your platform handles failover, and confirm with the vendor and your HAPI FHIR version whether the server behaves correctly against a replica before you route search traffic there.
Operating cost and skills
Database licensing, managed service fees and specialist time are cost components that differ between PostgreSQL and SQL Server. Self-hosted PostgreSQL moves platform work to your team, while SQL Server typically brings license terms that your procurement team must review. Ask any partner for a quote that separates one-time setup from recurring database administration, backup storage and monitoring, and state which of these your team will own.
How the scaling components fit together
The diagram starts with clients sending FHIR requests through a reverse proxy to several HAPI FHIR JPA server instances, all inside the client's own infrastructure. The servers write to a primary database and read from replicas, and partition routing decides which partition a resource is placed in. A cache layer sits in front of search, while batch jobs run on the same servers and touch the database heavily. Check where the trust boundary sits, which database role each instance uses, and whether your replication setup supports the read pattern you plan to use.
Request, data and batch paths for a self-hosted HAPI FHIR JPA deployment.
Sequence for designing and standing up the large-scale server
This sequence moves a regional HAPI FHIR deployment from data-sharing decisions to a load-tested server, with a check at each step so that scale decisions are made before data arrives rather than after.
Define the partition model and data-sharing rules
Decide whether the repository needs one shared partition, partitions for regions or organizations, or separate servers per data owner. Record which resources may be read across partitions, who approves cross-partition access, and how consent and legal boundaries map to partitions. The HAPI FHIR partitioning documentation describes partitions as useful for multitenancy, separating data sources or grouping data by region, so the choice should follow your governance model. Done when a signed data-sharing matrix lists each partition, its owners and its permitted readers, and the security team has reviewed it.
Select and validate the production database
Choose PostgreSQL or Microsoft SQL Server, the two databases the JPA server starter supports for production, and confirm the version against the HAPI FHIR version you plan to run. Your database team should own backups, high availability and the connection budget. Confirm the version and JDK requirements against the HAPI FHIR versions page before procurement, since HAPI FHIR 8.2.0 requires JDK 17. Done when the database platform, version and operating model are documented and a restore from backup has been demonstrated in a non-production environment.
Size storage and indexes for projected volume
Estimate resource counts per type, average resource size, history retention and the search parameters clinical teams will use most. Plan storage for both current and historical versions, plus index overhead, and decide which search parameters need indexing before data loads. Ask your DBA to set tablespace layout, autovacuum or maintenance windows and monitoring thresholds. Done when a sizing worksheet has been reviewed against a sample load, and the team can explain how each index supports a named query.
Deploy the starter on your chosen runtime
Deploy the hapi-fhir-jpaserver-starter using the option your platform team operates: the hapiproject/hapi Docker image with Docker Compose, Spring Boot, a WAR on Tomcat, Jetty or Wildfly, or Kubernetes with the Helm chart. Configure the datasource to the production database, enable partitioning settings that match step one, and place a reverse proxy in front for TLS and health checks. Done when the server starts against the production database schema, passes health checks behind the proxy, and a smoke test creates, reads and searches resources in each partition.
Configure search caching and history behavior
Set the search cache timeout, paging and max-results limits, and decide how _history totals are returned on large tables. Clinical users need fresh results for some queries and tolerate staleness for others, so document which query types may be cached and for how long. Review history count behavior with the data owners before go-live. Done when the configuration is stored in version control, each setting has a documented owner and rationale, and test queries show the expected cached and uncached behavior.
Plan read replica routing
Decide which read traffic, such as bulk export, reporting and heavy search, can go to replicas, and how the application tells reads from writes. Confirm that the replica lag your users can accept is documented, and that writes and reads that need read-after-write consistency go to the primary. Confirm replication and routing support with your chosen database and deployment approach before relying on it. Done when a routing diagram exists, lag thresholds are agreed, and a failover test shows reads and writes routing correctly.
Schedule batch jobs away from peak hours
Plan reindexing, export and expunge jobs, which run through the batch2 framework, and assign them to windows outside clinical peaks. Decide how many instances will run jobs, how job progress will be monitored and who can start or cancel heavy jobs. Done when a written schedule exists, job monitoring alerts are configured, and a test reindex has completed on a copy of the data without degrading interactive traffic.
Run load tests before go-live
Build a realistic workload of reads, searches and writes from the captured usage patterns, then size the database and JVM against it. Use the results to find slow queries, adjust indexes and set capacity targets. Repeat the test after each significant configuration change. Done when the test report lists throughput and latency targets, the slow queries have been addressed or accepted, and the operations team has signed off the capacity limits in writing.
How the design differs by deployment environment
Docker Compose suits a single host or a small set of hosts that you manage directly. It runs the hapiproject/hapi image alongside your database and reverse proxy in one declared stack, which makes the first environment quick to reproduce. Its limits show up at scale: Compose has no built-in scheduler for spreading replicas across machines, so horizontal scaling means managing additional hosts and a load balancer yourself.
- Horizontal scaling: Adding JPA server instances is manual. Plan the host count, the load balancer and session behavior before go-live.
- Configuration management: Settings live in the Compose file and environment files. Keep them in version control and keep database credentials out of the file itself.
- Batch and read placement: Every container shares the same host resources, so a reindexing job can starve interactive traffic unless you pin it to a separate instance or schedule it away from peak hours.
- Database: Run PostgreSQL or Microsoft SQL Server outside the stack for production, not the embedded H2 default.
- Recovery: Restarting a failed container is simple, but you must script host rebuilds and database restores yourself.
Confirm the image tag, the starter's supported database settings and the Compose version against the release you plan to run.
The Helm chart is one of the supported starter paths named in the project sources, and it fits organizations that already operate Kubernetes. Deployments, services and configuration map onto Kubernetes objects, so replica counts, rolling updates and health probes are managed by the cluster. The trade-off is operational weight: you own the cluster, the ingress, the storage classes and the database operator or managed database connection.
- Horizontal scaling: Increase replicas in the Helm values, provided the database and any shared state can serve multiple instances concurrently. Test this before relying on it.
- Configuration management: Store values files in Git, keep secrets in your secret store and review chart changes like any other release.
- Batch and read placement: Node pools, taints and resource limits let you isolate batch jobs or dedicated read traffic on separate pods, but only if you configure them deliberately.
- Upgrades: Chart versions and server versions move together, so check the chart's values changes against the upgrade notes for your target release.
- Health checks: Liveness and readiness probes need thresholds that tolerate long-running startup and index work.
Confirm the chart version, the supported Kubernetes versions and the exact value keys for the release you deploy, since these change between versions.
Deploying the starter as a WAR into Tomcat, Jetty or Wildfly suits organizations with an established application server estate and operating procedures built around it. The application server handles thread pools, connection settings and deployment, while you manage the JVM, the database connection pool and the reverse proxy. The JDK requirement is a planning input: HAPI FHIR 8.2.0 requires JDK 17, so confirm the version your target release needs.
- Horizontal scaling: Each node runs a separate deployment behind a load balancer. The application server does not scale the service for you.
- Configuration management: Externalize settings through server-level properties or environment variables, so the WAR stays identical across environments.
- Batch and read placement: Use separate server nodes or a distinct deployment for heavy jobs, and keep the connection pool sized so batch work does not exhaust connections needed by reads.
- Connection pools: Size the JDBC pool on each node and multiply by node count when calculating database connection totals.
- Operations: Your team must track application server patches alongside HAPI FHIR and JDK updates.
Confirm the supported application server versions and JDK requirement for the release you choose before you size the estate.
Security and operational risks at scale
HAPI FHIR gives you building blocks for security, not a finished control layer, so every risk below is one you must design for. At national or regional volumes, partition boundaries, audit trails and copies of the data all have to carry the same protections as the live server.
No single security layer
HAPI FHIR states that it does not provide one turnkey security layer. Authorization, consent, search narrowing, CORS and audit logging are interceptors and building blocks you assemble and configure. Before go-live, map each regulatory and internal requirement to a specific interceptor or external control, and test the combined behavior rather than assuming each piece covers the others. Confirm the configuration against the current HAPI FHIR security documentation for your release.
HAPI FHIR security docsAuthorization interceptor rules
The AuthorizationInterceptor decides which operations and resources each caller can reach. Rules must be written for every resource type, search, history, bulk operation and batch request, because a rule that covers reads alone leaves writes and exports open. Test denial paths as thoroughly as allowed ones, and confirm that rules still apply when requests arrive through a reverse proxy or gateway.
Partition boundaries enforced by access control
Partitions separate data by tenant, source or region, but a partition is only a storage and routing boundary. If the identity a caller presents is not mapped to a permitted partition, one region's users can read another region's records. Define the mapping between identity provider groups and partitions, and run cross-partition tests with accounts from each region to prove the boundary holds under search, includes and chained queries.
Partitioning docsConsent and search narrowing
Consent and search narrowing interceptors limit what a caller sees within a resource type, for example by patient, care relationship or data category. These rules run on every search, so their cost grows with data volume, and a missing narrowing rule can expose records through a broad query. Ask which query shapes the rules cover, and include paging, _include and chained searches in your test set.
Audit volume grows with data
BALP audit logging records access events, and at national scale the number of events grows with reads, searches and exports, not only with stored records. Plan where audit events are stored, how long they are kept, how they are indexed for investigations, and who can read them. Estimate event volume from your own load tests, and confirm retention periods with your legal and compliance teams before choosing storage.
Backups and replicas under the same controls
Backups, restored copies and read replicas hold the same protected health data as the primary database, so they need the same encryption, access rules, partition scoping and retention. A restore into a test environment with looser access is a common source of exposure. Document who can take and restore backups, where copies are stored, how a restore is verified, and how deleted or expunged data is removed from replicas and older backups.
Questions buyers ask before scaling a FHIR repository
What drives the cost and effort of scaling a HAPI FHIR server?
Scope drives most of the cost: how many resource types, how much history you keep, how many regions or tenants share the server, and how heavy your search workload is. The main cost components are the design work (partition strategy, database sizing, caching and batch schedules), the build and configuration, the load testing that proves the design, and the handover to your operators. Recurring costs come from running the database, storage growth, backups, upgrades and support. Ask any quote to separate one-time design and build work from ongoing support, and to state which environments, data volumes and load targets it assumes.
How long does the design phase take for a national or regional FHIR repository?
The design phase length depends on scope, not on a fixed rule. The timing is shaped by how many regions or tenants need partitioning, how many systems will read and write, how much existing data must be loaded, and how many compliance reviews must sign off on the design. Ask for a written plan with named phases, the decisions each phase must close, and the reviews that gate it. DeployOpen agrees timelines in writing before work starts, so the plan you receive will tie any duration to the scope you approve.
What must our team provide before a scaling engagement starts?
Plan to supply the inputs that the design depends on. These usually include:
- Expected resource counts, growth rates and history retention by resource type
- The regions, legal entities or tenants that will be separated or grouped
- Access rules, consent requirements and which identity provider users sign in with
- The infrastructure you run: cloud accounts, data centers or air-gapped networks, database platform (PostgreSQL or Microsoft SQL Server), and Java runtime, with HAPI FHIR 8.2.0 requiring JDK 17 or later
- Current search, read and write patterns, plus any bulk load or export jobs
Missing inputs usually turn into rework later, so confirm them before the scope is fixed.
Can our internal team scale HAPI FHIR without a partner?
Yes, if your team has Java, database and Kubernetes or application server experience, and time to test the design under realistic load. HAPI FHIR is Apache Software License 2.0 licensed, so the software itself carries no license fee, but the work of partitioning, index planning, cache tuning, batch job scheduling and load testing is specialized. Teams that go alone should budget for a load test, a failure-mode review and a documented runbook. Check whether the people who design the system are also the people who will operate it at 2 a.m.
When is it worth bringing in an implementation partner?
A partner is worth considering when the decision is hard to reverse, when your team lacks recent large-scale FHIR experience, or when a regulator or internal review will ask for evidence of the design. Partition mode, database layout and batch job strategy are costly to change after production data arrives. A partner can run the design review, build the environment in your infrastructure, run load tests and hand over documentation and runbooks. DeployOpen plans, implements, hardens, backs up, documents and supports self-hosted platforms in infrastructure you control, and prepares evidence for compliance assessments without issuing audit reports.
How do we ask for a fixed-scope quote for this work?
Send a written scope request that lists the regions or tenants, expected data volumes, the systems that will connect, the environments you need (development, test, production, disaster recovery), the compliance evidence you must produce, and the operating model after go-live. Ask the provider to return deliverables, a timeline, assumptions, exclusions and the responsibilities of your team. DeployOpen works from a written scope, so a quote follows from the agreed deliverables, and it does not publish a price list. Compare quotes on the same assumptions, and ask what happens if the data volumes differ from the plan.
What are the main risks of scaling a HAPI FHIR repository too late?
The main risk is that a repository grows past the design it was built for. Slow searches, expensive history totals, long batch jobs that compete with clinical traffic, and database storage that grows faster than planned all tend to appear together. Recovery is harder once production data sits in a layout that no longer fits. Ask for a load test against your projected volumes before go-live, a capacity review on a fixed schedule, and a tested backup and restore procedure for the database.
What to decide before loading the first record
The choices that are most expensive to change later are the partition strategy, the database platform, the FHIR version and the way batch and read traffic are separated. Make these before the first bulk load, because each one shapes how data is written, indexed and queried. HAPI FHIR JPA partitioning places each resource in a partition, which can serve multitenancy, separate data sources or group data by region. Decide whether your national or regional repository needs partitions at all, which resource types or tenants belong in each, and how a partition is chosen at write time. Retrofitting partitions onto a loaded repository is a migration project, not a configuration change, and it will consume a full copy and verification cycle of the data.
The database platform is the second decision. The JPA starter supports PostgreSQL and Microsoft SQL Server for production and does not support MySQL, so the choice narrows to the engines your operations team can back up, restore, patch and tune. Confirm the exact database versions and the HAPI FHIR release you intend to run against the current HAPI FHIR versions page, including the JDK requirement, since HAPI FHIR 8.2.0 requires JDK 17. Also fix the FHIR version (DSTU2, DSTU3, R4, R4B or R5) early, because the resource profiles, search parameters and any implementation guide packages you load depend on it, and changing versions later means reloading and revalidating data.
Finally, decide how batch workloads such as bulk loads, reindexing and export will be separated from interactive reads and writes. Batch jobs compete with clinical or citizen-facing traffic for database connections, I/O and CPU, so plan for dedicated job-running instances or scheduled windows, and confirm how many instances will run batch processing. Treat these decisions as hypotheses until you test them. Build a realistic workload of reads, searches and writes that mirrors your expected profile, then measure partition behavior, query plans and throughput on a copy of your target database. Ask your team to document the results and the decision each one supports before the first production record is loaded.
How DeployOpen scopes and delivers large-scale HAPI FHIR deployments
DeployOpen plans and implements self-hosted HAPI FHIR JPA servers inside your own cloud accounts, data centers or air-gapped networks. For national and regional data volumes, we start by agreeing in writing which partitioning, database, caching and batch choices apply to your data, then build and document them so your own teams can run the result.
How we scope
- Engagements are fixed-scope, with the scope, deliverables and timeline agreed in writing before work starts.
- The written scope lists the expected record volumes, partition strategy, database platform and whether PostgreSQL or Microsoft SQL Server is in use.
- We confirm which search, history and bulk workloads your clients run, so caching and batch decisions rest on real traffic.
- Scope also records who owns the database, the Java runtime and the backup and recovery process after handover.
How we build
- We deploy the JPA server starter in your environment, using the Docker, Kubernetes, Tomcat or Spring Boot route your team already operates.
- Partition mode, search cache settings and index storage are configured and documented against the workloads defined in scope.
- Bulk loading, reindexing and export jobs are scheduled and tested in a non-production environment before they touch live data.
- Security building blocks such as the AuthorizationInterceptor, audit logging and identity provider integration are included where the scope requires them.
How we hand over
- You receive configuration, architecture notes and runbooks covering partitions, database settings, cache behavior and batch job schedules.
- Load and failover test results are documented so your team can compare future changes against a known baseline.
- Knowledge transfer sessions cover day-two tasks such as monitoring batch jobs, reviewing slow queries and planning HAPI FHIR upgrades.
- Evidence for compliance assessments is prepared as documentation and configuration records. Independent auditors issue any audit reports or certifications.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Upgrade work follows the version-by-version path, including schema migrations and Java requirements, tested before production rollout.
- Security testing of the deployed server, including its APIs and access controls, can be scoped separately from the implementation.
- Ask for a written quote based on your scope. DeployOpen does not publish a price list.

