|
| 1 | +--- |
| 2 | +title: FHIR service best practices |
| 3 | +description: Best practices for higher performance in FHIR service |
| 4 | +services: healthcare-apis |
| 5 | +author: expekesheth |
| 6 | +ms.service: azure-health-data-services |
| 7 | +ms.subservice: fhir |
| 8 | +ms.topic: conceptual |
| 9 | +ms.date: 10/01/2024 |
| 10 | +ms.author: kesheth |
| 11 | +--- |
| 12 | + |
| 13 | +# Best practices for better performance in FHIR service |
| 14 | + |
| 15 | +This document provides guidance on best practices with the Azure Health Data Services FHIR® service. You'll find practices you should **Do**, **Consider**, or **Avoid** to better the performance of your FHIR service. |
| 16 | + |
| 17 | +> [!NOTE] |
| 18 | +> This document is scoped for Azure Health Data Services FHIR service customers. |
| 19 | +
|
| 20 | +## Data ingestion |
| 21 | + |
| 22 | +### Import operation |
| 23 | + |
| 24 | +Azure FHIR service supports data ingestion through the import operation, which offers two modes: initial mode, and incremental mode. For detailed guidance, refer to the [Importing data into the FHIR service](import-data.md) documentation. |
| 25 | + |
| 26 | +* **Consider** using the import operation over HTTP API requests to ingest the data into FHIR service. The import operation provides a high throughput and is a scalable method for loading data. |
| 27 | +To achieve optimal performance with the import operation, consider the following best practices. |
| 28 | + |
| 29 | +* **Do** use large files while ingesting data. The optimal DNJSON file size for import is 50 MB or larger (or 20,000 resources or more, with no upper limit). Combining smaller files into larger ones can enhance performance. |
| 30 | +* **Consider** importing all FHIR resource files in a single import operation for optimal performance. Aim for a total file size of 100 GB or more (or 100 million resources, no upper limit) in one operation. Maximizing an import in this way helps reduce the overhead associated with managing multiple import jobs. |
| 31 | +* **Consider** running multiple concurrent imports only if necessary, but limit parallel import jobs. A single large import is designed to consume all available system resources, and processing throughput doesn't increase with concurrent import jobs. |
| 32 | + |
| 33 | +### Bundles |
| 34 | + |
| 35 | +In Azure FHIR service, bundles act as containers for multiple resources. Batch and transaction bundles enable users to submit sets of actions in a single HTTP request or response. Consider the following to achieve higher throughput with bundle ingestion. |
| 36 | + |
| 37 | +* **Do** tune the number of concurrent bundle requests to the FHIR server. A high number (>100) may lead to negative scaling and reduced processing throughput. The optimal concurrency is dependent on the complexity of the bundles and resources. |
| 38 | +* **Do** generate load on Azure FHIR service in a linear manner and avoid burst operations to prevent performance degradation. |
| 39 | +* **Consider** enabling parallel processing for batch and transaction bundles. By default, resources in bundles are processed sequentially. To enhance throughput, you can enable parallel resource processing by adding the HTTP header flag `x-bundle-processing-logic` and setting it to `parallel`. For more information, see the [batch bundle parallel processing documentation](rest-api-capabilities.md#bundle-parallel-processing). |
| 40 | + |
| 41 | +> [!NOTE] |
| 42 | +> Parallel bundle processing can enhance throughput when there isn't an implicit dependency on the order of resources within an HTTP operation. |
| 43 | +
|
| 44 | +* **Consider** splitting resource entries across multiple bundles to increase parallelism, which can enhance throughput. Optimizing the number of resource entries in a bundle can reduce network time. |
| 45 | +* **Consider** using smaller bundle sizes for complex operations. Smaller transaction bundles can reduce errors and support data consistency. Use separate transaction bundles for FHIR resources that don't depend on each other, and can be updated separately. |
| 46 | +* **Avoid** submitting parallel bundle requests that attempt to update the same resources concurrently, which can cause delays in processing. |
| 47 | + |
| 48 | +### Search parameter index tuning |
| 49 | + |
| 50 | +Azure FHIR service is provisioned with predefined search parameters per resource. Search parameters are indexed for ease of use and efficient searching. Indexes are updated for every write on the FHIR service. [Selectable search parameters](selectable-search-parameters.md) allow you to enable or disable built-in search parameter indexes. This functionality helps you optimize storage use and performance by only enabling necessary search parameters. Focusing on relevant search parameters helps minimize the volume of data retrieved during ingestion. |
| 51 | + |
| 52 | +**Consider** disabling search indexes that your organization doesn't use to optimize performance. |
| 53 | + |
| 54 | +## Query performance optimization |
| 55 | + |
| 56 | +After data ingestion, optimizing query performance is crucial. To ensure optimal performance: |
| 57 | + |
| 58 | +* **Do** generate load on Azure FHIR service in a linear manner and, avoid burst operations to prevent performance degradation. |
| 59 | +* **Consider** using the most selective search parameters (for instance, `identifier`) over parameters with low cardinality to optimize index usage. |
| 60 | +* **Consider** performing deterministic searches using logical identifiers. FHIR service provides two ways to identify a resource: logical identifiers and business identifiers.<br> |
| 61 | +Logical Identifiers are considered "deterministic" because FHIR operations performed with them are predictable. Business Identifiers are considered "conditional" because their operations have different behavior depending on the state of the system. We recommend deterministic operations using logical identifiers. |
| 62 | +* **Consider** using the `PUT` HTTP verb instead of POST where applicable. `PUT` requests can help maintain data integrity and optimize resource management. `POST` requests can lead to duplication of resources, poor data quality, and increase FHIR data size unnecessarily. |
| 63 | +* **Avoid** the use of `_revinclude` in search queries, as they can result in unbounded result sets and higher latencies. |
| 64 | +* **Avoid** using complex searches (for example: `_has`, or chained search parameters), as they impact query performance. |
| 65 | + |
| 66 | +## Data extraction |
| 67 | + |
| 68 | +For data extraction, use the bulk `$export` operation as specified in the [HL7 FHIR Build Data Access specification](https://www.hl7.org/fhir/uv/bulkdata/). |
| 69 | +* **Do** use larger data blocks for system level exports when not using filters to maximize throughput. Azure FHIR service automatically splits them into parallel jobs. |
| 70 | +* **Consider** splitting Patient, Group, and filtered system exports into small data blocks for export. |
| 71 | + |
| 72 | +For more information on export operations, see [Export your FHIR data](export-data.md). |
| 73 | + |
| 74 | +By applying these best practices you can enhance the performance and efficiency of data ingestion, bundle processing, query execution, and data extraction in Azure FHIR service. |
| 75 | + |
| 76 | +[!INCLUDE [FHIR trademark statement](../includes/healthcare-apis-fhir-trademark.md)] |
0 commit comments