How to resize the Medplum RDS database with zero downtime
A zero-downtime resize of the Medplum database on AWS works only when the deployment runs at least two database instances, and the reader instances are changed before the writer. Medplum's zero-downtime path sets rdsInstances to 2 or more, upgrades readers first through the optional rdsReaderInstanceType setting, and then changes the writer by updating rdsInstanceType. CloudFormation then swaps the writer with an upgraded reader, so the database stays available to the server throughout. A single-instance database cannot follow this path, because there is no reader to promote, so the resize would require a planned interruption.
This matters most for organizations that cannot schedule a clinical-system outage. Clinicians, patient-facing applications and integrations that write to Medplum depend on the database being reachable at all times, and a resize that restarts the writer without a standby leaves them waiting. The sequence also protects the rollback position: if a reader fails to come up at the new size, the writer and the application are untouched. Before starting, confirm with your infrastructure owner that your stack already has the second instance, that the CloudFormation changes are reviewed through your normal change process, and that a current backup exists.
Follow the supported steps in Medplum's Upgrade RDS Database documentation rather than working from memory of the parameters, and check the exact setting names against the version of the CDK stack you deployed. Run the reader change in a staging environment first so you can observe how long the failover swap takes on your instance class and how the application reconnects. Confirm the expected duration and failover behavior with Medplum and your AWS account team before scheduling the production change.
Which config settings control the resize and what each one does
This table compares the four settings and steps that control a zero-downtime Medplum RDS resize, in the order they take effect. Read each row alongside the upgrade sequence: readers change first, the writer changes last, and the CloudFormation swap moves the writer role. Confirm each value in your own stack before you start.
| Setting or step | What it controls | Impact on the running database | Action needed |
|---|---|---|---|
| rdsInstances | The number of RDS database instances in the Medplum stack. The zero-downtime path requires 2 or more. | With fewer than 2 instances there is no reader to take over the writer role, so a writer change interrupts service. | Confirm the value is 2 or more in your CDK or CloudFormation configuration before planning the resize. |
| rdsReaderInstanceType | Optional instance class applied to the reader instances. Readers are changed first. | Readers restart on the new class while the writer keeps serving traffic, so reads may be briefly affected but writes continue. | Set the target class here, confirm it is available in your region, and check that the reader instances show the new class before continuing. |
| rdsInstanceType | The instance class of the writer. It is changed last. | Changing this value starts the writer change. Medplum depends on this step being preceded by the reader upgrade. | Change only after every reader runs the new class. Confirm the target class matches the readers so the swapped writer is sized the same. |
| CloudFormation writer-to-reader swap | The failover step where CloudFormation swaps the upgraded reader into the writer role and the old writer becomes a reader. | This swap is what keeps the database available through the writer change, and it is the step where a short write interruption can still occur. | Watch the stack events and database status during the swap, confirm the new writer accepts connections, and verify application health afterward. |
| Config cleanup after the resize | Removal of temporary or transitional values once the resize is complete. | Leaving transitional values in place can cause a later deploy to resize the database unexpectedly. | Confirm with your own stack which values to remove or align, then run a diff to check that no further changes are pending. |
How the writer swap moves traffic to a resized instance
The diagram starts with the Medplum server connected to the RDS writer and its readers inside the AWS account. The reader resize runs first, so the readers are upgraded through rdsReaderInstanceType while the writer keeps serving traffic. Next, the rdsInstanceType setting is changed and CloudFormation swaps the writer with a resized reader, so the resized instance becomes the writer. Check that the Medplum server reconnects to the new writer and that the old writer is now sized as a reader before you clean up the config.
Writer swap order between the Medplum server, RDS instances and CloudFormation.
What to confirm before the Medplum RDS resize starts
A resize touches the database that every Medplum request depends on, so the preparation decides whether the change stays invisible to users. The six items below cover the current topology, the reason for the change, a recovery point, the server version, a staging rehearsal and the people who must be reachable during the window.
Confirm the current instance count
Check the rdsInstances value in your CDK or CloudFormation configuration and confirm the database runs at least two instances. The zero-downtime path depends on having a reader that CloudFormation can promote to writer, so a single-instance stack needs a topology change before any resize. Record the current rdsInstanceType for both the writer and readers, and confirm which instance type the readers and writer each run today. Keep this record with the change ticket so rollback targets are clear.
Show the capacity case
Collect CPU, memory, connection count, IOPS and replica lag figures from the period when the database was under strain. A resize should answer a measured bottleneck, not a general sense that the database feels slow. Note which metric points to the instance class, because a connection limit or storage throughput problem may need a different fix. Confirm the new size will be checked against these same metrics after the change.
Verify a recent backup
Confirm a current automated backup exists and take a manual snapshot immediately before the change. Check the snapshot status and restore point, and confirm your team knows how to restore it in another account or Region if needed. Ask who holds permission to restore and whether that person is available during the window. A snapshot that has never been restored in your environment is an assumption, not a recovery plan.
Confirm the Medplum server version
Check the running Medplum server version against Medplum's upgrade guidance before you touch the database. A resize is not the place to discover that the server is on a version that skips required minor stops or has a pending post-deploy migration. Confirm that no migration is still running from a recent upgrade, because a writer swap during a long data migration adds risk. Record the version in the change ticket.
Upgrade guideRehearse in a production-shaped staging stack
Build a staging stack with the same rdsInstances count, engine version and CDK configuration as production, then run the reader upgrade, writer swap and config cleanup there first. Measure how long each stage takes in your environment and note any stage where Medplum returns errors. Use staging data volumes close to production so connection handling and failover behavior are realistic. Capture the exact commands and parameter changes so the production run repeats them without improvisation.
Schedule the window with named contacts
Agree a change window with the clinical operations lead, the application owner and the support on-call, and confirm who can declare a stop. Make sure the people who will watch error rates and user reports know what a brief disconnect looks like, and what to escalate. Ask the cloud operations team to confirm change freeze rules and approvals. Write down the rollback decision owner and the conditions that trigger a stop before the window opens.
The resize sequence from readers to writer
The sequence moves reader instances to the target size first, then swaps the writer through CloudFormation, so the database keeps a serving instance at each stage. Each step ends with a check that tells the team whether to continue.
Confirm at least two database instances
Open the Medplum CDK configuration and check that rdsInstances is set to 2 or more. If it is lower, raise it to 2 and deploy before changing any instance size, because the writer swap needs a reader to promote. The team confirms this in the CDK config file and in the RDS console, where the cluster should show one writer and at least one reader. If the cluster has only one instance, stop here: the zero-downtime path does not apply and the team should confirm the downtime tolerance with its own operations owner before continuing.
Set the reader instance type and deploy
Set rdsReaderInstanceType to the target instance size and run the CDK deploy for the Medplum stack. Leave rdsInstanceType unchanged in this deploy. CloudFormation replaces the reader instances first, so the writer keeps serving traffic. The engineer running the deploy confirms that the stack update completes without errors and that the reader instances report the new instance class in the RDS console.
Check reader health and replication
Before touching the writer, confirm that each upgraded reader is available, that replication lag from the writer is back to its normal level, and that the Medplum server is still answering requests normally. Use the RDS console or CloudWatch metrics for replica lag and instance status, and check Medplum server logs and health endpoints for database errors. Only continue when every reader is available and lag has settled. If a reader stays unhealthy or lag keeps growing, stop, leave the writer as it is, and investigate before any further change.
Set the writer instance type and deploy
Set rdsInstanceType to the same target size and deploy again. Per the Medplum RDS upgrade documentation, CloudFormation then swaps the writer with an upgraded reader, so the promoted instance becomes the new writer. Plan this deploy for a window when your team is watching the stack and the Medplum server, because the failover is the one stage where connections may briefly reset. Confirm the stack reaches its complete state and that the RDS console shows a new writer at the target size.
Verify the new writer and server connectivity
Confirm which instance is now the writer and that its instance class matches the target. Then check that the Medplum server reconnects to the database, that API requests succeed with normal latency, and that write operations complete, for example by creating and reading a test resource in a non-production project. Review server logs for connection errors after the swap. If writes fail or the server cannot reconnect, stop and resolve connectivity before any cleanup, because the temporary settings are still the simplest state to reason about.
Remove or revert temporary settings
Once the new writer is confirmed, remove rdsReaderInstanceType if it is no longer needed, and make sure rdsInstanceType and the reader configuration match the intended long-term layout. Keep rdsInstances at 2 or more if the deployment needs redundancy. Run a CDK diff and deploy so the configuration in code matches what is running. The team is done when the diff shows no pending changes and the running instances match the committed configuration. Confirm with your own operations owner whether any rollback path to the previous instance size is needed, since the facts supplied do not describe one.
Why the writer changes last in a Medplum RDS resize
The writer changes last because the readers absorb the change first, and the writer is the only instance that takes writes. Once rdsReaderInstanceType has been applied and the resized readers are serving traffic, the team has a working check on the new instance class before anything touches the instance that accepts writes. If the readers behave badly on the new size, the operator can stop and investigate while the writer is still the original, known-good instance. Changing the writer first would put the least-tested configuration in the place where failures are hardest to contain.
The writer step is the one that matters for uptime. The change to rdsInstanceType leads CloudFormation to swap the writer with a reader, so the watch period should cover the moment the swap happens. In the Medplum server, watch for spikes in application errors, failed or retried database requests, and rising write latency, and compare them with the baseline you recorded before the change. Also watch the Medplum server's own logs for connection errors while the new writer takes over. Confirm in the Medplum upgrade RDS database documentation exactly how the swap and any connection interruption appear for your Medplum version, and confirm in the AWS RDS documentation how failover behaves for your chosen engine version, including how long the endpoint takes to point at the new writer.
Before you start the writer step, decide in advance what you will check and who can call a stop. Agree on the error and latency thresholds that mean the swap should be paused, confirm that the readers have run under real load long enough for you to trust them, and make sure someone is watching dashboards for the full window. Record the instance class and endpoint state before and after, so a rollback decision or a support ticket has a clear starting point. Treat these thresholds as your own targets to set with your platform and database owners, not as values from the Medplum documentation.
What makes a Medplum RDS resize take longer
This table lists the factors that add work to a Medplum RDS resize and what to check for each one. Read it before estimating scope, because the first row, the existing instance count, decides whether a zero-downtime path exists at all. The main takeaway is that the stack's current shape and your organization's sign-off rules usually matter more than the instance size itself.
| Driver | Why it adds work | What to check |
|---|---|---|
| Existing instance count | The zero-downtime method needs at least two database instances. A single-instance database must be changed first, which adds a planned outage window. | Confirm the value of rdsInstances in the stack config. If it is 1, plan how to raise it to 2 or more before the resize starts. |
| Size of the change | A large jump in instance class can change memory, connection limits and I/O behavior, so the post-change tuning and load testing take longer. | Compare current and target instance classes. Ask Medplum and your DBA which connection and memory settings depend on instance size. |
| CDK and CloudFormation management | A stack managed through CDK and CloudFormation changes the database through a planned template update. Manual console changes can drift from the stack and block later deploys. | Check whether the database was created by the Medplum CDK stack and whether any settings were edited in the AWS console. Run a CDK diff before changing anything. |
| Custom configuration in the stack | Custom parameter groups, networking, security groups, backup settings or added resources need review so the template update does not remove or alter them. | List every customized setting in the stack. Confirm which ones the CDK diff will touch and which need separate handling. |
| Staging rehearsal scope | A staging environment that matches production in instance count, configuration and data volume gives a realistic view of failover timing and application behavior. | Confirm whether staging has the same instance count and config. Decide which checks run during the rehearsal, such as login, API traffic and Bot execution. |
| Number of environments | Each environment that carries the database needs its own resize, verification and rollback record. Work multiplies with each additional environment. | Count the environments that use this database, such as development, staging, production and disaster recovery copies, and order them. |
| Verification and sign-off requirements | Regulated organizations often require change tickets, approvals, evidence of testing and a defined rollback plan before a production change. This adds documentation and review cycles. | Ask your change board and compliance team what evidence they expect. Confirm who approves the failover window and who monitors it. |
Common questions about resizing the Medplum RDS database
Is resizing the Medplum RDS database really zero downtime?
The method is designed to avoid an outage, but whether your deployment stays fully available depends on how you run it. The sequence requires at least two database instances, so readers are upgraded first through the optional rdsReaderInstanceType setting, then the writer is changed through rdsInstanceType, and CloudFormation swaps the writer with a reader. Your team should confirm the behavior in a staging stack that mirrors production, including how the Medplum server reconnects during the failover swap, how long active sessions and Bots see interruptions, and whether any write-heavy jobs need to be paused. Treat zero downtime as a result to verify in your own environment, not an assumption. The Medplum RDS upgrade documentation is the starting point for the exact steps.
What does a database resize cost in effort, and what drives that cost?
The main cost is skilled engineering time, plus the cost of running a larger instance and any extra reader instance while the work is in progress. The effort depends on how many environments you have, how standardized your CDK or CloudFormation configuration is, how much monitoring already exists, and whether you can rehearse the change in staging first. Ask any partner for a quote built from a written scope that lists the environments, the rehearsal runs, the change window support and the post-change checks. Ask whether the price includes a rollback plan and a retest. Ongoing costs are mainly the instance hourly charges from AWS, which depend on the instance class you choose and your region, so confirm those against current AWS pricing.
How long does a zero-downtime RDS resize take?
The duration depends on your environment rather than on a fixed figure, so it is best confirmed through a staging run. The work includes the reader upgrade, the writer change, the CloudFormation failover swap, and the verification that follows each step. Factors that lengthen the timeline include database size, how long the stack takes to apply changes, the number of environments, and whether you need separate approval windows for each step. Ask your team or partner to time each stage in staging, then use those measurements to plan production change windows. Avoid committing to a date until that rehearsal has been completed and reviewed.
Can our team resize the database without outside help?
Yes, if your team already manages the Medplum stack on AWS with CDK or CloudFormation and has experience with RDS failover behavior. The change is a configuration change followed by a stack update, so the main risks are configuration drift, a missed reader, or an unplanned writer swap during peak use. Teams new to CloudFormation or to Medplum's self-hosting layout usually benefit from a review of their configuration and a rehearsal before production. Check whether your staff have access to the infrastructure repository, the AWS account, and the monitoring tools needed to watch each step. A fixed-scope engagement with DeployOpen can cover the planning, the staged run, and the handover, while your team keeps ownership of the environment.
What do we need to provide before the resize starts?
You need to provide access and decisions, not only tooling. Expect to supply access to the AWS account and CloudFormation stack, the current rdsInstances and instance type settings, a staging environment that matches production, a named change window and approver for each stage, and the dashboards or metrics used to watch database connections, CPU, memory, replication lag and Medplum server errors. You will also need a rollback decision owner and a communication plan for users and integrations that depend on the API. Ask your team to confirm which metrics are already collected and whether alerts go to someone who can act during the window.
Does running a second database instance add ongoing cost?
Yes. The resize requires at least two database instances, so a reader instance is billed by AWS for as long as it runs, in addition to the writer. The cost depends on the instance class, the region and the time the second instance is kept. Some teams keep the reader in place for high availability and read scaling, while others remove it after the change if the design allows. Ask your architect to confirm whether the reader is needed for ongoing resilience, then check the current AWS pricing for the chosen instance class. Any retainer or support agreement you sign would be a separate, recurring cost to confirm in the written scope.
What should we do if the resize fails partway through?
Stop further changes, confirm the current state of the writer and readers, and follow your rollback plan before trying again. The failure point determines the next step: a failed reader change is usually easier to recover than a writer swap, and CloudFormation events show which resource stopped. Keep a tested rollback procedure from staging, check that Medplum reconnects after any recovery, and review database logs and server errors before starting another attempt. Record the cause, the timeline and the decision made, so the next change window has better information. If your team cannot diagnose the failure quickly, escalate to the AWS support plan you hold or to the partner named in your written scope.
How to verify the resized database and clean up the config
Confirm both instance classes in AWS before you close the change. Open the RDS console or run a describe call against the cluster and check that every instance, the writer and each reader, reports the new instance class. The writer should be the instance that was swapped in during the failover, and the old writer should now appear as a reader on the old size. Confirm that the CloudFormation stack has reached its completed state with no rollback and no pending changes, because a stack that stalls partway through can leave the cluster with mixed sizes that look correct in one place and wrong in another. Record the instance identifiers and classes you saw, since the team will need them for the change record.
Next, prove the application path works, not just the database. Watch the Medplum server logs for connection errors or repeated reconnect attempts around the time of the writer swap, and confirm the server is serving FHIR requests with a simple authenticated read and a search against a known resource type. Check the database metrics for the same window: connection counts, replica lag, CPU, memory and any spike in errors or latency. Expect a brief blip at failover, but agree in advance with the operations owner on what level of error rate or latency means the resize is not finished. Keep the monitoring baseline from before the change so the comparison is fair.
Finally, remove the temporary settings. Delete rdsReaderInstanceType from the configuration once the readers are on the target class, so a later deployment does not quietly reapply an outdated reader size, and make sure rdsInstanceType and rdsInstances match what is now running. Store the configuration in version control and merge the cleanup as its own reviewed change, so the commit history shows the before and after state. Ask whoever owns your self-hosting setup to confirm, against the Medplum upgrade RDS database guide, that no other setting in your stack still depends on the temporary value.
How DeployOpen scopes and runs a Medplum database resize
DeployOpen plans and carries out the RDS resize for Medplum inside your own AWS account, starting from a written scope that names the instance sizes, reader count, maintenance window and rollback steps. Each stage is checked in a non-production copy before the production writer is touched, and the result is documented for your team to run later.
How we scope
- Confirm the current Medplum version, the CDK stack and the RDS instance class, engine version and reader count in use.
- Agree the target instance size, the number of readers and whether the stack already runs at least two database instances.
- Define the maintenance and monitoring window, the rollback plan and who approves each writer swap before work starts.
- Set the written scope, deliverables and timeline in writing. Engagements are fixed-scope, and ongoing support is available as a retainer.
How we build
- Rehearse the reader upgrade, then the writer change through the failover swap, in a staging stack that mirrors production settings.
- Change the rdsReaderInstanceType setting first, then rdsInstanceType, and review the CloudFormation change set before each deploy.
- Check application health, database connections and Medplum server responses after each step, not only the stack status.
- Remove temporary configuration values once the new instance sizes are confirmed, so the stack config matches what is running.
How we hand over
- Deliver a runbook with the exact order of reader, writer and cleanup steps, the checks at each stage and the rollback conditions.
- Document the final CDK configuration, instance sizes and the decisions made during scoping so future resizes start from a known state.
- Walk your platform and database owners through the failover behavior and the signals that show the swap has finished.
- Record open items, such as recurring cost changes or a later PostgreSQL major version move, for your own planning.
How we support
- Offer retainer support for future Medplum upgrades, resizes and infrastructure changes on the same stack.
- Re-run the resize checks against staging when Medplum or the CDK stack changes between resizes.
- Provide ongoing testing and documentation updates if your deployment is part of a continuing security review.
- Confirm support terms, response expectations and scope boundaries in the written agreement before work begins.

