Load testing a HAPI FHIR server before go-live

A load test shows whether your HAPI FHIR JPA server will hold up under real clinical and integration traffic before patients depend on it. This page covers workload design, database and JVM sizing, slow query analysis and capacity targets.

On this page

Load testing a HAPI FHIR server before go-live: what it proves and when to run it

Run a load test before a self-hosted HAPI FHIR JPA server takes real users or integration traffic, and treat its results as evidence about your own stack. The test answers one question: can this database, JVM and deployment handle the reads, searches and writes you expect, at the volumes and concurrency you plan for? The HAPI FHIR JPA server is a complete RESTful FHIR server backed by a relational database through the JPA API. The starter supports PostgreSQL and Microsoft SQL Server for production, and it does not support MySQL. Because the database engine, its settings, the JVM heap, the application server, the reverse proxy and the network path all shape the result, the test must run against your own environment. A vendor benchmark or the public demonstration server at hapi.fhir.org tells you nothing about your data shape or hardware.

Schedule the test at three points. The first is before go-live, once the production-like database is loaded with a realistic volume of resources and the deployment matches the target topology. The second is after any major HAPI FHIR upgrade, since the schema, search behavior and Java requirements can change, so confirm the release requirements in the HAPI FHIR versions documentation before you start. The third is after schema or index changes, including new search parameters or custom indexes, because a query that was fast on the old index can slow sharply on the new one. Re-run the same workload each time so the results can be compared directly. Confirm with your team what volume counts as production-like, because that figure depends on your own patient and encounter data.

A load test does not prove that the server is secure, that data is correct, or that every clinical workflow works. It does not cover search patterns you left out of the workload, failover behavior, backup and restore times, or the effect of batch jobs such as reindexing running during peak hours. It also does not replace validation of resources against profiles or a review of access control. Write these limits into the test report so stakeholders do not read a passing run as a general approval. Before you start, ask your team to confirm which failure criteria, response time targets and error rates define a pass, and who signs off on them.

How to build a realistic FHIR workload of reads, searches and writes

A load test is only as useful as the workload it generates. A generic mix of reads and searches, borrowed from a benchmark or a vendor example, tells you how the server behaves under someone else's traffic. The better starting point is evidence from the system you are about to run: access logs from the existing FHIR endpoint, audit records, API gateway metrics or, for a new build, the written list of applications and their expected calls per user session. Group requests by resource type, interaction, search parameters and time of day, then convert them into proportions per interaction. Peak windows matter as much as averages, because a morning clinical rush or a month-end batch can behave very differently from the daily mean.

  • Start from logs, not assumptions: Count requests by method, resource type and query shape over a representative period, including a known peak.
  • Keep the peak profile: Record the busiest five-minute windows separately so the test can reproduce burst concurrency.
  • Name each application: Assign each client application its own share of the mix, since a single EHR integration can dominate reads while a portal dominates searches.
  • Re-check after go-live: Compare the production mix at the first review with the test mix and adjust the next test run.
  • Document the assumptions: Record where each proportion came from so reviewers can challenge it.

Confirm with the application owners which interactions are planned but not yet live, because a test that omits them will understate the load the server must carry later.

Sizing the database and JVM under load

Capacity for a HAPI FHIR JPA server is set by a chain of components: the database, the connection pool, the JVM and the servlet container. A weakness in any one of them caps the whole server, so load tests should watch each layer rather than only response times at the front door. Use the results from your own runs, together with the documentation for your chosen JDK and database, to set each value.

Database CPU and memory

The JPA server pushes most of its work into the relational database, including search index lookups, joins for chained parameters and history queries. Track CPU saturation, buffer or cache hit ratios and query wait time during each stage of the test. If the database is CPU bound at a modest request rate, adding application instances will not raise throughput. Ask your DBA which database version and configuration your test targets, and whether the test environment matches production hardware.

Storage I/O and index size

Search-heavy workloads on large repositories depend on how fast the database reads index pages from storage. Measure read and write IOPS, latency percentiles and queue depth while running the mixed workload, not only during bulk loads. Write-heavy phases can also expose checkpoint or write-ahead log pressure, which shows up as latency spikes that look like application slowness. Confirm the storage class and the provisioned IOPS with your infrastructure team before you set targets.

Connection pool size

Each JPA transaction holds a database connection for its duration, so the pool size determines how many requests can hit the database at once. A pool that is too large sends more concurrent queries than the database can serve efficiently, while one that is too small makes requests queue inside the application. Watch pool wait time and active connection counts together with database-side session counts. Take the pool limits from your own test results and the connection limits documented for your database.

JVM heap and garbage collection

Large search result sets, resource parsing and validation allocate heavily, and garbage collection pauses add latency that appears in response time percentiles. Record heap occupancy after full collections, pause durations and allocation rate for each load level. A heap that is too small causes frequent collections under peak load, and an oversized heap can lengthen individual pauses. Confirm which garbage collector and JVM flags your chosen JDK supports, because HAPI FHIR 8.2.0 requires JDK 17 or later.

Servlet container thread pool

The servlet container limits how many HTTP requests run at once, and requests beyond that limit wait in an accept queue. Set the thread pool and queue sizes against the connection pool and the database limits, so the container does not admit more work than the layers below can process. Look for rising queue wait time, timeouts at the reverse proxy and threads blocked on database calls in thread dumps. Check the default settings of your container (Tomcat, Jetty or Wildfly) before you change them.

Load test tools and approaches, and when each fits

This table compares three common ways to generate load against a HAPI FHIR server, showing what each measures, how much setup it needs and where it fits in a go-live plan. Read it to pick an approach for each stage, then confirm each tool's capabilities in its own documentation before committing to it.

ApproachWhat it measuresSetup effortWhere it fits
Scripted HTTP load generatorRaw throughput and latency for the endpoints you script, such as reads by ID, searches with fixed parameters and transaction bundlesModerate: you write and maintain scripts, data generators and assertionsCapacity baselines, JVM and database tuning runs and repeatable regression checks after upgrades
FHIR-aware test harnessCorrect FHIR responses under load, including search parameter behavior, paging, bundle handling and resource validityModerate to high: resource fixtures and conformance checks must match your profiles and IGsFunctional confidence at volume, especially where your own profiles, search parameters or custom operations are in use
Replay of recorded production trafficBehavior under the real mix of request shapes, parameters and concurrency seen in your environmentHigh: capture, anonymize, filter and replay pipelines must be designed with privacy controls in placeFinal pre-go-live validation when a source system or migration is already live and traffic can be captured lawfully
Mixed approach with a scripted core and sampled replayBaseline capacity plus realistic query distribution for the most expensive searchesHigh: two workloads to build, run and keep in sync with the data setLarger deployments where one generator alone does not represent the expected usage pattern
Vendor or third-party load serviceDepends on the service and its scenarios, so confirm which FHIR operations it exercisesLow to moderate for setup, with cost and data handling terms to reviewOnly when the service documents its FHIR scenarios and accepts your test data and network constraints

Setup sequence for a HAPI FHIR load test

This sequence turns a load test from a single benchmark run into a repeatable process that produces a measured capacity figure, a list of slow queries and a clear record of which change moved which result. It is written for the team that will own the server after go-live.

  1. Confirm a production-equivalent environment

    Match the test stack to production: JDK 17 or later for HAPI FHIR 8.2.0 and later (per the HAPI FHIR versions documentation), the same database engine as production (PostgreSQL or Microsoft SQL Server, since the JPA starter does not support MySQL), the same deployment style (Docker image, Spring Boot, WAR on Tomcat, Jetty or Wildfly, or Kubernetes with the Helm chart), and comparable CPU, memory, storage class and network path. Record every version and setting in a configuration file so the environment can be rebuilt. The step is done when the team can show a side-by-side table of test and production settings with every difference explained. Do not use the embedded H2 default for any test that informs go-live.

  2. Load a representative dataset

    Populate the database with data shaped like production: the same resource types, the same ratio of patients to encounters and observations, realistic reference density and comparable row counts. Load through the same path clients will use, so indexes and search parameters are built the way they will be in production. Confirm the table sizes and index sizes in the database match the production profile within an agreed tolerance, and record the load time. The step is done when row counts per resource type are signed off by the data owner and a database snapshot exists so each test run starts from the same state. An empty database produces results that will not hold after go-live.

  3. Define the workload mix

    Turn expected production traffic into a written workload model: the share of reads by resource ID, searches with their parameters, chained searches, history requests, and writes such as creates, updates and transactions. Take the mix from access logs of the system being replaced, or from the business owners if no logs exist, and state the assumption where data is missing. Define the think time and the user or client count per scenario. The step is done when the scenario list, percentages and parameter sets are reviewed by the application owner and stored with the test scripts. Scripts that only hit one endpoint measure that endpoint, not the server.

  4. Run a baseline test at low load

    Execute the workload at a low, steady load to establish reference latency and error rates for each scenario. Use the same client tooling and data snapshot on every run. Record response time percentiles, error counts, and the server response to each request type. The step is done when two consecutive baseline runs agree closely enough that the team trusts them as a reference. If they do not agree, fix test noise (client machine limits, cold caches, shared hosts) before going further.

  5. Ramp the load and capture server signals

    Increase concurrent load in stages until latency targets break or errors appear. During each stage, capture database slow query logs (PostgreSQL log_min_duration_statement or the SQL Server equivalent), JVM heap, garbage collection pauses, thread pool saturation and connection pool wait times. Expose metrics through the monitoring stack already planned for production. The step is done when the team has a stage-by-stage table linking load level to latency, errors and resource use, and a set of ranked slow queries with their execution plans.

  6. Identify the bottleneck and its owner

    Use the captured evidence to decide which layer limits throughput: database query plans, missing or unused indexes, connection pool size, JVM memory or garbage collection, the application server thread pool, the reverse proxy, or the client. Assign each finding to an owner. Confirm the diagnosis with a second signal, such as a query plan or a GC log, before deciding on a fix. The step is done when each bottleneck has a written cause, an owner and the evidence that supports it.

  7. Change one variable and retest

    Apply a single change at a time, such as one index, one pool size, one heap setting or one search cache setting, then repeat the same ramp test on the same data snapshot. Compare against the previous result, not against memory. Keep changes that improve the target and revert those that do not. The step is done when each change has a before and after result in the test log and the final configuration is recorded in version control.

  8. Set capacity targets from measured results

    Convert the stable results into capacity targets: the sustained request rate and concurrent user count that meet the latency and error goals, the headroom kept below that point, and the database and JVM sizes that produced it. State which workload mix and dataset size the targets apply to, so the figures are not applied to a different system. Name the tests that must be repeated after go-live, such as after a HAPI FHIR upgrade or a large bulk load. The step is done when the targets are approved by the service owner and attached to the go-live record.

How the load generator, HAPI FHIR server and database fit together

The test starts on a load generator host outside the server network, which sends FHIR requests through a reverse proxy or ingress into one or more HAPI FHIR JPA server instances. Those instances read and write the relational database, which is the component most often under pressure. Metrics from the servers, the database and the proxy flow to a collector that stays inside the test environment. Before running, confirm that the test environment matches production-like infrastructure in JVM settings, database size, proxy behavior and authentication, and that no traffic reaches a live patient data store.

Load generator, proxy, JPA server instances, database and metrics path in the test environment.

Finding slow queries and tracing them to search parameters

The purpose of this step is to connect each slow request in the load test to the database statements it produces, so the team knows which search parameter, chain or count is responsible. Start with the request timings from the test tool, sorted by 95th or 99th percentile latency per operation, then pick the slowest few operations and capture the exact FHIR URLs they used. Keep the request mix from the workload model open alongside the results, because a slow search that runs once per hundred requests matters less than a moderately slow one that runs on every page load.

Next, pull the database side of the same window. Most PostgreSQL deployments can use the pg_stat_statements extension to rank statements by total and mean execution time, and SQL Server offers equivalent query store or DMV views. Confirm with your DBA which of these is enabled in the test environment before the run, since enabling it afterward leaves a gap in the data. In the HAPI FHIR server, enable SQL logging or the JPA query trace for the test window only, and correlate the statements to requests through the request ID or timestamps in the server log. The goal is a short list where each slow FHIR URL maps to one or two SQL statements that touch the search index tables.

Common hotspots are predictable. Searches on poorly selective or unindexed parameters, chained searches that join through several reference tables, and _total=accurate or other _history counts that scan large version tables often dominate the top of the list. Record each hotspot with the parameter, the resource type and the data volume it ran against, then decide whether the fix belongs to the search cache, the history count mode or the chained search design. Those fixes are covered in the sibling topics on HAPI FHIR search caching and paging, history count mode and chained searches, so this step ends with a ranked list of findings, not a tuned configuration.

Setting capacity targets from test results

Which latency percentiles should I set as capacity targets for a FHIR server?

Set targets on percentiles, not averages, and separate them by operation type: reads by id, simple searches, chained or complex searches, transaction bundles and history requests behave differently and should each have their own target. Most teams set a median target for typical behavior and a high percentile, such as the 95th or 99th, for the slow tail that users actually notice. The right numbers come from your own service-level expectations, meaning what clinical and integration users need and what downstream systems time out after. Ask your application owners and integration partners for those thresholds before the test, then check each operation against them in the results.

What error rate should be acceptable during a load test?

Define the acceptable error rate per operation before the test, and treat any server-side error (HTTP 5xx), timeout or database connection failure as a hard finding rather than noise. Client-side 4xx responses, such as invalid search parameters or unauthorized calls that your test deliberately includes, should be counted separately so they do not hide real failures. A useful target usually states that the error rate stays flat as load rises, since errors that appear only above a certain throughput often signal pool exhaustion or lock contention. Set the figure from your own tolerance for failed requests and retry behavior in calling systems.

How do I turn production forecasts into a peak throughput target?

Start from production logs or a forecast of requests per second at the busiest hour, then multiply by the factor you expect at the worst moment, such as a month-end batch window, a mass patient registration or an integration backfill. Break the total into the same operation mix you used to build the workload, because a target of 200 requests per second means little if it is all cheap reads when your real traffic includes heavy searches. Record the source of each input: the log period, the systems generating traffic and any planned growth. Ask your integration owners which bulk or scheduled jobs will run alongside interactive traffic, since they often set the real peak.

How much headroom should a HAPI FHIR server keep above peak load?

Headroom is the gap between your peak target and the load at which latency or errors first break your thresholds, and it should be measured in the test rather than guessed. Teams commonly plan to run comfortably below the saturation point, leaving room for traffic growth, a node failure that shifts load to fewer instances, and background jobs such as reindexing. The size of that margin is a business decision: a server that supports a national program may need more room than an internal tool. Verify headroom under the failure scenarios you plan to support, such as one application node down, and ask your team to confirm the margin they will accept before go-live.

How should I record the capacity target together with the configuration that produced it?

Store each target next to a versioned record of the test conditions, so a later result can be compared like for like. The record should include the HAPI FHIR version and JDK, the JPA server starter build, database engine and version with its instance size, connection pool and thread settings, JVM heap and garbage collector options, the dataset size and resource mix, the workload scenario file, and the load generator location. Keep the raw results and dashboards from the run, not only a summary. When any of these change, such as a HAPI FHIR upgrade or a new partition setup, rerun the affected scenarios and update the record instead of assuming the old target still holds.

Can my own team set and maintain these capacity targets, or do we need a partner?

Your team can set and maintain targets if it owns the service-level expectations, has someone who can build realistic workloads, and can read database and JVM metrics together. The effort is often underestimated in the repeat work: each HAPI FHIR upgrade, schema change or data growth milestone needs the scenarios rerun and the record updated. A partner can take on the workload design, test execution and tuning as a fixed-scope engagement with written deliverables, then hand over the scenarios and record for your team to run. DeployOpen plans and implements self-hosted open-source platforms inside your own infrastructure, and ongoing testing is available as a retainer if you want recurring checks.

What drives the cost and duration of setting capacity targets?

The main drivers are the number of operations and resource types in scope, how many environments must match production, the size of the dataset you need to reproduce, and how many tuning cycles the results require. Each test cycle costs time for setup, run, analysis and retest, so a server with many slow query paths takes more rounds than one with few. Ask any provider for a quote that lists the scenarios, environments, dataset size, number of test cycles and deliverables, and whether retesting after tuning is included. The most reliable way to compare quotes is to agree the written scope first, since the price follows from it.

Security and data handling during load tests

A load test sends real protocol traffic at a server that may hold health data, and it produces logs and traces full of request content. The cards below cover the decisions that keep that test from becoming a privacy incident. They also cover the one point that is easy to miss: the security settings you test must match production.

Use synthetic patient data

Load tests need volume and realistic shape, not real patients. Generate synthetic Patient, Encounter, Observation and related resources that reproduce reference density, code diversity and payload size seen in production. Do not copy production rows into the test database, even temporarily, because restores and snapshots tend to outlive the test. Ask whether the generator's output has been reviewed for accidental re-identification by people who know the source data.

Test with the production security configuration

HAPI FHIR does not provide a single security layer. Authentication, the AuthorizationInterceptor, consent and search narrowing interceptors, CORS and BALP audit logging are building blocks you assemble. Interceptors add work to every request, and a test run without them measures a different server. Run the load test with the same identity provider integration, authorization rules and audit settings as production, and confirm that token validation and permission checks are included in the measured path.

HAPI FHIR security docs

Manage test accounts and credentials

Load generators need tokens or client credentials, and these are often hard-coded in scripts or shared across a team. Create dedicated test clients with the minimum scopes the workload needs, and issue short-lived tokens where the identity provider allows it. Store secrets in your vault, not in the test repository, and revoke all test identities when the run ends. Confirm that tokens for the test tenant cannot be used against production endpoints.

Isolate the test environment

A test environment that shares a database, message queue, network segment or DNS name with production can corrupt live data or pull real traffic into a load run. Use a separate database instance, separate storage and separate endpoints, with egress rules that stop test components from reaching production systems. Check that outbound integrations, such as terminology or subscription targets, point at stubs or sandboxes during the run.

Control logs and traces with request content

Access logs, debug logs, tracing spans and audit records can hold query parameters, identifiers and resource bodies. Decide before the run what the server and collectors will record, and reduce payload logging to what the test needs. Restrict who can read these stores, set a retention period that matches your policy, and delete test-run telemetry on a schedule. Check that BALP audit output from the test is handled under the same rules as production audit data.

Destroy test data after the run

Test databases, object storage snapshots, exported bulk files and copied logs all persist after the load test ends. Write a teardown step that drops the synthetic dataset, removes exports and clears caches, then confirm the removal in the database and storage consoles. Keep the generator and its seed values so the dataset can be rebuilt, but do not keep the populated database as a reference copy.

What does a HAPI FHIR load test cost and how long does it take?

What drives the cost of a HAPI FHIR load test?

The cost follows the scope in the written statement of work: how complex the workload model is, how large the dataset is, how many environments are involved, how deep the query analysis goes, and how many retest cycles are included. A workload built from a few read and search patterns costs less to design than one that replays weeks of production traffic across several resource types and search parameter combinations. Dataset size matters because generating and loading realistic data takes engineering time and test infrastructure. Each environment you ask us to test adds setup and verification work. Query analysis that stops at finding slow endpoints is shorter than analysis that traces slow SQL in PostgreSQL or Microsoft SQL Server and recommends index changes. Retesting after fixes is usually the item that changes the total most, so ask for it to be priced separately. Ask every bidder to state these items explicitly so quotes can be compared.

Can our own team run a HAPI FHIR load test internally?

Yes, if you have engineers who can build a realistic workload, operate the load generator, and read database and JVM metrics. Many teams do this in-house for a first pass. The work that tends to take the longest is not running the test but preparing it: exporting representative request patterns from production logs, creating a dataset whose size and reference structure resemble your real data, and agreeing on pass criteria with the application owners. Internal teams also need an isolated environment that matches production closely enough for results to mean something. A partner adds value when you need an independent view before a regulator, an acquirer or a go-live board, when your team lacks database tuning experience, or when the same people who built the server would otherwise grade their own results. Compare the cost of your engineers' time against the cost of a partner using the same scope document.

What do we need to provide for a HAPI FHIR load test?

The test depends on information and access that only your organization holds. Expect to provide the following before work starts:

How long does a HAPI FHIR load test take?

The duration depends on the scope and on how quickly access and information arrive, not on a fixed template. A written scope should show the phases separately: discovery and workload design, environment and dataset preparation, test execution, analysis, fixes and retesting. Discovery is often the longest phase when production usage data is not readily available, because the workload model cannot be built without it. Environment readiness is the most common source of delay, particularly for database access, network routes to the load generator and approval for test windows. Each retest cycle repeats execution and analysis, so the number of planned cycles should be stated in advance. Ask for a timeline with dependencies marked, and ask which milestones depend on your team's responses.

Which costs are one-time and which recur after go-live?

The core load test is a one-time engagement tied to a release or a capacity change. Recurring costs appear in several places: the test environment that must stay available between runs, any licensed load-generation tooling you choose, and the staff time needed to repeat tests after upgrades, schema changes or significant growth in data volume. Capacity targets set during the test also need periodic review as usage grows. If you want the test repeated for each release, ask whether that is a separate fixed-scope engagement or part of an ongoing retainer. DeployOpen offers ongoing support, upgrades and continuous testing as retainers, so ask for those terms in writing rather than assuming they are included.

What should we ask for in a written load testing scope?

A useful scope names the deliverables, the environments, the workload model, and the acceptance criteria. Ask for the following in writing:

Does load testing HAPI FHIR also test security?

No, a standard load test measures throughput, latency, resource use and error behavior under load. It does not establish whether authorization, consent or audit controls work correctly. HAPI FHIR provides building blocks for these controls, but it does not supply a complete security layer, so you need to configure and verify them separately. If you want security checks alongside performance work, ask for them as a separate line in the scope, because the test data, accounts and acceptance criteria differ. Confirm with your compliance team which evidence they expect before the test starts.

How DeployOpen scopes and delivers HAPI FHIR load testing

DeployOpen approaches load testing of a HAPI FHIR JPA server as a written, fixed-scope engagement. We agree the workload, the environment and the capacity targets before any test runs, then build the test harness, run it against your infrastructure and hand over the results with the tuning changes that follow from them.

How we scope

  • Agree in writing which FHIR resource types, search parameters and interactions the test workload covers
  • Confirm the target FHIR version and whether the test runs against a PostgreSQL or Microsoft SQL Server database
  • Define capacity targets for response times, throughput and concurrency with your application and operations owners

How we build

  • Build a repeatable workload of reads, searches and writes from anonymized or synthetic data shaped like your production volumes
  • Run the test against a staging environment in your cloud account, data center or air-gapped network with matching JVM and database sizing
  • Capture slow query plans, JVM heap and garbage collection behavior, and database connection usage during each test run

How we hand over

  • Deliver a written report with the scenarios run, measured results against the agreed targets and the bottlenecks found
  • Document the database, JVM and HAPI FHIR configuration used, so your team can repeat the tests after changes
  • Provide the test scripts and the step-by-step run procedure, with a retest after the agreed fixes are applied

How we support

  • Engagements are fixed-scope, so your team knows the deliverables and the decision points before work begins
  • Ongoing support, periodic regression load testing and upgrade testing are available as retainers
  • Confirm with us which environment changes, data loads and maintenance windows your organization must approve before testing

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.