# Aurora Serverless v2 to Self-Managed PostgreSQL: Sizing, WAL, Recovery

> A planning guide for leaving Aurora Serverless v2 for self-managed PostgreSQL: what to measure, how to size the machine, and how WAL and recovery change.

- Author: Zeeshan Adil (https://www.internalswithzee.com/about)
- Published: 2026-06-07
- Updated: 2026-11-21
- Source: https://www.internalswithzee.com/blog/self-managed-postgresql-from-first-principles

## The short version

- A managed database bundles three things: the machine, the write path (WAL, checkpoints, full-page writes) and the durability plan. Leaving means owning all three.
- Size from labeled numbers (measured, estimated, unknown). The Aurora cluster I measured did not expose the usual PostgreSQL WAL statistics, so I measured the candidate's WAL rate during replay.
- Use workload settings such as autovacuum as starting points, and reassess write-path settings such as full_page_writes, checkpoint_timeout and max_wal_size on the new machine.
- Without a managed layer, backups, WAL archiving, point-in-time recovery, a standby and failover drills are yours, and the recovery objective is a business decision.

Managed databases are good at hiding how databases work. That is the product. You get a connection string and an autoscaling knob, and the machine underneath stops being your problem.

Right up until it is. On the database I moved, Aurora Serverless v2 hit its capacity ceiling repeatedly, and the bill scaled with the ceiling. At that point "the machine is not your problem" stops being true, and the only way to make a good decision about leaving is to understand what the managed layer was doing for you, in enough depth to do it yourself or consciously decide not to.

This is the playbook I built for that decision. It is written to be reusable: the specific database is one worked example, and every section teaches the piece of the system you need to reason about your own. If you finish it, you should be able to look at any PostgreSQL workload and answer four questions. What does it ask of a machine? What did the managed platform hide? What do I measure before I commit? How do I prove the new box under load before production traffic touches it?

**Where this article fits**

This is the planning and decision guide, written as the plan: what to understand, what to measure and how to size. The move itself has since been completed. The production database (491 GB, 2,818 commits a second) is off Aurora Serverless v2 and running on self-managed PostgreSQL 17 on local NVMe, saving $78k a year. A separate results write-up is planned, covering the cutover, performance, recovery tests and what was given up. This article does not report those results. The figures below are planning-time measurements from the source cluster, so they differ from the 491 GB above. Where a number is a worked example rather than a measurement, the text says so.

**Reading path:** Basic PostgreSQL queries and transactions are enough to begin. Start with the decision frame, then follow a write to disk. If you are already evaluating a move, focus on [workload measurement](#part-5-measuring-a-workload-you-cannot-fully-see), [sizing](#part-6-sizing-the-machine), and [recovery responsibilities](#part-7-durability-and-availability-without-a-managed-layer). Read the validation section before turning a sizing estimate into a production decision.

## The decision frame first

Before any technical detail, the posture. Every choice below follows from three rules I set at the start:

**Measure before buying.** No hardware commitment until a candidate box has replayed real traffic. On-demand pricing only until then.

**Durability before data.** Backups and WAL archiving are configured and tested before the first byte of production data lands on the new machine, not after.

**One reversible step at a time.** Restore a snapshot, replay, compare, and only then plan the cutover. At every step Aurora is still running and untouched.

None of that is clever. It is the difference between a migration and a gamble, and it shapes what you need to learn. You cannot measure what you do not understand, so the rest of this article is the understanding.

## Part 1: What a database asks of a machine

PostgreSQL is a process that turns disk pages into query results. Almost every performance question reduces to four resources, and a self-managed migration forces you to size all four explicitly, where Aurora sized them for you.

### CPU: cores versus clocks versus generation

PostgreSQL uses one backend process per connection. A single query runs on one core unless the planner decides to parallelize it, which it does for large scans and aggregates but not for the short OLTP statements that dominate most transactional workloads. So for OLTP, single-core speed matters as much as core count, and the two trade against each other in the instance catalog.

Then there is the generation problem. "64 vCPUs" on a five-year-old server and "64 vCPUs" on this year's part are not the same amount of work per second. The honest way to compare is to normalize to a reference: pick a benchmark you trust for your access pattern, or take the vendor's stated generational uplift and treat it as an estimate, not a fact.

This mattered in the worked example. The Aurora cluster reported its ceiling in ACUs, Aurora's own capacity unit, on a platform version that AWS describes as roughly 30% faster than its predecessor without naming the silicon. Translating "peak ACU" to "how many cores of a specific x86 or ARM part" is not arithmetic, it is an estimate with a correction factor, and the correction pushed the core count up. That single correction eliminated every cheaper machine on my shortlist. Knowing that the number was an estimate is what stopped me from buying the wrong box.

**What NUMA means**

Non-Uniform Memory Access. On a machine with more than one CPU socket, each socket has RAM attached directly to it. A core can read memory attached to the other socket, but it is slower. PostgreSQL's shared buffer cache is one big shared allocation, so on a two-socket machine part of it is always "far" from any given backend. This is one reason a single fast socket often beats two slower ones for a database, and why cloud instance sizes that stay within one socket are worth noticing.

### Memory: three consumers, one pool

PostgreSQL memory has three big consumers, and they compete.

**Shared buffers** is PostgreSQL's own page cache. Pages are read from disk into it and modified there. A page that is in shared buffers is served without touching storage. On Aurora the size is chosen for you and moves with the instance. On the cluster I measured it had reached 153 GB at peak. That number became a conservative planning input for the new machine's RAM. It did not prove that all 153 GB was a necessary working set: the target's shared buffers and OS cache work together, so the replay needed to test whether a different split met the latency target.

**The operating system page cache.** PostgreSQL reads and writes data files through the kernel, so the kernel keeps its own cache of the same files. Pages can live in both, which is why a common rule of thumb sets shared buffers around a quarter of RAM and leaves the rest for the OS. Aurora's distributed storage and caching model differs from a local PostgreSQL server's page-cache path, so don't assume the same split transfers. On a self-managed box, the OS cache is a useful second tier: RAM left available for it can reduce storage reads.

**Per-operation working memory.** `work_mem` is the budget each sort or hash operation gets before spilling to a temporary file on disk. It is per operation, not per connection, so one complex query can use it several times over. The default is 4 MB. On the cluster I measured, `work_mem` was still 4 MB and the lifetime temp file volume was 48 TB. The counter records cumulative temporary data written, not the amount of RAM a query needs or a direct measure of a specific sort. It suggests investigating spills and the queries behind them, including with `pg_stat_statements` and execution plans, and it says the new box needs RAM headroom for a higher `work_mem` multiplied by realistic concurrency. Hash operations get `work_mem` multiplied by `hash_mem_multiplier`, so they can use more than the base figure.

I used those three consumers to set a conservative planning floor: 153 GB of source cache plus headroom put the initial floor at 192 GiB and the candidate at 256 GiB. The replay, rather than that arithmetic alone, had to validate the choice.

### Storage: where a managed database differs most

This is the part that changes your mental model, so it gets its own section below. The short version: Aurora replaced your disk with a distributed storage service. When you leave, you get a disk back, and every property of that disk matters. Latency per write, whether it is local or network-attached, what happens to it when the instance is stopped, and whether the operating system's promise of an atomic write matches the size of a database page.

### Network

Two things. Replication traffic to a standby, which is roughly your WAL rate. And the round trip from the application, which on a managed service you never chose and on a self-managed box you place deliberately, in the same zone as the workers that hit it hardest.

## Part 2: How a write reaches disk

Everything about PostgreSQL durability, checkpoint tuning, and the Aurora difference comes from one sequence. Learn it once and the parameter names stop being magic.

### The simple model

Three places are involved when a transaction changes a row:

1. **Shared buffers.** The page holding the row is modified in memory. It is now dirty.
2. **The write-ahead log.** A small record describing the change is appended to a sequential file and flushed to disk. With the default settings (`fsync` and `synchronous_commit` on, see the commit path section below), the transaction reports success only after that flush.
3. **The data files.** The dirty page is written to its real location separately. This can happen before or after commit, but the relevant WAL must be durable before the page is written.

![A changed page can remain in memory while its write-ahead log is flushed at commit. The commit returns before the data page necessarily reaches disk. After a crash, recovery can replay flushed WAL, subject to the durability settings described in the article.](https://www.internalswithzee.com/images/diagrams/wal-commit-relationships-wide.svg)

The write-ahead log is the durability mechanism. If the server dies after the WAL is flushed but before the changed page reaches its data file, recovery replays the log. That lets PostgreSQL acknowledge a durable commit without waiting for every changed data page to be written.

**What WAL means**

Write-Ahead Log. "Write-ahead" means the description of a change is written and made durable before the change itself reaches the data files. Many databases use a redo log, transaction log, or journal; other durable designs use different mechanisms, such as copy-on-write. In PostgreSQL it is a sequence of fixed-size segment files, and almost every durability, replication and backup feature is built on top of it.

### Checkpoints

Dirty pages cannot stay dirty forever. A checkpoint is the moment PostgreSQL guarantees every dirty page from before a certain point has been written to the data files, and writes a marker into the WAL saying so. Recovery reads the checkpoint record to find its redo position, which can precede the checkpoint record itself. WAL before that redo position is no longer needed for this crash recovery, although replication, archiving, and backups can still require older segments.

Two settings decide when checkpoints happen. `checkpoint_timeout`, default five minutes, is the maximum time between them. `max_wal_size`, default 1 GB, is a soft limit on how much WAL is allowed to accumulate before one is forced. Whichever limit arrives first triggers the checkpoint. A third setting, `checkpoint_completion_target`, default 0.9, spreads the page writes across most of the interval so the checkpoint is a steady background load rather than a burst.

The trade is explicit in the [PostgreSQL WAL configuration chapter](https://www.postgresql.org/docs/current/wal-configuration.html): shorter intervals mean faster crash recovery, because less WAL has to be replayed, and more I/O, because of what comes next.

### Full page writes and torn pages

A PostgreSQL page is 8 KB in the default build; the page size is a build-time choice. Most storage promises atomic writes of 4 KB or smaller. If power fails halfway through writing a page, the disk can hold the first half of the new version and the second half of the old one. That is a torn page, and WAL replay cannot repair it, because a WAL record describes a change to a page and applying a change to a half-wrong page yields a fully wrong page.

PostgreSQL's defense is `full_page_writes`. When it is on, which is the default, PostgreSQL logs a full-page image on the first relevant modification of a page after a checkpoint. The stored image can be smaller than 8 KB when unused page space is omitted or WAL compression is enabled. Recovery restores that whole image and replays later changes on top. The [parameter reference](https://www.postgresql.org/docs/current/runtime-config-wal.html) is blunt about the alternative: turning it off "might lead to either unrecoverable data corruption, or silent data corruption, after a system failure."

Now connect the two mechanisms. Every checkpoint resets the "first modification since checkpoint" bookkeeping, so every page touched in the next interval gets logged in full again. Frequent checkpoints multiply full-page images. This is write amplification, and it is the reason a 60-second checkpoint interval on a busy database is a bad idea on real disks: you can repeatedly pay for full-page images, on top of the checkpoint writes. The actual image size depends on compression and unused space.

### Worked example: what one small update actually writes

This is an illustrative calculation with rough sizes, not a measurement from the cluster. Take a table with three indexes and rows of about 80 bytes. You update one integer column on one row, and assume the update cannot be a heap-only update (for example because the column is indexed), so all three indexes get a new entry. That sounds like a hundred-byte write. Immediately after a checkpoint, with `full_page_writes` on (the default), here is roughly what reaches the WAL:

| Write | Rough size | Why it exists |
|---|---|---|
| New heap tuple | ~100 bytes | MVCC writes a new row version instead of editing in place |
| Full page image of the heap page | 8 KB | First touch of that page since the checkpoint |
| Index entries, three indexes | ~150 bytes | Each index needs a pointer to the new tuple |
| Full page images of three index pages | 24 KB | The same first-touch rule, once per index page |

Using four uncompressed 8 KB images as a rough upper-bound illustration gives about 32 KB of WAL for this change, around 400 times the 80-byte row size. Real WAL differs: page images may omit unused space or be compressed, and the records and affected pages depend on the update. Measure the actual bytes rather than treating this ratio as a constant.

The number that makes it bearable is what happens next. Update a second row on the same heap page and the same index pages inside the same checkpoint interval and the full page images are gone: you pay only the ~250 bytes of tuple and index records. So amplification is front-loaded per page per interval, which is exactly why interval length is the lever. Shorter intervals can cause the same hot pages to generate images more often, but the change in total WAL is workload-dependent rather than a guaranteed doubling.

You can watch this directly. `pg_stat_wal` counts full page images separately:

```sql
SELECT wal_records,
       wal_fpi,
       pg_size_pretty(wal_bytes) AS wal_total,
       stats_reset
FROM pg_stat_wal;
```

Compare deltas over a known interval rather than lifetime totals alone. A high image count can be a reason to investigate checkpoint frequency and the workload's page-touch pattern, but the ratio is not a universal health threshold. Measure WAL bytes and recovery time before and after changing settings.

**Aside: wal_compression is the other lever**

`wal_compression` compresses full page images specifically, with pglz, lz4 or zstd depending on the build. It trades CPU during logging and replay for a smaller WAL. On a workload dominated by full page images, lz4 often pays for itself. It does not change the mechanism, only the size of what the mechanism writes, so measure the WAL rate first and treat compression as a second pass.

### Sizing checkpoints from a number, not a guess

The only sane input for checkpoint settings is the WAL rate: bytes of WAL per hour under real load. With that number:

- Pick a checkpoint interval you can tolerate for crash recovery, commonly 15 to 30 minutes for a write-heavy primary.
- Set `max_wal_size` above the WAL generated in that interval, with margin, so time triggers checkpoints rather than volume. On a database writing several gigabytes an hour, that is tens of gigabytes, not the 1 GB default.
- Keep `checkpoint_completion_target` at 0.9 and watch the checkpointer statistics for checkpoints that were forced by volume rather than time.

Worked through with a number. The 6 GB an hour below is an assumed figure for the example, not this cluster's WAL rate (which, as the next part explains, could not be read). Suppose the replay measures 6 GB of WAL per hour at peak:

| Step | Arithmetic | Result |
|---|---|---|
| WAL per minute | 6 GB / 60 | 100 MB |
| Target checkpoint interval | chosen for recovery time | 15 minutes |
| WAL per interval | 100 MB x 15 | 1.5 GB |
| `max_wal_size` with 2x headroom | 1.5 GB x 2 | 3 GB |

Suppose `checkpoint_timeout` has been raised to 15 minutes but `max_wal_size` is left at the 1 GB default. At 100 MB a minute, volume alone would force a checkpoint roughly every ten minutes, and in practice sooner, because the server starts a checkpoint before the soft limit is reached. The timeout would never fire, and every one of those checkpoints would re-arm the full page image tax from the previous section. Setting it to 3 GB provides more headroom in this illustration, but the soft limit and actual checkpoint timing depend on PostgreSQL's WAL accounting and workload. Confirm the triggers in the logs and statistics.

One caveat: the WAL rate itself depends on the checkpoint interval, because longer intervals mean fewer full page images. A rate measured under one setting is an input to the next one, so re-measure after you change it.

Then verify rather than trust. The checkpointer statistics tell you which trigger fired:

```sql
SELECT num_timed, num_requested FROM pg_stat_checkpointer;
```

`num_timed` should dominate. A rising `num_requested` means checkpoints were requested, but the counter alone does not identify the cause. Correlate it with checkpoint logs, WAL volume, and administrative activity before changing `max_wal_size`. On older PostgreSQL versions the same counters live in `pg_stat_bgwriter` under different names, so check which view your version exposes.

On a conventional PostgreSQL server, compare `pg_stat_wal.wal_bytes` over time to estimate the WAL rate. The Aurora cluster in this example did not expose that counter, which is the subject of the next part.

### The commit path: synchronous_commit and fsync

With `fsync` enabled, PostgreSQL asks the operating system to make writes durable. Whether a commit waits for its WAL flush also depends on `synchronous_commit`. Disabling `fsync` can corrupt the database after a power failure or operating system crash. Leave `fsync` on. That promise also assumes the storage honors flush requests: a drive with a volatile write cache and no power-loss protection can acknowledge a flush it has not made durable, so check this on the actual NVMe (the reliability chapter in the sources covers it).

`synchronous_commit` is the subtler knob: with it on, the commit waits for the WAL flush; with it off, the commit does not wait for that flush. Under normal conditions, the WAL writer flushes within about three times `wal_writer_delay`, 600 ms with the default setting. With `fsync` still on, asynchronous commit can lose recently acknowledged transactions after a crash without the corruption risk of disabling `fsync`. The documented flush interval is an operational bound under normal conditions, not a substitute for testing the storage and failure path. Whether that is acceptable is a business question with a technical answer, and on a migration the baseline is to keep it on and measure the cost before relaxing it.

**Aside: this model is deliberately incomplete**

There are more buffers, a background writer that trickles dirty pages out between checkpoints, WAL buffers that stage records before they hit the file, and hint bits that dirty pages during reads. None of them change the decisions in this article. They start mattering when you are diagnosing latency spikes on the new box, which is a different article.

## Part 3: What Aurora was doing for you

Aurora is PostgreSQL with a very different storage and operational model around it. The engine still generates WAL records. The difference is what happens to them.

Amazon's own [description of the storage engine](https://aws.amazon.com/blogs/database/introducing-the-aurora-storage-engine/) is that the database "only sends log records to the storage nodes and those writes are done in parallel", and that on the storage side "log records are first coalesced and then used to create data pages." The compute instance never writes a data page to a disk it owns. Materializing pages from the log is the storage service's job, replicated across three availability zones.

Once you hold that picture, the parameter group of an Aurora cluster reads very differently. On the cluster I measured:

```
full_page_writes    = off
checkpoint_timeout  = 60s
max_wal_size        = 1GB
```

Do not copy these values blindly to a conventional PostgreSQL server. In particular, turning off `full_page_writes` can risk corruption after a system failure unless the storage and failure assumptions justify it. Aurora's storage architecture changes the write path, so assess the target against PostgreSQL's own documentation and measured behavior rather than treating the source settings as portable defaults.

That generalizes into the single most useful rule for a migration:

| Parameter type | Examples | Transfers? |
|---|---|---|
| Describes the workload | autovacuum aggressiveness, `work_mem` observations, extension list, index usage | Useful starting points; verify version support and retune |
| Describes the physical write path | `full_page_writes`, `checkpoint_timeout`, `max_wal_size`, `wal_buffers` | No, derive from measurement on the new machine |
| Describes durability semantics | `synchronous_commit`, `fsync` | Keep the strict setting as baseline, measure before relaxing |

The second thing Aurora does is hide the measurement you need most. On the Aurora cluster I measured, `pg_stat_get_wal()`, the function behind `pg_stat_wal`, returned an unsupported error. A later [AWS monitoring example](https://aws.amazon.com/blogs/database/build-an-oracle-awr-style-report-for-rds-aurora-postgresql/) also notes that this function is unavailable on Aurora; check the behavior of the engine version you run. Monitoring tools like [pgmetrics](https://github.com/rapidloop/pgmetrics/blob/master/collector/collect.go) and the [Datadog agent](https://github.com/DataDog/integrations-core/issues/15890) carry explicit "skip WAL stats on Aurora" branches for exactly this reason. In my cluster `pg_current_wal_lsn()` was not usable either without turning on logical replication, and I found no CloudWatch metric that reports WAL bytes for Aurora PostgreSQL.

The source's storage model and statistics differ from the target's. WAL rate on the candidate is one useful input to configuring the database you are moving to. The consequence is a method, not a complaint: the first real WAL number comes from the replay box, and every checkpoint setting is a placeholder until it does.

**Aside: what you can still read on Aurora**

Plenty. `pg_stat_statements` for the query mix, `pg_stat_user_tables` for tuple churn and vacuum activity, temp file volume, connection counts and states, the volume size and its daily growth from CloudWatch, the extension list, and every parameter. Most of Part 5 comes from those. The gap is specifically the physical write path, which is the one thing Aurora abstracted away.

## Part 4: The read side, connections, and vacuum

The write path gets the drama. Three quieter areas decide whether the new box feels fast.

### Reads and the double cache

A read is served from shared buffers if the page is there, from the OS cache if the kernel has it, and from disk otherwise. The cache hit ratio from `pg_stat_database` tells you about hits in PostgreSQL shared buffers; a PostgreSQL buffer miss may still be served by the OS cache, so it does not directly measure physical disk reads. Compare latency, storage I/O, and cache behavior on the target under replay. Matching the source's shared-buffer size or hit ratio is a starting hypothesis, not proof that the target has enough RAM.

### Indexes, and the partition trap

An unused-index audit is standard pre-migration hygiene: every index costs write amplification on every insert and update, and dropping dead ones is free performance. The trap is partitioned tables. Usage statistics are recorded per partition, so an index on the parent can show zero scans while its children are hit constantly. On the cluster I measured, a 41 GB index looked unused at the parent level and turned out to be essential once the child partitions were rolled up. Roll them up before you drop anything.

### Connections are processes

Every PostgreSQL connection is an operating system process with its own memory. Aurora absorbs a few hundred idle connections without complaint. On a self-managed box they are a few hundred processes sitting on RAM and file descriptors. The cluster I measured had 186 idle anonymous connections, which is the argument for a connection pooler from day one.

The arithmetic that makes people nervous, correctly, is `work_mem` multiplied by concurrency. Raise `work_mem` to 256 MB to stop the temp file spilling from earlier, and the theoretical worst case is that number times the number of concurrent sort and hash operations, which is more than the number of connections because one query can use several at once. As an illustration, two hundred active connections each running two sorts is about 100 GB of working memory on a 256 GB machine, on top of shared buffers.

That worst case almost never happens, and designing as though it cannot happen is how databases fall over at 3am. The response is to identify expensive spills and bound the concurrency multiplier, then choose memory settings for measured queries rather than raising the global value indiscriminately:

| Lever | Effect | Cost |
|---|---|---|
| PgBouncer, small server pool | Caps concurrent backends regardless of app connections | Session features break, see below |
| `work_mem` set per role or per query | Big budget only for the queries that need it | Someone has to identify them |
| Lower global `work_mem`, raise in session | Safe default, explicit opt-in | Application changes |

The pooler is the one that generalizes, because it turns an unbounded number into a number you chose.

[PgBouncer](https://www.pgbouncer.org/features.html) in transaction pooling mode assigns a server connection to a client only for the duration of a transaction, so a small pool of real backends serves a large number of application connections. It works by breaking some session assumptions on purpose. Session-level features are not supported through it: `SET` and `RESET`, `LISTEN`, `WITH HOLD` cursors, SQL-level `PREPARE` and `DEALLOCATE`, session-level advisory locks, and a few others. (Protocol-level prepared statements are supported in recent PgBouncer versions when `max_prepared_statements` is set, so check your version and driver.) The pre-migration check is to count how often the application uses each. This one used none: zero `LISTEN`, zero advisory locks. That made transaction pooling safe. If the count is not zero, session pooling or application changes come first.

**What MVCC and dead tuples mean**

Multi-Version Concurrency Control. PostgreSQL never updates a row in place. An update writes a new version of the row and marks the old one as expired, so readers that started earlier still see a consistent snapshot. Expired versions are dead tuples, and they take space until vacuum reclaims them. A database with heavy updates and lazy vacuum grows bloated tables and indexes, which is why autovacuum settings are workload settings, not platform settings.

### Vacuum settings transfer cleanly

The Aurora cluster already ran autovacuum aggressively: a 5 second naptime, 8 workers, and a large work memory. Those numbers were earned by the workload's update rate, and they say nothing about the platform. They copy straight across. If anything, the new box with faster local storage lets vacuum keep up more easily, but the settings are the starting point, not the thing to reinvent.

## Part 5: Measuring a workload you cannot fully see

A migration plan is only as good as its measurements, and the measurements come in layers. Here is the sheet I built for the worked example, with the source of each number and how confident it is.

| What | Value (this cluster) | Source | Confidence |
|---|---|---|---|
| Logical data size | ~570 GB | `pg_database_size` | Measured |
| Volume peak and growth | 680 GB peak, ~6.3 GB/day | CloudWatch volume metrics | Measured |
| Cache at peak | 153 GB shared buffers | Parameter and instance history | Measured |
| Temp file volume, lifetime | 48 TB | `pg_stat_database` | Measured |
| Connection profile | 186 idle, 0 LISTEN, 0 advisory locks | `pg_stat_activity`, code audit | Measured |
| Capacity ceiling | 256 ACU limit hit repeatedly | Serverless scaling history | Measured |
| WAL rate | Unknown | Not readable on Aurora | Placeholder until replay |
| Core equivalent at peak | 35 to 52 current-generation cores | ACU peak with a platform correction | Estimated |

The right-hand column is the important one. A plan that mixes measured, estimated and unknown numbers without labeling them will look precise and be wrong. The single biggest correction in this plan, the platform generation factor, moved an estimate, and it moved the machine choice with it.

The method for the unknowns is a replay. Restore a snapshot of the production database onto the candidate machine, then drive it with captured production traffic at 1x, 1.5x and 2x rate. Read `pg_stat_wal`, the checkpointer stats, latency percentiles and CPU on a box that can actually report them. The 2x run answers the growth question. The 1x run answers the "is this box enough" question. Both answer the WAL question that Aurora could not.

## Part 6: Sizing the machine

With the sheet filled in, sizing becomes a set of explicit gates rather than a shopping trip.

**Cores.** Take the estimated core equivalent at peak, with its correction, and pick the size that clears the upper bound. Choose the architecture consciously. ARM instances offered the best price per core for this workload; x86 would have been required if I needed a specific disaster-recovery tool that only supported x86. Write that dependency down before it decides for you.

**RAM.** Shared buffers peak plus working memory headroom plus OS cache. Floor 192 GiB, plan 256 GiB for this database.

**Storage.** Local NVMe or network-attached block storage is the biggest fork. Local NVMe typically gives the lowest write latency, which is what a WAL flush on every commit wants. On most clouds it is instance-local storage: it normally survives a reboot, but the data is lost if the instance is stopped or terminated or the host fails, which is what a durability plan has to survive. Check your provider's rules. Network-attached storage survives instance loss and adds latency to every fsync. The worked example chose local NVMe for the primary and made the durability plan carry the risk: continuous WAL archiving plus a base backup tool, with a standby on network-attached storage in another zone as the next step. If your recovery objective cannot tolerate hours, the standby is not the next step, it is part of step one.

**The budget.** The planning budget was an on-demand figure of roughly $3,000 a month all-in, deliberately on-demand so that a wrong choice costs one month, not one year.

**The gates before buying.** The candidate has to pass all of these, and they are written down so that "it's probably fine" cannot creep in:

1. The instance size actually exists in the target region and zone. It did not, in the zone I first assumed.
2. The list price is verified against the catalog, not a blog post.
3. The business has signed off on the recovery time objective that a single box implies.
4. A single-disk fsync latency test on the real NVMe matches expectations.
5. The 1x, 1.5x and 2x replays pass their latency targets.

**Aside: why not just buy the biggest box**

Because the biggest box is not a plan, it is an apology in advance. It hides the measurement gaps, it costs the most, and when it still misbehaves you have learned nothing about why. Sizing from measured inputs means every surprise on the new machine points at a specific wrong number in the sheet, which is exactly what you want when you are debugging at two in the morning.

## Part 7: Durability and availability without a managed layer

This is the part where leaving a managed service costs you the most thinking, so it gets the most care.

**What RPO and RTO mean**

Recovery Point Objective is how much data you can afford to lose, measured in time: "at most five minutes of transactions." Recovery Time Objective is how long you can afford to be down. Every durability design is a pair of these numbers, and the honest ones are agreed with the business before the machine is built.

**Backups are WAL plus a base copy.** A physical base backup together with the required WAL gives PostgreSQL a consistent starting point for recovery. A continuous archive of subsequent WAL can then support point-in-time recovery within the available backup and WAL history. Validate the recoverable range with a real restore. [pgBackRest](https://pgbackrest.org/user-guide.html) handles the base backups and archive management. Note that archiving by `archive_command` ships completed WAL segments (or whatever `archive_timeout` forces out), so an archive-only recovery point depends on the latest successfully archived segment and can lag further if archiving fails; `pg_receivewal` streams WAL to a second location and can reduce that gap when configured and monitored appropriately. Both get configured and tested with a real restore before production data arrives. "Durability before data" is not a slogan, it is an ordering constraint.

**Checksums on.** Data checksums cost a little CPU and let PostgreSQL detect a corrupted page when it is read, instead of returning bad data silently. They detect corruption, they do not repair it. Turn them on when initializing the new cluster; enabling them later means running `pg_checksums` with the cluster stopped.

**A standby is a second copy of the write path.** Streaming replication ships WAL to a second server that replays it continuously. Asynchronous replication means the primary does not wait; you can lose the last few transactions on failover. Synchronous replication makes the primary wait for the standby: set `synchronous_standby_names` and use `on`, `remote_write` or `remote_apply` for `synchronous_commit`. With `on` or `remote_apply`, an acknowledged commit has reached the configured synchronous standby at the corresponding durability level. Preserving it on failover also requires promoting a standby that has the acknowledged WAL and a storage stack that honors flushes. `remote_write` is weaker against a standby operating-system crash because WAL has only been handed to its OS. The costs are commit latency and availability: if the only synchronous standby goes away, commits on the primary stall until it returns or you reconfigure, unless you run more than one standby. The choice is the RPO number from the business, expressed as a parameter.

**Failover is a procedure before it is a tool.** Tools like [Patroni](https://patroni.readthedocs.io/) automate promotion of a standby. Automating a procedure you have never run by hand is how you get a failover that promotes the wrong node at the worst time, or leaves the old primary still accepting writes. Fencing the old primary is part of the procedure. The plan here is deliberate: manual failover drills first, documented, timed, and repeated, then automation once the manual version is boring.

**The honest RTO of step one.** With a single primary and archived WAL, recovery from instance loss means restoring a base backup and replaying WAL onto a new box. For a database in the hundreds of gigabytes, that can be hours, depending on restore throughput and how much WAL has to replay, which is why the restore is timed rather than guessed. That number was put in front of the business as the cost of the first phase, and the standby was scheduled as the thing that brings it down. Managed services make this trade for you silently. Self-managing means making it out loud.

## Part 8: Building and proving the box

The build itself is the least interesting part once the thinking is done, but the order matters.

Infrastructure as code creates the instance, its security boundary and its storage; configuration management installs PostgreSQL 17 onto an XFS filesystem on the local NVMe with checksums enabled and the locale matched to the source, because a locale mismatch is a silent way to break index ordering after a restore. Access goes through a session-manager tunnel rather than a public SSH port. Secrets live in the platform's parameter store, not in a repository.

Then the proving sequence:

1. Synthetic load first. Before any production data, run a synthetic write-heavy load and watch the fsync latency, WAL throughput and checkpoint behavior on this specific disk. This is where a wrong storage choice shows up cheaply.
2. Durability next. Configure and test backups and WAL archiving. Perform a restore and time it. Include detection, provisioning, validation, and reconnecting applications in a full recovery drill; the restore time alone is not the whole RTO.
3. Restore the production snapshot and replay captured traffic at 1x, 1.5x and 2x. Fill in the WAL rate and derive the checkpoint settings from it.
4. Add the standby. Run failover drills by hand.
5. Only then plan the cutover window, with Aurora still live and untouched as the rollback.

Every step leaves the previous state intact. If step 3 says the box is wrong, the cost is one month of on-demand pricing and a corrected sheet.

## What this actually teaches

Strip the specifics away and the reusable model is short.

A database is a machine plus a write path plus a durability plan. A managed service bundles all three and hides the seams. Leaving one means finding the seams: which parameters describe your workload and travel with it, which describe the platform's physical write path and must be rederived, and which numbers you can measure at the source versus only on a replay. Size from labeled measurements, gate every purchase on tests you wrote down in advance, put durability before data, and make the recovery objective a business decision spoken out loud rather than a default inherited from a vendor.

The distinction that made the whole decision tractable is the one I would hand to anyone starting the same move: separate engine behavior from platform behavior. Aurora is PostgreSQL with a different machine underneath. Once you know which parts were the engine and which were the machine, you know exactly what you are taking on.

## Continue learning

Once the database is running, [Diagnosing Slow PostgreSQL Queries](/blog/postgresql-optimization) takes the next step: finding expensive queries and reading their plans. For the operating side, go deeper on checkpoint tuning under measured WAL rates, MVCC and vacuum, and streaming replication and failover.

## Sources and further reading

Primary sources this article leans on, and the places to go deeper. In rough order of usefulness.

- [PostgreSQL manual: WAL configuration](https://www.postgresql.org/docs/current/wal-configuration.html). Checkpoints, full-page writes and the recovery trade-off, from the people who wrote the code. Read this before touching any checkpoint parameter.
- [PostgreSQL manual: Reliability](https://www.postgresql.org/docs/current/wal-reliability.html). What the database can and cannot promise about your disk, including the torn-page discussion and the caveats about drive write caches.
- [PostgreSQL manual: WAL parameters](https://www.postgresql.org/docs/current/runtime-config-wal.html). The reference for `full_page_writes`, `synchronous_commit`, `fsync`, `wal_buffers`, `checkpoint_timeout` and `max_wal_size`.
- [PostgreSQL manual: Continuous archiving and point-in-time recovery](https://www.postgresql.org/docs/current/continuous-archiving.html). The durability model that pgBackRest and `pg_receivewal` implement.
- [PostgreSQL manual: Log-shipping standby servers](https://www.postgresql.org/docs/current/warm-standby.html). Streaming replication, synchronous standbys and the semantics behind `remote_write` and `remote_apply`.
- [PostgreSQL manual: Routine vacuuming](https://www.postgresql.org/docs/current/routine-vacuuming.html) and [Concurrency control](https://www.postgresql.org/docs/current/mvcc-intro.html). MVCC, dead tuples and why autovacuum settings are workload settings.
- [PostgreSQL manual: Cumulative statistics](https://www.postgresql.org/docs/current/monitoring-stats.html). `pg_stat_wal`, `pg_stat_database` and the other views used in the measurement sheet.
- [The Internals of PostgreSQL](https://www.interdb.jp/pg/) by Hironobu Suzuki. The best free deep dive on the buffer manager, WAL and vacuum. Chapters 8 and 9 cover this article's write path at code level.
- [Introducing the Aurora Storage Engine](https://aws.amazon.com/blogs/database/introducing-the-aurora-storage-engine/) from the AWS Database Blog, and the SIGMOD 2017 paper [Amazon Aurora: Design Considerations for High Throughput Cloud-Native Relational Databases](https://media.amazonwebservices.com/blog/2017/aurora-design-considerations-paper.pdf). The log-is-the-database model, from the source.
- [AWS: Building a PostgreSQL monitoring report](https://aws.amazon.com/blogs/database/build-an-oracle-awr-style-report-for-rds-aurora-postgresql/). Its Aurora-specific notes describe the unavailable `pg_stat_get_wal()` function and alternative CloudWatch write metrics.
- [PgBouncer features](https://www.pgbouncer.org/features.html). The table of what transaction pooling breaks. Check your application against it before choosing a pooling mode.
- [pgBackRest user guide](https://pgbackrest.org/user-guide.html) and [Patroni documentation](https://patroni.readthedocs.io/). The two tools that carry the durability and failover halves of Part 7.

## FAQ

**Is Aurora bad?**
No. Its storage model removes an entire class of failure and an entire class of tuning. This database outgrew its capacity ceiling and its cost curve. That is a fit problem, not a quality problem.

**Can I skip the replay and just size generously?**
You can, and you will not know your WAL rate, your checkpoint behavior, or whether your fsync latency is acceptable until production tells you. The replay costs a few days. Production telling you costs an incident.

**Why local NVMe if it disappears with the instance?**
For this workload, local NVMe was selected to pursue low WAL-flush latency. The tradeoff is instance-local failure, so the decision depends on measured performance and a recovery plan that meets the agreed RPO and RTO. Network-attached storage or a standby can change those tradeoffs; compare the actual devices and failure paths rather than assuming one is always faster or sufficient.

**Does any of this change for a read-heavy workload?**
The write-path sections matter less and the cache sections matter more. Size RAM to keep the working set in shared buffers plus OS cache, and lean harder on read replicas. The measurement discipline is identical.
