AWS Bites Podcast

122. Amazing Databases with Aurora

In this episode, we provide an overview of Amazon Aurora, a relational database solution on AWS. We discuss its unique capabilities like distinct storage architecture for better performance and faster recovery. We cover concepts like Aurora clusters, reader and writer instances, endpoints, and global databases. We also compare the serverless versions V1 and V2, noting that V2 is more enterprise-ready while V1 scales to zero. We touch on billing and additional features like the data API, RDS query editor, and RDS proxy. Overall, Aurora is powerful and scalable but not trivial to use at global scale. It's best for serious enterprise use cases or variable traffic workloads.

AWS Bites is brought to you by fourTheorem. If you need someone to work with you to build the best-designed, highly available database on AWS, give us a shout. Check us out on fourtheorem.com!

In this episode, we mentioned the following resources.

Let's talk!

Do you agree with our opinions? Do you have interesting AWS questions you'd like us to chat about? Leave a comment on YouTube or connect with us on:

00:02:13

So is this something we can achieve on AWS? If yes, what kind of services we should be looking at and try to analyze and decide if they really fit our description. And the first service that comes to mind is Aurora. So what is Aurora? So if you're looking for a relational database on AWS, you have a few options. You're probably aware of RDS, which is a service that allows you to create relational databases and supports a big number of databases, including SQL Server, Oracle, but also open source ones like Postgres, MariaDB, MySQL. And the idea is that they give you a service that is somewhat managed and it somehow removes some of the pain points of having to manage databases, but it's still running on EC2 instances. So it does abstract some things, but there is still a bit of the pain point of having to manage servers. So with RDS, you also have another category of databases, which is the one called Aurora. And Aurora promises to deliver MySQL and Postgres compatibility with performance three times faster than the regular one that you find in the regular MySQL and Postgres RDS. On top of that, Aurora has some different characteristics that are only possible because effectively AWS reinvented this kind of databases. It's a service that they somewhat recreated, provided the compatibility with the protocols of MySQL and Postgres. So they figured out clever ways to optimize the service more than what you would get with the open source alternatives. So let's try to dive into the details. Maybe we should talk first about the storage, because I think that's the first thing that comes to mind when we try to think why Aurora is different from just a simple MySQL or Postgres.

00:07:04

So we can also call them read replica if that term is a little bit more familiar to you. And that's something that allows you to handle read scalability. So you can easily spin up more instances if you see that you need more throughput in terms of read. There are ways to do auto scaling. So you can set up auto scaling policies, and this allows you to basically look for things like CPU utilization or number of connections to provision new reader nodes as you see that your traffic increases. And of course, you can also scale it down if you see that that traffic decreases. So each instance in the cluster will have its own endpoint. So this is the idea that you need to have a way to connect to the specific instances. So every instance has its own kind of address that allows you to connect to it. But there is also a concept of a cluster read and write endpoints. And these endpoints are kind of the preferred way to connect to a database because they will automatically do all the routing for you, figuring out which instance is the most appropriate to handle that particular request. And this is important because, for instance, as you scale up and down, or maybe if there is some failover in your cluster, that layer, that kind of global endpoint will know exactly what to do to make sure that your request gets answered correctly. If you manage your own connection directly to the specific instances, then doing all of that stuff is on you. And of course, that's not always fun to do. It can lead to all sorts of problems. So try to avoid it unless you really know what you're doing. So on the topic of failover recovery, if your writer fails, because remember, you only have one writer, so you might be wondering, okay, what happens if that writer fails? Of course, there is some kind of failover mechanism. Aurora will automatically promote one of your replicas to a writer. So this is all within a single region. We mentioned also that Aurora supports the concept of multi-region, which is something that seems really, really cool and promising. And if you ever tried to do a multi-region database, you know that it's extremely complicated to do it correctly. So maybe we should talk a little bit more about this particular characteristic of Aurora.

00:18:59

And the primary difference is that scaling you mentioned. Aurora Serverless means you can scale vertically without having any failover. And that's really one of the sweet spots here. Because normally, if you've got a provisioned instance and you decide it isn't big enough for your needs anymore, you would have to add a larger instance size as a reader and then promote it to the writer and then deprovision the old one. And that takes time, and you might have outage time on the right instance while you do that. Otherwise, the management overhead between Aurora Serverless and provisioned Aurora isn't really that different. As he said, you still have maintenance windows, you can reboot the instance. It doesn't really seem like a serverless product. It has a serverless badge, but I think it's a little bit of a mask it's wearing, to be honest. It might be a good fit for your pre-production or development databases where you might have lots of idle time and then you just want to scale them up as you deploy and run test workloads. So that might be one of the cases where you can actually make use of the cost difference. Because generally, Aurora Serverless will cost you more if you're comparing gigabyte for gigabyte. And it will only really start becoming cheaper if you've got that really variable traffic pattern and you spend a lot of time scaling down from peak capacity. So we mentioned cost a few times. So let's go into cost a little bit. I've done some calculations on this. Maybe we can share the link to this cost calculator, the AWS pricing calculator in the show notes. And if you look at the cheapest possible serverless V2 instance, so 0.5 ACUs, you're talking about around $50 a month. Whereas the cheapest Aurora standard that I could find at least was just a little bit more expensive, closer to $60. But that was for a much bigger instance. So I think it was, I don't have it two hands right now, but I think it was eight or 16 gigabytes of RAM. So you're already getting far more compute and memory than you would for the serverless version. Now, if you compare that to the cheapest possible one you can get on RDS, I could pick one there that costs $15 a month. Of course, all of this, you have to try it and measure it yourself. There's no way of saying there's absolute price comparisons between all of these options. It depends on your storage, your traffic and everything. So you really just have to give it a go. If you were to look at an R6G large, this is a Graviton memory optimized instance, I think 10 gigabytes. So that's kind of entry level when it comes to Aurora standard. You're looking at provisioned cost of over $200 a month. But if you wanted Aurora serverless as a primary in your cluster, you're going to need ACUs like you mentioned, that's going to cost you $400 a month. So if you're like a startup bootstrapped solopreneur, you might be looking at some of these costs thinking this isn't going to work for me. And you might be better off starting with something like neon or one of the other services. Or you could just say, okay, well, look, the database is a serious part of my infrastructure. I'm going to have to spend a serious amount on this. I don't think that production grade, enterprise grade databases come for cheap, unfortunately. So that's our two cents on cost, but there's a lot of other features. We don't have time to cover them all. In fact, I think we should probably do a few more episodes on Aurora architecture, maybe setting up and managing Aurora, but what other topics should we run through this channel before we finish up?

Luciano
00:22:14

Yeah, let's do a quick list of other things that might be interesting to know, but we'll leave it to you the task of like doing a deep down and really trying to understand all of the details. So the first thing to mention is that there is a data API, which right now exists only for Aurora Postgres. MySQL was interesting enough supported in Aurora server as V1, but it's not there yet, at least in V2. So if you're planning to go from V1 to V2 and you were relying on this MySQL data API, just be aware that it's not there for the V2, at least not yet. Hopefully it's going to come soon. But what is the point of this data API? So the idea is that with the database, you generally connect through kind of a raw TCP connection that uses a protocol that is specific to the database system. While with this data API, there is effectively an HTTP API that replaces all of that. And why is this convenient? Because it's a little bit easier, for instance, to call if you are in a Lambda, you don't necessarily need to install specific drivers for your own database. So it can make things a little bit easier in terms of connectivity from different environments. Now, should you use it? Again, if you are in a server environment, serverless environment probably makes things easier. But if you are in other context, maybe you have a more traditional application with maybe using an ORM, a standard framework, like, I don't know, Spring Boot or something like that, it's going to be probably much easier to just use the tools that you are already familiar with and just do things in the classic way.

00:23:37

Another interesting thing is that there is an RDS query editor. So you can finally run queries in the AWS console. This is something that for traditional RDS, I was looking for for a long time. It's good to know that with Aurora, you have that option. And it is based on the data API, so you need to enable the data API for it to work. So just be aware of that small detail. And there are some limitations that we have observed using it. But if you just need to run a quick query just to try to validate some assumption, it can be a really useful tool, and it might save you a lot of time. Now, it's not necessarily the main tool you should be using for doing all your data modeling with your database. But again, if you just need to use it for some debugging, it can be very beneficial. And the other thing is RDS proxy. It's probably a better solution for Lambda compared to data API. It's an additional resource that you need to provision for each regional cluster. And the idea is that because when you run Lambdas, you might end up having really, really quick spinning up thousands of Lambdas. And every single Lambda is going to try to establish its own connection. So if you try to do that in the traditional way, where you try to just establish a TCP connection directly against the database, you might very easily saturate the pool of connections available in the database. So this proxy tries to manage all of that, tries to provide some kind of share pool and manage all of this stuff so that you don't end up overloading your database in the case where you're spinning up thousands of Lambdas at the same time. So it keeps your database a little bit leaner and manages all of these things, and also gives you faster failover because it's aware of the cluster topology. So you don't have to rely on DNS. And with DNS, oftentimes you might have problems because maybe you have a TTL, and then your DNS doesn't get refreshed fast enough. So you might be failing for a while before you figure out that there is a new DNS record, and then you can easily connect to the correct instance. Another interesting point is that allows you to enforce IAM authentication. So this can be useful if you have, for instance, to share secrets with the application directly. The small problem is that, of course, because it's an additional resource, there is an additional cost. So something that you have to consider is $25 a month, more or less. So it's not a massive cost, but depending what you are trying to do and what is your budget, it can be something significant and is worth considering that. So these three things I wanted to mention, Data API, RDS query editor, and RDS proxy, somewhat interesting. So if you end up using our Aurora or seriously considering Aurora, check them out a little bit better in the documentation. We'll have links in the show notes if you really want to understand why those additional three things can be really beneficial for you. I guess this is time now to jump to the conclusions.

00:26:42

And I can see Amazon basically aiming at people who are paying a lot of money for commercial databases with high license costs and lower performance. And they're saying, this is going to be cheaper and faster, even though it's still a significant cost for the average user like us from our perspective. For enterprises, they can definitely make some savings. But it's also good for single instance, low config, serverless type cases that need relational database rather than no SQL. So if you're somewhere in between those two extremes, you might just use RDS or another vendor, especially if you are cost conscious. So just to summarize everything we talked about today, Aurora, its relational database solution on AWS, we talked about some of its unique capabilities, intricacies and trade offs, and how it'll give you MySQL and Postgres compatibility with faster performance. But the most important thing maybe to take away is its distinct storage layer that gives you that better performance and durability and faster recovery. And then bear in mind as well the concepts of Aurora clusters, reader and writers, endpoints, instances, and global databases as well. When it comes to Aurora serverless, comparing its two versions and their features, V2 is definitely more enterprise grade, but V1 is not going to be supported from the end of this year anyway. And while it definitely does not reach the gold standard of serverlessness set by DynamoDB, it does have its uses, particularly for variable traffic use cases, and maybe pre-production workloads as well. And we also touched on billing aspects and things like the data API, RDS query editor, and RDS proxy as well. So overall, I think it is a really powerful and scalable solution. It's not trivial to use, especially when it comes to global scale, but still way more trivial than the alternative because when you're dealing with clusters of relational databases, at least as of yet, there is no silver bullet, ultimately simple solution. So thanks very much for joining us and join us in the upcoming episode for more on Aurora and a whole load of other AWS topics.

Help us to make this transcription better! If you find an error, please submit a PR with your corrections.