Externalized Resource Body Storage
FHIR resource bodies (JSON payloads) are stored by default in the database. However, in systems that manage high volumes of resources or require more cost-effective storage, it is possible to externalize resource body storage to an object storage system such as Amazon S3, MinIO, or Azure Blob Storage. This is especially useful for high-volume databases, enabling up to 20% storage savings depending on the selected resource body offload mode and the number of resource bodies stored in the database.
Externalized resource storage is controlled by two configuration parameters:
The following sections describe options for resource body offload:
By default, saving resource body to external storage is disabled, all resource body content is stored in the relational database.
In this mode, all resource body content continues to be stored in the database. Additionally, each newly created or updated resource is also saved to the configured external object storage system (e.g., S3, MinIO, or Azure Blob Storage). Resource bodies are not removed from the database, and the external storage acts as an archive. This setup allows the FHIR server to operate entirely from the database for reads, updates, searches, and retrieving historical versions of resources. It can serve as a foundation for future migration to offload modes that reduce database size.
In this mode, all older versions of a resource (i.e., versions prior to the latest version) are moved to the configured external object storage system (e.g., S3, MinIO, or Azure Blob Storage) and removed from the relational database.
The latest version is saved to external storage as well, but it remains in the database.
This setup reduces database size while preserving quick access to the most recent resource body version. Historical versions are retrieved on demand from external storage when needed (e.g., via the _history
operation).
This mode offers an optimal balance between minimizing database storage and maintaining high performance for read, update, and search operations.
In this mode, all resource body versions, including the latest, are moved to the configured external object storage system (e.g., S3, MinIO, or Azure Blob Storage), and none are stored in the database. Only resource metadata remains in the relational database, significantly reducing its size. All resource bodies must be retrieved from external storage when needed, including for reads, updates, or historical access. This mode offers maximum storage efficiency and is best suited for systems where minimizing database storage is a priority and latency introduced by external storage is acceptable. Note that read, update, and search operations may be slower due to network overhead and object storage performance.
The following sections describe options for resource body storage:
By default, all resource body content is stored in the database, including all historical versions as well as resource metadata.
This provides efficient reads, writes, and searches. However, as the number of resources and versions grows, database size can increase significantly.
In this mode, FHIR resource bodies are stored in an AWS S3 bucket. Resource bodies will be stored in one bucket, which can be named via the Blob Service Bucket / Container property. You can also configure the region by setting the Blob Service Region property. On boot, Smile CDR will create a bucket if it does not already exist.
Authentication to S3 is done using the DefaultAwsCredentialsProviderChain. This means that credentials can be provided in a variety of ways, including:
However, you also have the option to provide your own credentials via the Blob Service S3 Access Key property and the Blob Service S3 Secret Key property. If credentials are provided in this fashion, they will be used instead of the default credentials.
The account you authenticate with will need permissions to create buckets, as well as to put/head/get/delete objects in the bucket.
In this mode, resource bodies are stored in a MinIO server. All data will be stored in one bucket, which can be named via the Blob Service Bucket / Container property.
Authentication for MinIO must be provided via the Blob Service S3 Access Key and Blob Service S3 Secret Key properties.
Currently, MinIO is only recommended for development purposes.
In this mode, resource bodies are stored in an Azure Blog Storage container. All data will be stored in one container, which can be named via the Blob Service Bucket / Container property. You can also configure the account name by setting the Blob Service Azure Account property. On boot, Smile CDR will create a container if it does not already exist.
There are three different supported authentication methods:
The authenticated account will need permissions to create containers, as well as to PUT/HEAD/GET/DELETE objects in the container.
When resource bodies are stored in an external object storage system (e.g., S3, MinIO, or Azure Blob Storage), each version is written using a path format provided below:
{resource_type}/{fhir_id}/_history/{resource_version}
Example Path:
Patient/1706/_history/5
This corresponds to storing the fifth version of a Patient resource with FHIR ID 1706
.
A mandatory Blob Service Path Prefix is required be configured to prepend a logical folder structure to all object keys. For example, if the prefix is set to fhir-resource-body/dev
, the full object key becomes:
fhir-storage/dev/Patient/1706/_history/5
This is required as storage bucket for resource bodies is shared with Externalized Binary Storage.
When enabling externalize resource body storage, consider the following operational impacts:
VACUUM
/ VACUUM FULL
operations for PostgreSQL etc.) may be required to recover disk space.SAVE_AND_CLEAR_ALL
mode, resource bodies are retrieved sequentially from external storage. As this process is not asynchronous, it may result in slower search performance compared to modes where resource bodies are stored in the database.Externalized Resource Body Storage functionality is under active development. Below is a roadmap of planned features.
You are about to leave the Smile Digital Health documentation and navigate to the Open Source HAPI-FHIR Documentation.