iTranslated by AI
re:Invent 2025: Amazon Aurora HA/DR Design Patterns and Aurora DSQL Global Resilience
Introduction
By transcribing various overseas lectures into Japanese articles, we aim to make hidden, high-quality information more accessible. This project brings you this presentation!
For re:Invent 2025 transcription articles, please check the information summarized in this Spreadsheet.
📖re:Invent 2025: AWS re:Invent 2025 - Amazon Aurora HA and DR design patterns for global resilience (DAT442)
In this video, Tim and Marc provide a detailed explanation of Amazon Aurora's resilience and HA/DR features. Aurora PostgreSQL and Aurora MySQL achieve zero RPO with six storage copies across three AZs and achieve an RTO of approximately 30 seconds in a Multi-AZ configuration. Features such as read scaling with up to 15 replicas, replication to up to 10 regions using Aurora Global Database, and zero-downtime maintenance using blue-green deployment are introduced. The second half explains the new Aurora DSQL architecture, describing active-active configuration, optimistic concurrency control, automatic sharding, quorum-based replication in multi-region clusters, and design philosophies with no single points of failure.
Note: This article was automatically generated while maintaining the content of the existing lecture to the maximum extent possible. Please be aware that there may be typos or incorrect information.
Main Session
Session Start: Basic Concepts of Aurora and Resilience
First, I would like to apologize slightly for the AV issues. You may encounter some challenges along the way, but I hope you will bear with us. Hello everyone, and welcome to DAT442. If you didn't come to learn about Aurora and resilience, you are in the wrong place. My name is Tim. Marc will join me shortly, and today we will talk about Aurora and how to bring resilience to your applications using Aurora.
Now, a show of hands, please. How many of you run databases in production? Most of you. Now, you are at re:Invent and not at work, but how many of you feel a little nervous about running a database in production? Some, quite a lot of hands are up. You keep a pager in your pocket for that reason, right? I'm glad you're here. Let's learn today. There are many things you can choose to make your system more resilient, and Aurora is no exception.
Well, let's first define resilience to make sure we are talking about the same thing. Resilience, in technical terms, is the ability of a workload to recover from failures, or the ability of infrastructure to recover from failures, the ability to dynamically acquire resources to meet demand, and the ability to mitigate failures caused by configuration errors. In other words, it is not just about when something crashes, and not just about when a server catches fire. It also includes performance and many other things.
And resilience actually has two pillars: availability and disaster recovery. Availability is the percentage of time that a workload is available. This is usually a measurement of past time. For example, you might say that you had five-nines availability over the past year. This is what we talk about when we talk about availability. The other is disaster recovery, or DR. Usually, when we talk about DR, it refers to the techniques we use to recover a workload when something goes wrong, which could be a volcanic eruption or perhaps human-made threats.
Here we use Recovery Time Objective, or RTO, as one of the measurements we talk about. This is the maximum time for a single event until service resumption. This is the operational recovery time. And there is Recovery Point Objective, or RPO. This is the maximum amount of data that can be lost, usually measured as an amount of time. It could be lost due to asynchronous replication, for example. And you might want an RPO of zero. That is also a valid value. Now, we are on the same page.
Let's briefly explain the agenda. Next, I will talk about Aurora PostgreSQL. Let's call this APG. And then Aurora MySQL, AMS. Please forgive me for using acronyms, as I will have to say these words thousands of times. Now, since these two are very similar, many of the features they support are similar. So, when it comes to resiliency, I will talk about them together. And midway through, I will hand over to Marc. He will talk about the same set of questions we ask ourselves regarding DR and HA. He will answer them again, but from the perspective of Aurora DSQL. So, please stay with us. The first half is Aurora MySQL and PostgreSQL. The second half is DSQL.
Basic Architecture of Aurora PostgreSQL and MySQL: Six Storage Copies Across Three AZs
Now, for those of you who don't know anything about Aurora, APG, or AMS, what are they? They are relational database services that combine the speed and availability of high-end commercial databases with the simplicity and cost-effectiveness of cloud and open source. APG and AMS are fully compatible with open-source PostgreSQL and MySQL engines, allowing you to run existing applications and tools without changes. Today, we will ask ourselves some questions—five questions—and if you have any questions of your own, please come to Chalk Talk 424 on Thursday and ask me there.
So, the first question we ask ourselves regarding HA and DR: What happens if a database node fails? In the case of self-managed—this is self-managed, you see the small tag in the corner—if you are just starting with self-managed, you might end up with a system like this. You have one node. You have the database engine. The storage is within the same node, and there is only one of it. This means all storage and execution work happens inside that node.
You might take backups with third-party tools. You might send backups to S3. When performing backups, some kind of quiescing process might be required, which could degrade performance and affect availability. This isn't very good. Since it is very difficult, you probably won't perform backups very often. Maybe once a day. This means your RPO will be around 24 hours. This is not very good.
And when that node goes down, it means both the storage and the engine are down. This is not good for availability, and it might not be good for durability either. RTO could be several hours. Not a very good situation. Now, let's look inside Aurora, and first talk about durability, the RPO part. You can start with a single database cluster in one Availability Zone on the left side. A single instance. And we will use this empty box at the bottom. We will fill this in as we go along today.
This is Aurora storage. Grover is its codename. This is where all the magic for Aurora for AMS and APG happens.
Aurora storage is a multi-tenant storage fleet. The storage nodes, represented by these large pink boxes, are distributed across three Availability Zones. Since they are multi-tenant, they also contain data from other customers, shown by the small colorful boxes. And what we do is, every time we write from the engine, we create six copies of that write across three Availability Zones. Customers only pay for one of those copies. This means that even if you lose an entire set of storage nodes in one Availability Zone, and one more, there is absolutely no durability issue. In other words, Aurora provides very strong durability from the start. Customers get six copies across three Availability Zones without having to configure anything.
RPO is zero because no asynchronous replication is performed here. Therefore, you get this immediately just by using Amazon Aurora MySQL and PostgreSQL. Let's delve a bit deeper into this area. What is the data we are storing here? Traditional databases write log records of what they are doing, then write pages, and sometimes take checkpoints. They need to do this in case of an interruption. What Aurora does is write only those log records. It never writes pages. It never writes pages to disk; it only writes log records.
Storage knows how to apply these log records to convert them back into database pages. This is necessary when you need to save space or satisfy reads. When you think about it, this means that Aurora has a complete timeline of what happened within the database. Every commit made to the database is stored in sequence. This is the reason why we can implement several of the features I'm about to talk about.
Continuous Backup and Multi-AZ Availability Patterns: Achieving RPO Zero and RTO 30 Seconds
One of the first features enabled by this is backup and restore. On the left, we have a production cluster where the database is performing writes. You see those colored lines inside the box? Those are the lineages of different database pages and their log records. What we do is the storage engine, not the head node, is continuously backing up all that data to Amazon S3. The first key point here is that the head node is not doing that. So it will never impact the head node's performance. It will never be quiesced. It is done continuously. It's always happening.
So what can you do with this? It enables point-in-time restore. From the earliest restorable point in time—which can be configured for up to 35 days, you can set that in the retention window—to the latest restorable point in time—which for a busy database is about 5 minutes ago—you can select any point in time between these two. Let's actually perform one of these restores. I don't have much imagination, so I'll choose time equals seven and execute this restore. What happens is that those storage servers pull that storage data back from Amazon S3. Then they apply the internal log records to bring it up to exactly that point in time. Then it starts the engine, and the engine executes standard transaction recovery logic, which means it processes interrupted transactions and so on at a logical level.
So, to answer the question, the second part of your job is really easy because all of this is provided out of the box. You didn't have to do anything to support point-in-time restore. Aurora is doing it for you in the background. That's about data, but what about the availability of database instances? In the most basic configuration, it looks like this. You have one instance. If a failure occurs, you could build another instance, but it takes 10 to 15 minutes.
So what you can do is spin up another instance here, let's call it a standby. Aurora keeps this in sync too—remember, they share the same storage, and for every transaction that occurs, it notifies the other instance. Now you have a replica; let's keep it the same size for when some failover is needed. When some failover is needed, the other one can take over really quickly, in just a few seconds, and because it's the same size, it can handle the same amount of load, right? This one becomes the primary.
This results in an RPO of zero because it's shared storage. We're not replicating the storage. You don't have to worry about asynchronous commits or anything like that. When a failover happens, the RTO is typically about 30 seconds. By doing this, it becomes one of the patterns that achieves what we call the Multi-AZ availability pattern, and you can truly improve availability.
Handling Performance Fluctuations: Up to 15 Replicas and Auto-Scaling
The next question is about performance. Performance fluctuates. Your application might be pushing harder or lighter, and you might be wasting money, so you want to be able to respond to these changes in performance levels. In open source, there are two main ways to do this: scaling up instances, which probably means buying hardware and performing a migration, which is a bit tough; or scaling out, which requires recognizing at the application layer that you are splitting the database into multiple parts, and the application needs to know which part to talk to. This is really difficult in terms of consistency, and you have to deal with that as well. And noisy neighbors are also difficult to deal with in this situation.
So, let's go back to Amazon Aurora MySQL and Amazon Aurora PostgreSQL. What can we do about this? Well, you can add replicas, as I explained earlier. You don't have to add them just for availability purposes. You can also add them for performance purposes. Because you can just send reads to that other replica. You will see older data.
Within the scope of asynchronous lag—it might be about 100 milliseconds—it is completely offloaded. It does not affect the writer's performance at all. Now, if you have another workload, for example, some kind of analytics job, you can run it on another replica. Then, all the resources on that replica are isolated for that application. The buffer pool is the most important thing for performance. So, in terms of resilience to performance changes, being able to isolate noisy neighbors is really important.
You can add up to 15 of these replicas, so you can configure them quite granularly. Each one, in very large cases, can be a 48 X-large, which is 1.5 terabytes of memory. That's a big system, right? And you have 15 of them? Now, I haven't talked about storage scaling yet, but that's because you don't need to worry about it. Storage scales automatically in capacity, and performance also scales automatically. There is no performance provisioning in Amazon Aurora MySQL or Amazon Aurora PostgreSQL at all.
Now, instance scaling. You have instances on the side here; this is an R9G, the latest Graviton 4. It's a 16 X-large, a pretty big box, but not the largest one we make. Now, you can add one of the same size. This is suitable for the failovers I talked about earlier. You can also add different sizes: 8 XL, 4 XL. You can also add this thing called DB.serverless. I'll talk a bit more about that. This is an elastic instance that scales from zero to a maximum of 256 Aurora Capacity Units.
When you have many instances like this, you need to decide the order in which to failover. There is no point in failing over to one of the 8 XLs if it's too small to handle the load I have. So, you need to define what we call these failover tiers. The lowest number tier, tier 0 in this case, is the one that will be failed over to first. I'll talk a bit more about those serverless instances, but since they can scale, you have resilience against workload spikes. And you won't get stuck there and keep paying a lot of money. It will scale back down again.
Connection Management Optimization: Endpoints and AWS Advanced Wrapper Drivers
Having all these instances is good, but your application needs to connect to them somehow. And knowing which one is the writer can be a bit of a hassle. When you need to send transactions that include writes like updates, you need to connect to the writer. How do you do that? Besides, you don't want to have so many connections. Having a lot of idle connections is not good for performance, and it's not good for cost. You don't know which connection goes where, and even if you could solve that, the overhead would be high. So, for self-managed, it's probably not a good situation.
So, here you can use two techniques: pooling and limits. You can limit the number of connections per database instance. Larger instances might need more connections than smaller instances, depending on the type. You can avoid reconnecting. This is all quite standard, and there are no special Aurora elements here. If you've been dealing with databases for a while, this should look quite familiar. Some of these things are already provided by the driver frameworks you're using, like if you're using Spring or JDBC or others. However, they tend not to work with clustered databases like the ones we're using here, because they don't understand what's going on.
So let's talk about endpoints first. In Aurora, there are generally two endpoints. There is a writer endpoint, which always points to the node that is currently the writer. And when that changes, we make it point somewhere else. So you can always send writes to the writer. Then there is a reader endpoint, which, remember, since there could be 15 of them, points to a pool of instances that can accept reads, using DNS round-robin. Since it's pooled, you can also do rough load balancing there.
If a failover is needed, you just re-point the writer endpoint. This can be done very quickly with a DNS lookup and reconnect. The application already needs to handle this reconnect for other errors as well. So in this way, you can basically switch over in about 35 seconds, which is DNS time. For further flexibility, you can also create custom endpoints. If you want to group some endpoints and call them, say, an analytics endpoint, that's also possible, as you like.
Now, on top of this, there is something called the AWS Advanced Wrapper Drivers. This is for when we talk about availability, not just performance issues regarding those connections. Each piece of code in your application needs specific reconnection code internally to deal with those errors. You need to recognize that this is a retryable error and deal with it. This is availability time, so you need to do it fast enough, which is a bit of a problem, right?
So, Aurora gives us two additional tools: rapid drivers and RDS Proxy. The rapid drivers have detailed knowledge of what's happening inside the cluster. They know which is a reader and which is a writer at any given moment. Therefore, they can handle failovers much more quickly. These are built by wrapping existing platform drivers like JDBC in this case, but they also support ODBC, Node.js, Python, and many others. If you have already validated a platform driver, we won't change it.
We just wrap it with a few plugins. One of those plugins is called Enhanced Failover. Another is for read-write splitting and blue-green deployment, which I'll talk about later. There are a few others. If you're not using these drivers, we strongly recommend that you use them. They are excellent for various reasons. This can also reduce failover time to about 6 seconds.
If you're interested, there's a QR code for the GitHub project there. These are all open-source. We're not doing anything secretly that you can't do yourself. We're just doing it on your behalf. Now, everything so far has been within one region, but what about multi-region? What happens if an entire region fails? Well, that could be a problem. If your business needs to continue while that region is down, or if that region isn't failing but is disconnected from the network, which is perhaps a more likely failure scenario.
What we have here, what we want, is to have a copy in another region. And we want it to be as up-to-date as possible, we want it to not cost too much, and we want to be able to use that copy for other purposes as well. If you are self-managing, this is quite difficult. With Aurora, we have Aurora Global Database for Amazon Aurora MySQL and Amazon Aurora PostgreSQL. You can add up to 10 of these, though the slide isn't big enough to show more than one, but you can add 10 secondary regions.
In Region A on the left, we have the same diagram as I've been talking about for the last 15 minutes, with some replicas and storage. When you add another region to this system, we launch replication servers and replication agents inside Aurora. We handle the asynchronous physical replication between them. Note that the head node is not involved in this at all. This is not logical replication. You don't have to pay the performance cost of something like MySQL binary logs. We handle everything internally.
This means that on the application side, it doesn't even realize this is happening. So, you can have up to 10 of these global secondaries without the application being aware of it. When you write these log records—those colorful boxes I'm good at drawing—they are also replicated to the storage side in Region B. You might notice that in my diagram, there is currently no head node in Region B. There is only storage. This means that in this particular configuration, it's good for data availability and durability, but not very good in terms of availability. You are not in a state where you can run workloads over there.
The RPO, or lag, between Region A and Region B is typically about one second, as it is asynchronous. This depends on your choice of region pairs. Unfortunately, I cannot do anything about the speed of light, so if the regions are far apart, it will be a bit slower. And if you need to, you can add other instances to the secondary region. I am drawing a symmetrical configuration here, but it doesn't have to be symmetrical at all. You can have as many different numbers of instances as you like. And these are read-only nodes. They are replicas like the ones I described earlier, so you can perform low-latency local reads.
If you don't test it, you don't know if it works. So, the first thing you need to do is use this thing called the Global Endpoint. Same question as before, how do you know which writer to specify? When you zoom out to the next level, the global level, how do you know which region is the primary region at that point? That's where this so-called Global Endpoint comes in.
If something goes wrong in Region A, you have the Global Endpoint name there, so you would first trigger a failover. I will explain this in a bit more detail. This means the writer will move to Region B. This is a managed operation. You can see the 'allow data loss' flag in the bottom corner. This is to remind us all that this is asynchronous replication. Therefore, anything that was within that asynchronous replication window could potentially be lost when you perform a forced failover.
Once that is complete, the writer moves to the other region. We now have a new primary region, Region B. And the Global Endpoint is pointed there using the Route 53 data plane. So, this happens as quickly as possible. This gives you very high write availability across multiple regions. What if nothing has failed in the global database? You just want to perform what is called a switchover. This is done when both Region A and Region B are healthy, not when one of them has failed.
What we want to do is tell Region A to stop being primary and tell Region B to become primary at this point. Now, the way we built this to be achieved so quickly is very interesting, so I would like to explain it in a bit more detail. We have this log record stream, so we insert this special log record, a marker log record, into that stream. And it flows through as I just explained, and the other side confirms it. Once the other side confirms it, it decides at this moment in log time—not wall-clock time—that I should become primary right now. And Region A realizes that it should stop being primary at that point. In other words, a clean handoff is achieved, the RPO is zero, and the RTO is very low.
I thought this was very interesting, so I wanted to share how it works.
Maintenance and Upgrade Strategy: Organizations upgrade rollout policy and blue-green deployment
And we also know that this gives you an RTO of about 30 seconds and an RPO of zero. The last question I ask myself is about maintenance. For example, version upgrades. We are fully open-source compatible, so there are versions. We have PostgreSQL 16, and you might need to make it PostgreSQL 17. So, how do you do that?
If you are self-managing, you need to take a downtime window. You need to talk to your customers and coordinate when you want to take that downtime. You need to take snapshots so that you can roll back. If you don't have excellent storage like we have, that might be difficult. You need to coordinate with everyone. You need to do compatibility testing, and a lot of it, between applications, between old database versions, and everything else. What people often overlook is performance. When you perform an upgrade, even if you just restart, performance will likely degrade because you just restarted the engine and lost the buffer pool. So, if you are self-managing, performance testing must be part of your upgrade compatibility.
For Amazon Aurora PostgreSQL and Amazon Aurora MySQL, because we are fully open-source compatible, we cannot ignore this. We must maintain a strong security posture. So, we provide a fully managed and automated minor version and patch upgrade experience. You can see here in the console that there are some maintenance actions. There are upgrades available for this database cluster. We now perform rolling operating system upgrades, which we didn't do before, and this improves availability.
Define a maintenance window. If you don't want to define one, we will define it for you. This means that this system will receive automatic maintenance within this time frame. Maintenance notifications can be received here and in the AWS Health Dashboard, and all of this can be automated if you wish. This is opt-in. Of course, we strongly recommend opting in, because you no longer need to think about it and we will handle it.
Now, here is something new for us. It is the AWS Organizations upgrade rollout policy. It is a bit of a long name, but what it means is that we have had a good story for automating the lifecycle of a single database cluster for a long time. However, I suspect most of you don't just have one database cluster. You probably have a lot of them. You have a whole fleet, and you probably want to manage them in development, QA, production, or some other mechanism. But we haven't really provided a way to deal with that until now. That is where the Organizations upgrade rollout policy comes in.
On the left side, there is a GUI screenshot, and on the right side, there is a JSON version of the same thing. What this means is that you set policies based on tags. Here, there is an 'env' tag, and for every resource in my AWS organization—which could be an account or a database cluster—where the value of the 'env' tag is 'prod', it says that it will be upgraded last. You can see a few others too. If the value of 'env' is 'dev', it must be upgraded first. And for those that don't have tags I recognize, they are upgraded second. That is the default at the bottom.
So, how is this actually done when rolling out? Once you build that policy, you need to assign it to resources in your organization. That could be an account or everything in the organization. Then, you will be able to see this. It is determined that the upgrade order of that resource is second. This is really helpful. We notify first, then wait for the maintenance window of the first wave of resources, and then upgrade. After that, we leave them for a while to observe, wait for the maintenance window of the second wave of resources to come, and then upgrade. We also leave them for a while in the final wave.
In reality, we don't block from the first wave to the second wave, but we are waiting. If you find any issues in the meantime, you will know how long that window is. This depends on the resource. At that point, you can remove the tag or turn off 'auto minor version upgrades' to stop the progress of the upgrade.
Regarding in-place upgrades, when performing a major upgrade, by definition, it is not compatible with open source. You can upgrade in-place. You start by creating a clone of the database cluster, which is very fast and costs nothing. Except for the changes you make to the storage, you will not be billed for the storage. And you can practice with this clone. You can upgrade the clone. You can test the clone with your application. And if there is no problem, you say, 'Okay, discard the clone and upgrade in production.' This is one way to perform a major version upgrade in-place. It is very simple.
As a more flexible method, if possible, you can use what is called blue-green. Here is the production environment. It has several replicas and endpoints, and we use blue-green to perform a major upgrade. You don't have to use it only for major upgrades. You can also use it for schema changes, static parameter changes, and things like that.
Blue-green means keeping the existing environment, called 'blue', and the new environment, called 'green', in sync using logical replication. You don't have to do this; we do it for you. We perform the upgrade and keep it in sync using logical replication while you perform the tests. If there are no issues, you trigger a blue-green switchover. In a switchover, we promote the green to production. The old resources are still there. All resource names are changed, so you don't need to fix scripts later. After the blue-green is completed, it will be as if nothing had happened. It is very flexible, and this switchover can be completed in as little as one minute.
You might have missed it, but this same blue-green capability has just been announced for Global Database as well. Here you have a blue configuration and a green configuration, in this case spanning two regions. Everything I just explained about blue-green is exactly the same, with the difference being that it spans multiple regions. By now, you have learned that Aurora PostgreSQL and Aurora MySQL provide protection against the failure of an entire Availability Zone plus one, straight out of the box, due to the storage underneath. And we have looked at how you can increase availability and enable failover by adding some replicas here. We can also make that smoother by using the AWS advanced rapid drivers.
Next, we learned how to use Global Database to provide durability and availability across up to 10 secondary regions. It supports low-latency local region reads and simple cluster endpoint management via its global endpoint. And finally, we learned some patterns to follow to keep your database clusters up to date, using managed, automated cluster-wide upgrades, fast clones, and blue-green. Now, I will pass it over to my buddy, Mark. When he comes up, he might change the slides, but he will tackle the same five questions again, but this time from the perspective of DSQL. Thank you.
The Arrival of Aurora DSQL: Active-Active Architecture and Eliminating Single Points of Failure
Hello everyone. My name is Mark. I apologize for the unexpected downtime. In the remainder of this talk, we will look at building resilient applications using Aurora DSQL. Aurora DSQL is the newest engine in the Aurora family. Aurora has been around for about 10 years, but this one is only six months old. And DSQL was born from the request from our customers to provide the best parts of relational: the ability to run complex queries, joins, and evolve schemas. It also provides the best parts of distributed database architectures like DynamoDB—that is, no single points of failure, and scaling out instead of scaling up. And not only that, it also has the best parts of serverless services like Lambda: the ability to pay only for what you use.
We will revisit all five questions, starting with what happens if a database node fails. But before that, let's have a crash course in the DSQL architecture. On the screen, you see a self-managed Postgres downloaded from the internet and running on an EC2 instance. The application is connected and exchanging credentials. The server forks itself and creates a Unix process dedicated to the connection. This is known as a backend process. When you connect multiple times, even more processes are created. And each of these sessions can parse SQL, plan, and execute queries, running them against local storage. Of course, they can also perform updates. These are sent to the write-ahead log, which is used to keep storage up to date.
Remember these three components, because they will reappear right now. This is DSQL. The application is connected to a component called the Query Processor. This is exactly like that backend session. You get one of these for every connection. And just like we saw with Postgres, you can send SQL SELECT statements, which are translated into read queries and sent over the network to the DSQL storage engine. Writes, on the other hand, behave a little differently. When you execute an INSERT statement to add a new row to the system, that row is buffered in the memory of the Query Processor. When you execute an UPDATE statement, the Query Processor receives the update, translates it into a read against local storage to get the current version of the row, processes the statement to generate a new version of the row, and again keeps it in memory. You can continue doing this—INSERT, UPDATE, DELETE—as you build the transaction, until you call COMMIT.
When you call COMMIT, the entire bundle you requested from the database is sent over the network to a service called the Adjudicator. This is responsible for concurrency control. In other words, this is the part of the DSQL architecture that checks if there are any conflicts with other transactions running in the system. Committed transactions are sent to a service called the Journal. This is a backbone service for major AWS services like S3, and the Journal is responsible for durability. It replicates new transactions to at least two Availability Zones. And finally, just as we saw with traditional Postgres, it uses that journal to keep storage up to date. When you open another connection, another Query Processor is created.
That Query Processor can execute both reads and writes, but there is nothing in this architecture that says the Query Processor must run on the same host or must run within the same Availability Zone. DSQL is an active-active service. This means any connection can read from or write to any data at any time.
So let's talk about availability. What happens if a database node fails? We are connected to that blinking QP in Availability Zone 2 and are running some complex joins. Then, the storage node we were communicating with fails. It explodes. Oh no, what should we do? The answer is that the customer doesn't need to do anything because the QP will detect the failure. The QP starts shifting traffic to healthy replicas. These replicas might be in the same zone or in a different zone. As shown in the slide, it continues processing with only a slight increase in latency for the ongoing operations that needed to be retried.
Meanwhile, DSQL is continuously backing up data and detects the loss of this node. DSQL takes the latest snapshot and creates a replacement node in the same zone. That node comes online, connects to the journal, and catches itself up to the latest state. And the Query Processor starts shifting traffic to the local replica. This provides the best performance because latency within an AZ is simply better.
But what about writes? What about that adjudicator in Availability Zone 1? Well, the reason for having a single adjudicator is to allow this conflict resolution protocol to run very fast without adjusting across the network. However, single points of failure are not desirable. So what DSQL does is maintain standby adjudicators in other zones. Look at the arrows from the Journal. These standbys are simply following everything the leader adjudicator is doing. And if a failure occurs, within just a few milliseconds, these standby adjudicators run a leadership protocol. One of them becomes the leader. Lo and behold, it is in Availability Zone 2. And the QP retries the ongoing commit against the leader. There is nothing the application needs to do. It works immediately.
Now, there is much more going on in the DSQL architecture than I can show you on this slide. But the good news is, you don't need to know how these mechanisms work. DSQL is an architecture designed for high availability. DSQL has no single point of failure. Whether you are spending a few pennies a month on DSQL or running it entirely within the free tier, you get active-active right out of the box. But of course, DSQL is designed to scale. Let's dive into how we achieve that.
First, let's talk a bit more about that concurrency control protocol. DSQL uses a protocol called optimistic concurrency control, which is based on the assumption that transactions rarely conflict with each other. But what happens if a conflict occurs? Here we have two clients trying to update the same row with ID equals 1 to different values. The actual values don't matter, but they both prepare their transactions and race toward the adjudicator. Then, the upper transaction reaches it first. The adjudicator records that transaction in the journal, and the other client receives a PostgreSQL serialization failure error and is instructed to retry.
And when you build an application on DSQL, you need to handle this within the application. When you call commit, you need to deal with availability issues, and you also need to deal with the issues of optimistic concurrency control. You simply retry. This is just a few lines of code. It's a while true loop. And what we recommend is building a small helper function that you can use throughout the application. Or if you are using some framework, place it at the lowest possible layer.
Now, you want to design your application to avoid unnecessary conflicts so you don't have to retry. If you do that, you'll be able to commit these two transactions at the same time. Note that they are updating different rows. And as you keep repeating this, the load on the adjudicator and the journal might start to increase. So, what happens then? Well, before we run out of capacity on the adjudicator or the journal, DSQL notices this increase in utilization and begins to shard itself internally.
And if you are updating several records, the QP automatically recognizes this internal sharding strategy and routes the commit to the appropriate stack. But of course, sometimes you might execute transactions that touch rows spanning multiple shards. DSQL handles this automatically for you. We have an optimized implementation of two-phase commit that ensures transactions are committed atomically, even if they span multiple shards. The same thing is happening on the storage side, but I don't have enough time to touch on that today. I do, however, want to talk about rescaling.
So, imagine you have many connections open. These are all executing selects, putting a load on a single storage host, and as the load increases, latency might also increase. However, in this case, too, long before this becomes a problem, DSQL detects it. And using the same tricks we saw in the availability slide, DSQL brings new nodes online using the latest copy of the data.
That node catches itself up from the journal, and the query process automatically begins load balancing across these replicas. You can continue to scale this out limitlessly, and DSQL is doing this for you automatically. The key reason we can achieve this is because replicas in DSQL are always strongly consistent.
To understand this, let's create a new DSQL cluster. It's completely empty, not a single row of data. I've created a table called my table. And right now, I'm just about to insert the first row into this table. Let's do it. The data is written to the journal and committed to at least two availability zones. That means the journal has received your data, and we will send this commit confirmation back to the client.
Now, what you'd expect is that if you start a new transaction and execute "select star from my table," you should be able to see the row, right? Otherwise, it would be an eventually consistent system. Eventually consistent systems are very difficult to reason about, and writing correct code for them is very hard. This is the reason for our small technical interruption. I was using an old slide.
In DSQL, what we are doing is using a time-based synchronization protocol, combining two technologies here. The first is using the EC2 time sync service. This provides microsecond-accurate timestamps using GPS clocks. The second technology is using a library developed by AWS called Clockbound, which allows us to account for errors in those measurements. Combining these technologies gives us linearizable values. That is, a timestamp that is guaranteed to be later than any commit timestamp the service has issued before.
Once you get this transaction start time, you include it in the API request to storage. The role of storage is to recognize that it is lagging, wait for updates to come from the journal, and then return the row. So, how do you manage connections? We have six connections to DSQL here; how do you get them? Well, between the application and the query processor, there is a service called the session routing layer. Its role is to ensure that connections are always available and that you can get connections quickly, even if hundreds of thousands of connections are dropped due to network events.
This is a very deep and complex service, but at a high level, what's happening is that there is a large warm pool of these query processors. Again, each of these boxes represents a single process. Our team maintains a large fleet of EC2 instances and is responsible for capacity management. On these instances, we have packed query processors that are ready, running, and just waiting for connections. When you request a connection, DSQL simply takes one of these query processors from the pool, and the application can begin executing its transaction.
Now, let's look at connection failures. You have six connections open, and one of them fails. Ideally, from an RTO perspective, what's happening here is simply that an error occurred on one-sixth of the connections. The other five connections are perfectly healthy, right? This is a system with no single point of failure. All the application needs to do to handle this is detect the failure and retry. This is where the retry handler that appeared in the optimistic concurrency section comes in handy. If you add a retry for connection errors, you will get another connection and return to 100% availability.
Now, unlike storage failures or adjudicator failures, you cannot have the application automatically reconnect to these. This is something you need to do. To leverage DSQL, you need to incorporate functionality into your application to detect failures and retry with a new connection. Actually, we were quite worried that customers might not notice this. Because, you know, it feels like "look at page 43 of the manual." So, what we did instead was set the maximum lifetime of a connection in DSQL to one hour.
By simply using the best practices for client-side connection pooling libraries—this is the C3PO library for Java—and setting it to perform health checks and setting a maximum connection time, your application will immediately follow our best practices. Now, for DSQL, we recommend using client-side connection pooling, but you don't need to use server-side connection pooling. You don't need PG Bouncer, and you don't need RDS Proxy. Because the query processor layer is a separate service and horizontally scalable. We were able to build the concept of connection pooling directly into the service.
You are free to run PG Bouncer if you want to, but it will only add the need for management, patching, and availability monitoring. You won't gain any benefits. Now, throughout this talk, I have been showing you how applications communicate with query processors in the same zone.
And the reason we do that is to lower latency. In interactive Postgres transactions, we are constantly going back and forth between the client and the application. Each of these round trips takes time. Therefore, by communicating with the query processor in the same zone and the storage host in the same zone, we can provide the best performance.
Now, even in the unlikely event that an application is available but DSQL completely goes down in one region, don't worry. DSQL is equipped with functionality to automatically fail over to a healthy zone from top to bottom. In other words, even if an entire zone becomes unavailable, you can simply reconnect to a healthy Query Processor. For those who want to know more about this part of the service, please join us for session 439 tomorrow at 1 PM. We will dive deeper into how we built this.
DSQL Multi-Region Clusters: Witness Regions and Active Redundancy Patterns
Now, let's talk about region failure. In DSQL, you can set up what's called a multi-region cluster. The way to do that is to create a cluster in Region A, create a cluster in Region B, and specify a third region as a witness region. Now, you'll notice there are no storage boxes in the witness region. There are no Query Processors and no applications, either. The role of the witness region is simply to hold a copy of the journal. I'll talk about the reason for that in a moment.
Once you do this, DSQL pairs these journals using a quorum-based protocol. And your applications can continue to operate in an active-active manner across regions. Here, we have an application in Availability Zone 2 of Region A, and an application in Availability Zone 2 of Region B. And both can perform writes.
So, what happens if Region B fails? Well, try to imagine this. If there were no witness region, it would be very difficult to distinguish whether Region B had failed completely, or if Region A and Region B simply could not communicate with each other. This is where the witness region comes in handy. Because it votes with Region A to kick B out of the quorum. And DSQL can detect this automatically.
DSQL reconfigures the journal so that only A and C communicate with each other. And if by some chance you were able to connect to the Region B cluster, you would find that read and write operations are completely unavailable. This happens automatically again, with no intervention. It happens very quickly. And by doing this, you can continue to use the Region A cluster. No data loss ever occurs. And even as you continue to write data to Region A, DSQL maintains the guarantee that transactions are replicated to at least one other AWS region before a commit is acknowledged.
Meanwhile, later on, Region B comes back online. DSQL detects it. It catches up to the latest state. And then it reverts those configuration options, returning to two zones.
So, how do you leverage this? The pattern we recommend is the same one we've been using throughout this talk: the active redundancy pattern. That is, you should deploy your application in parallel with the cluster in Region A, and you also need to deploy it in parallel with the cluster in Region B. There are a few reasons for this. The first reason is that you get the best performance. That is because you have low-latency connections to the cluster. But the second reason is that this allows you to continuously verify that your application is working in both regions.
On top of this setup, you need to create some kind of global endpoint. You can achieve this with something like a Route 53 DNS record. And it automatically directs customer traffic to the nearest available healthy region. So, what happens if something goes wrong and Region B goes offline? No data is lost, and DNS begins shifting customers to the healthy region. And you know that this region is healthy. Why? Because you've been running it all the time.
Maintenance-Free DSQL and Session Summary
This is my favorite slide—it is my absolute favorite among the ones I had to create for re:Invent. Because there is not much content on it. The reason is that with DSQL, there is simply no maintenance for you to worry about as a customer, just as there is no maintenance for you to worry about as an S3 customer. DSQL is a fully managed service. Our active architecture allows us to perform far more maintenance on your behalf.
Think about the Query Processors. They only run for an hour. After an hour, either the customer disconnects or we disconnect them; we discard them and create new ones. And those new ones are equipped with the latest operating system, the latest security patches, the latest performance improvements, and the latest features. So, as a customer, you really don't have to do anything.
So, to summarize today's talk: Aurora has three engines. Aurora for Postgres, MySQL, and our newest engine, DSQL. All three of these engines provide three-availability-zone durability right out of the box. All three of these engines provide the ability to scale your workloads. For Aurora PostgreSQL and Aurora MySQL, you primarily scale up for writes and scale out for reads. For DSQL, we provide hands-free, automatic scaling, but you need to ensure that your application schema is designed to work optimally with the DSQL architecture.
If you can no longer handle things in a single region, consider multi-region. With Aurora PostgreSQL and Aurora MySQL, you can practice failover testing without losing data. With DSQL, you can take advantage of active-active across regions. And finally, all three engines provide simple maintenance with automated security updates and minor version upgrades.
Thank you so much for attending our talk. Tim and I will be hanging around, so please come by with any questions. Thank you. Have a great re:Invent. Please fill out the session survey in the mobile app.
















Discussion