Making MySQL faster
In this episode, I chat with Richard Crowley from PlanetScale about their new offering: PlanetScale Metal. We dive deep into the performance and reliability trade-offs of EBS vs. locally attached NVMe storage, and how Metal delivers game-changing speed for MySQL workloads.
Everything we said
Aaron Francis
In this episode, you're gonna hear from PlanetScale's Richard Crowley. We're gonna talk about their new offering, PlanetScale Metal, which is NVMe drives attached directly, so you get unlimited IOPS. We talk about all of the benefits, but also the pain and the process of actually building this thing out, and how Richard showed up on the job, and in week one was like, "What if we built PlanetScale Metal?" It's a bold move, Richard, but clearly it paid off.
You're gonna enjoy this episode. If you wanna check out the other episodes, you can go to databaseschool.com. Now, enough from me. Let's get onto the show. I reached out to a fl- a friend at PlanetScale and was like, "Hey, I wanna talk about this PlanetScale Metal thing. You wanna come on the show?" And he was like, "No, no, no. I can't come on the show. You have to get Richard on the show.
He's the genius." So Richard, welcome to the show. Do you want to introduce yourself?
Richard Crowley
Sure. Thanks for having me. My name is Richard Crowley. I work at PlanetScale. I have spent my whole career doing various database performance, reliability, operations kind of engineering. Um, my first exposure to Vitess, which we'll talk about more in a moment, was actually at Slack, where I led operations engineering for about six years. I have done a lot with AWS and, uh, a lot with companies large and small that you may or may not have heard of.
Aaron Francis
Well, I've definitely heard of Slack. That is very cool. I knew that y'all, uh, y'all, previous y'all at Slack were one of the biggest, uh, Vitess installations, so that's super cool. I, I didn't know that that is where you came from. Um, so on Vitess, can you tell us a little bit, um, before we get into Metal, can you tell us a little bit kind of what Vitess is and a little bit of how it operates, um, and then describe where PlanetScale fits into that, uh, landscape?
Richard Crowley
Sure. So Vitess is often described as a middleware for MySQL databases. It was open sourced by YouTube a long time ago at this point. I honestly don't remember which year. And at first, me personally, I thought of it as a really good production, high-quality Go code dump, and it was only much later that I began to investigate and appreciate it as a database middleware.
And its purpose is to handle horizontal scalability. So it, it handles sharding and then routing queries to the appropriate shard or many shards in cases, recombining results as necessary. It hel- helps handle failover, backups, uh, replication, schema changes, uh, resharding, all the operational concerns you might need that get you beyond having a sharded database, but actually living with a sharded database.
And PlanetScale, as a company, was founded in the aftermath of, of Vitess being open source and builds a hosted scalable MySQL database in the cloud, and we run in AWS and in GCP. We run some of the larger databases out there in the cloud for, for companies like Block and Intercom. And, um, we're out to make the very best database that we can, and we kinda consider ourselves a database operations company as much or even more than a Vitess
or a MySQL company.
Aaron Francis
Interesting. That's a interesting way to frame it. So I have always thought of Vitess as kind of like a... A middleware is a good analogy. I have thought of it as a router that kind of routes queries to individual, uh, MySQL instances. But maybe middleware is more correct because, uh, it could route it to multiple and then recombine partial results back in that middleware layer, which is Vitess.
Is that correct?
Richard Crowley
Exactly. You know, most queries, and especially if you're looking at high-performance OLTP kind of workloads, most queries you're gonna wanna design your sharding scheme to hit a specific and only one shard for a particular query. But that kind of implies that there are other kinds of queries that would need to hit many shards, potentially every shard, especially admin tools, analytic kind of things, where the idea of hitting every shard and asking who's got X, Y, or Z, and
recombining that into one result set, that's something that if you were doing it yourself, you'd be doing in a for loop over all your database servers, which is not nearly as programmer, uh, friendly nor as, uh, definitely correct as getting something battle tested in the database middleware.
Aaron Francis
Yes. That's exactly how I would do it, actually, is just a brute force for loop. So I'm glad Vitess exists.
Richard Crowley
Wouldn't we all until it doesn't work for us.
Aaron Francis
Yeah. Yeah. Exactly. Um, okay. So, um, from my understanding, um, and I don't know terribly much about Vitess. Uh, you may know this, listeners may know this. I used to work at PlanetScale, but I don't know a super, a super lot about Vitess. So help me understand on the Vitess side, um, as we're leading into this, like, uh, invention of Metal, what is some of the Vitess stuff, um, like under the hood
as it relates to storage? Is there anything special going on at that layer, or is it all, is that all pushed out to the MySQL layer underneath?
Richard Crowley
That's, I'd say, one of the most significant differentiators between something like PlanetScale and Vitess and something like, um, an Amazon Aurora. The, the terminology about, uh, disaggregated storage or separation of query processing and storage is an architecture that has some benefits and some drawbacks, and PlanetScale takes the opposite side of that, choosing instead to rely on MySQL for the kind of last mile query processing and all of the storage.
We still use InnoDB. We still use all of that, uh, that kind of open source technology. And that has extreme benefits for OLTP workloads in keeping the computation and data close together so that those tight loops of IO and computation happen locally rather than over a network
Aaron Francis
Gotcha. Okay. So that, that part makes a lot of sense. So you at, at PlanetScale, um, so y'all are operating these massive sharded databases, and you've got Vitess doing a ton of work, and then obviously the PlanetScale proprietary stuff doing a ton of work. So y'all are looking at this, and you come in at some point as the performance guy, and you're looking at this and you're thinking, "This is good, but it's not good enough yet." Or like what is the thing you're looking at where you say, "We're running these massive
databases, but we could do better"?
Richard Crowley
I actually came in looking at it from a reliability perspective first-
Aaron Francis
Oh
Richard Crowley
... and a performance perspective second.
Aaron Francis
Got it.
Richard Crowley
They're, they're very closely related in this context, but I came to PlanetScale and saw that we ran these very giant databases backed by EBS volumes in AWS and, uh, persistent disks in GCP, and that contrasted just night and day to how I ran databases at Slack, how we ar- architected everything.
We ran everything on what Amazon sometimes calls ephemeral storage, sometimes called instance storage. Uh, back in 2014 when we started doing this, it was the I2 instance class, and time has passed and now there's the I4i and I7i. And the distinguishing feature of these instances is that they have real hard drives like you could go buy from a hardware vendor plugged right into the motherboard.
At this point, they're, they're using the NVMe interspec- inter- interconnect standard, and they are real honkin' fast. And that technology gave us two things when we were running databases at Slack, even when they were a lesser, uh, like a s- a serially attached SCSI or some previous generation of attaching these drives.
They were locally attached, which meant no network hop between your running process and its storage, and they were, uh, un- unconcerned with the replication and recovery and, and fault tolerance that EBS is, which meant that there's a whole class of problems that EBS can have that these drives just can't have.
They're more binary. They kind of work or they don't work. And in a distributed system, in a large software system, a failure that's so black and white is really very nice.
Aaron Francis
Okay.
Richard Crowley
I don't want things to get slow. I want them to stop working entirely.
Aaron Francis
Mm-hmm. Yeah. Okay. So that, that makes, that makes sense to me. So you came out of Slack where you guys were already, you all were already kind of doing something at least directionally similar to metal, and you come into PlanetScale and everything's on EBS. So talk to me first about EBS.
We know the downsides. Um, you have to make that network hop. Why do, why does everyone up, and including PlanetScale up until recently, why does everyone choose EBS? Like, what are the great benefits of that?
Richard Crowley
I think there's a couple of pretty genuine benefits to using EBS. I don't wanna throw it completely under b- under the bus because it's not for nothing. We still support a lot of EBS-backed databases at PlanetScale, and there are some kinds of databases that are better fits for EBS than for metal.
Aaron Francis
Interesting.
Richard Crowley
Uh, the main benefit to me of EBS is that the drives are resizable online, so you can have it grow with you, and that's, uh, a technology that would allow you to skip a whole bunch of engineering work if you're building directly on this yourself. I mean, we're the, we're the database vendor, so that doesn't s- that doesn't really hold water for us long term.
Aaron Francis
Mm-hmm.
Richard Crowley
The bigger thing is that you can detach and reattach those drives to running instances, so you can replace EC2 instances, scaling them up and down, and keep the storage, which is a very nice operational benefit, which leads to the other really major thing, which is that you get flexibility between how much CPU and RAM you have versus how much storage you have.
And in AWS, when you have, you know, a little bit of CPU and storage but a lot ... or CPU and RAM, but a lot of storage, that is something you can achieve with EBS. Whereas the instance storage, the metal instance classes, there's a fixed ratio of-
Aaron Francis
Mm
Richard Crowley
... gigabytes of storage or terabytes of storage per CPU and RAM. And so those, those ratios limit what we can offer folks in terms of, of SKUs in our product, uh, with, of course, a lot of benefits that we'll get to in a moment. But EBS fits into that case where you have a ton of data but not very much traffic very well.
Aaron Francis
Okay. So I don't know the inner workings of AWS very well. So if I'm understanding correctly, what you're saying is, uh, with EBS you can have all kinds of different sizes, and because they're network attached, you can kind of mix and match with your compute. But with the attached stuff, the, the metal stuff, some human being has to go in there and configure a certain server with attached storage.
You can't just do it in software, and so that limits the permutations or combinations.
Richard Crowley
It's-
Aaron Francis
Is that right?
Richard Crowley
In a way, yes, although that human being that you're rightly identifying is way earlier in the process. That human being is a product manager at AWS deciding what kinds of EC2 instances get offered.
Aaron Francis
Got it.
Richard Crowley
And they're the ones that set that ratio of storage to compute, and that's immovable. That has been fixed for many generations even of these EC2 instances, and they keep maintaining that because it's, it's parity from one instance class to the next, which is nice for the consumer. But if you are kind of stuck, like for instance, one of the, one of the most popular instance classes for PlanetScale metal has just under a terabyte of storage.
Aaron Francis
Mm-hmm.
Richard Crowley
And the next size up is either twice as much storage, twice as much CPU, twice as much RAM, and twice as much money, or the same amount of CPU and RAM and three or four times the storage. For sort of an, an in-between price. So the, the jumps are quite large. That's the, that's the trade-off you're making. E- EBS offers the flexibility and precision of sizing.
Metal offers much more coarse-grained jumps with incredible performance to ma- to, to make up for it.
Aaron Francis
Okay. That makes sense. And like you said earlier, um, we're not throwing EBS under the bus. EBS is great. There are just trade-offs, and we're talking about all of the trade-offs. And you mentioned earlier one of the, I think you said it as a, as a negative, is like EBS concerns itself with backups and replications and durability, whereas the attached storage doesn't.
And you were like, "That's great because the attached storage only concerns itself with storage." Talk to me about the benefit of EBS concerning itself with this durability, because presumably that's something you had to reinvent. So is that something nice about EBS?
Richard Crowley
It can be. If you're, if you're taking AWS components off the shelf and trying to build something that doesn't lose data, I think EBS offers a primitive that is useful to you, that EBS's guarantees, especially the fancy expensive Io2 type of EBS volume, guarantees a level of durability that is impressive and useful in building redundant dur- durable systems.
Aaron Francis
Mm.
Richard Crowley
You can have one EBS volume attached to one EC2 instance, and if it's the Io2 type, know that you have five nines of data durability. That's, that's useful as a, as a system-building primitive. Now, we as a database vendor are not taking that and just kind of shipping it and being done with it because for a many other reasons, uh, a big one being the amount of time it would take to lose that instance, get
a new one, attach the volume, restart service, that's a long outage for people. Uh, whereas when we run three copies of every database shard online at all times, participating in replication, participating in monitoring, we can do failovers in a matter of a couple of seconds if that primary database instance fails. That provides higher availability to people and a better product for us to offer.
But EBS is not helping us offer that. In fact, in some senses, EBS is hindering that. We're already doing the triplicate redundant storage, but an EBS volume anywhere in that system that gets slow presents kind of a is it or isn't it dead challenge for us to detect, monitor, and respond to. So it would be easier for us if E- if EBS wasn't doing that and instead would just die when the hardware backing it died.
Aaron Francis
And that goes back to your point about reliability because it's getting slow and you can't tell is it, is it dying or is it just slow, and you want it to just drop dead. Because from what I understand, you all are keeping, uh, you all are handling durability with the three copies, and then anywhere in that chain that EBS exists, it's like, "Hey, I'm also gonna handle durability." And you're like, "No, I don't want that.
I'm, I'm taking care of it." Is that right?
Richard Crowley
It's redundant, and it's, and it's frankly, it's one of the reasons that EBS is expensive, and it's one of the reasons-
Aaron Francis
Mm
Richard Crowley
... that PlanetScale Metal can be cheaper in most, especially any seriously high IO configuration, than others is because we're not doing redundant redundancy.
Aaron Francis
Mm-hmm. Mm-hmm. Okay. So let's move, let's move to Metal. So we've got kind of a lay of the land on what you came into, which was, uh, highly functioning, well operated, but running on EBS. And so you come in and you're like, "Hey, let's talk about, think about, look at some of the stuff I did at Slack." Um, what was the internal conversation, whether it was you pitching or someone pitching?
What was it like when it first came up?
Richard Crowley
I pitched the CEO literally one week into working here after I-
Aaron Francis
Bold move
Richard Crowley
... looked around for a little while, and I told him, "This was how we ran-"
Aaron Francis
It's like the Kool-Aid Man bursting through the wall. "I've got some ideas."
Richard Crowley
Pretty much. And I said that this was how we ran it at Slack. I, I, I caught a, a friendly, ready-to-hear-the-message ear about the reliability challenges with EBS.
Aaron Francis
Mm-hmm.
Richard Crowley
It getting slow is hard to figure out. Uh, the failure modes are a lot more straightforward. Um, and the performance j- is just off the charts. You know, the, the final, I think, leap there was that, and we can probably offer a dramatically faster product if we go down this road. Now, it's not without challenges, uh-
Aaron Francis
Right
Richard Crowley
... because there was a lot of engineering work between that pitch and launching something, but the basic pitch of a more reliable and faster service was hard to say no to.
Aaron Francis
So you got, you got him hooked with, you got him teased with more reliable, and then you closed the deal with faster for our customers. Is that how, is that how it went?
Richard Crowley
I mean, that's, that's separating the two further than I probably did, but about 30 seconds between the two, yeah-
Aaron Francis
Yeah
Richard Crowley
... that's kind of how the pitch went.
Aaron Francis
Okay. So perfect. So you get, you get this successful pitch. You're the new guy coming in with lots of big ideas, and you get this successful pitch, which is awesome. So then, um, you start surveying, like, the existing components and how everything works. What does that engineering undertaking look like to go f- like, to basically change one of the fundamental building blocks of kind of your service?
How do you start to, like, even contain the blast radius of that or even diagnose it?
Richard Crowley
Well, so I set out to prototype this in a, in a development environment that I'd set up for myself to, to get as far as I could, and this was both to help build Metal, which Sam, the CEO, had named Metal within a matter of days, um, that-
Aaron Francis
Yeah
Richard Crowley
... that credit goes to him. It's a great name, and he'd settled-
Aaron Francis
Cool
Richard Crowley
... on it very quickly.
Aaron Francis
Mm-hmm.
Richard Crowley
I started doing development work to prototype how this would work to see where the, the seams and the breakages are. Uh, and I was honestly, I was very pleasantly surprised, um, I shouldn't say surprised. I was pleasantly had my expectations of the quality of the engineering team confirmed here that- ... when they built the whole EBS backed system, they built it in a really layered, robust way.
Aaron Francis
Cool.
Richard Crowley
So I mentioned before how great it is that an EBS volume can be detached from an instance and attached to a different one in EC2. That's, that's a powerful primitive that you can use, and PlanetScale took advantage of that. So when we wanted to recycle EC2 instances, either just because they were old and they needed to be recycled, which is a great operational hygiene that was there long before I joined, or because someone was sizing up or sizing down-
Aaron Francis
Mm
Richard Crowley
... whenever that happened, they would detach the EBS volume and reattach it to the running instance, and that made those operations faster. That made them happen in a matter of seconds instead of potentially hours if you need to restore a backup. But if the EBS volume failed or for a variety of other reasons that the, the operations software decided, it could terminate the EBS volume and bootstrap a new one from a backup, which is how you would have to operate under what became
the PlanetScale metal architecture anyway. Anytime you replace an EC2 instance, you're also replacing the storage, and so you also have to restore a backup.
Aaron Francis
Mm.
Richard Crowley
So it was lovely that all of that machinery already existed. We were already exceptionally good at taking and restoring backups, and that's such a core primitive to building a system on, on this ephemeral storage, where the storage goes away when you terminate the machine it's attached to. And that was the baseline for all of this. Now, the, the most significant change to the, the scale and the, and the, the risk profile of the operation
is, is the frequency of that, right? That if you have a backup that gets restored every once in a while to replace an instance when you're replacing the EBS volume, that latency hit isn't such a big deal when you're restoring a backup for maybe a half an hour or, or multiple hours. Um, especially when the other two instances are themselves backed by EBS volumes, which could be detached and reattached in a matter of seconds.
But when you're looking at a fleet of all of the machines are backed by these instance storage drives, which are fast, but take a while to restore their backups, that represents a position where you might find yourself, in the case of multiple failures, in a, in a bad place. So we, we run three database servers per shard in PlanetScale, and we run under what MySQL calls semi-synchronous replication, which means two have to be online to accept writes.
Aaron Francis
Okay.
Richard Crowley
If we take down a server for a routine replacement, we've given up our fault tolerance. That's no good. We want that to be there for accidents, for letting the blue smoke out of the CPU, for, you know, someone tripping over a power cord in a data center or any kind of an, an accident like that.
Aaron Francis
Mm-hmm.
Richard Crowley
So we did a lot of engineering work, um, and, and I didn't do this work. Credit to our orchestration team and a guy named Matt Loehr especially, who-
Aaron Francis
Mm
Richard Crowley
... who built this stuff. We introduced the idea of surging instead of shrinking clusters when we were replacing nodes. So instead of going from three instances down to two and bringing up a third one to replace it, we would go from three instances all the way to six, restore those three backups in parallel, and then knock back down to three instances.
And the reorganization of all the operations to do that meant that we were never giving up our fault tolerance voluntarily.
Aaron Francis
Mm.
Richard Crowley
And when we're not giving up our fault tolerance voluntarily, the difference between attaching and reattaching an EBS volume versus restoring a backup in the case of a fault does not materially impact the, our overall durability profile. We did the math on this, and it's like we lose a couple of nines of durability, which sounds bad, except we're already st- we're starting with nine or 10 nines worth of data durability, and the difference between eight nines and 10 nines is not
that great.
Aaron Francis
It's not that great. It's a couple nines, but in the real world it's not that great. Um, all right.
Richard Crowley
You got, you got enough nines.
Aaron Francis
Yeah. Okay. So let, let me, let me see if I got all of that. So you come in and you spin up, uh, your environment and you start tinkering, and it turns out there are some pretty good abstractions or events or life cycle hooks that you can, you can get your grubby little paws on and be like, "This is mine now. I'm gonna take over right here."
Richard Crowley
Yeah. I said, I said a moment ago that really PlanetScale's a database operations company. That's, that's this.
Aaron Francis
Yeah.
Richard Crowley
We are exceedingly good, and have been for a long time, at rebooting database servers and managing that life cycle.
Aaron Francis
So when you're mucking around with that part, where does that live in the stack? Is that in like the, the Rails part? Is that down in some sort of Go or some sort of... Like, where are you when you're like, uh, down there messing around at that point?
Richard Crowley
The, the majority of that part of PlanetScale's code is in our custom Kubernetes operator.
Aaron Francis
Kubernetes operator.
Richard Crowley
And that's, that's what's reacting to cluster events, and that's what, that's what matters when, say, an EC2 instance dies unexpectedly. That's all within our Kubernetes operator.
Aaron Francis
Nice.
Richard Crowley
And there's a, a service in between that and the Rails app that is translating sort of product notions like what size of cluster someone wants-
Aaron Francis
Mm
Richard Crowley
... into Kubernetes notions like which deployments should be deployed to which availability zones. And that-
Aaron Francis
Okay
Richard Crowley
... that is sort of a one-way brokering of intent from our Rails application-
Aaron Francis
Mm-hmm
Richard Crowley
... through that service into the, the operator. And that operator and the Kubernetes clusters that it's, it's managing ... is the real deal. That's where all the fault tolerance happens, that's where all the operational patterns are encoded.
Aaron Francis
Got it. Okay. So as a part of this, you're looking at the existing workflow and thinking because of some of the characteristics of Metal, we have to add more to do this surge thing. We have to add more because that may take a longer time to get those, those, uh, the new three online because the backups or the restores take a lot longer.
Did I remember that correctly?
Richard Crowley
Pretty much.
Aaron Francis
Okay.
Richard Crowley
Uh, and I'll, I'll make a, I'll make an example here that's exaggerated in a way that maybe makes this, uh, motivates this a little bit better.
Aaron Francis
Okay.
Richard Crowley
So suppose you have a database that is made of three nodes in a hypothetical cloud provider that's really bad.
Aaron Francis
Okay.
Richard Crowley
And so you expect one node to fail every single day.
Aaron Francis
Okay.
Richard Crowley
Which, like, whatever, whatever you think the reliability of EC2 is, it's probably better than you're imagining. You know, we model things at, uh, at a 1% failure rate per month, which is higher than we've ever experienced, but we did the math conservatively. So imagine you have a bad cloud provider that fails once a...
fails an instance a day, and you have your three instances, and so you're, you're pretty sure one's gonna fail, but your backups take 24 hours to restore, which is way slower than they would be in real life. And if you have a backup that's restoring and an instance fails, well, you've, you've already received a failure, and you're restoring from that one, so you have two instances that are healthy.
You're getting... You're on your way to a third. It's restoring its backup, but another one fails. Well, that, that means you're write unavailable now. You only have one instance left, so you can do reads off of that, but you can't perform any writes because you need two to do writes. So your slow backup has caused you, or your slow restore, I should say, has caused you unavailability.
Imagine in that same bad cloud provider that you had the same kind of failure modes, but your backups restored in one minute instead of 24 hours. Well, then the window in which you're vulnerable to that second failure is much lower. So that's why this surging behavior, being very thoughtful about when we preserved and when we gave up our fault tolerance, was really important to how the system works.
We don't want to put ourselves in a position where a second random failure impacts us.
Aaron Francis
Right. Yeah. Okay. That makes a lot of sense, and is a pretty, that's a pretty nice, uh, it sounds easy. I'm sure it was more complicated. That's a pretty nice and easy solution to scale up before you turn off the old guys so you don't lose, you don't lose that, uh, that fault tolerance. Um, okay. So you've got, at, at PlanetScale, when you're running a single, to the user, when you're running a single database, you're running three databases.
That's true so far?
Richard Crowley
Yes.
Aaron Francis
Okay.
Richard Crowley
Always at least three.
Aaron Francis
So when you're, when you... At least three. So when you're running a single logical database, you've got three. Two have to confirm. One can go offline, um, and as long as two are still confirming writes, you're fine. Um, so that's a little bit of just, like, PlanetScale basics. And then you, you guys move into Metal, and that means that, um, the disks are more, I don't wanna say risky, 'cause they're not risky, but you just have to be more careful with the disks going away, right?
Because you can't just detach it, 'cause when you're rolling in EC2-
Richard Crowley
Exactly
Aaron Francis
... that data just goes away. Is that right?
Richard Crowley
So realistically, they're the same hardware as EBS is using, right? You know, there's nothing, there's nothing magical or technologically different in the, in the silicon and the, and the copper there, right?
Aaron Francis
Mm-hmm.
Richard Crowley
And that, the difference is that when an EBS, when that piece of hardware in EBS fails, EBS gets slow because it's copying data from the two copies that remain-
Aaron Francis
Mm
Richard Crowley
... over to a new one to restore its redundancy, which is slowing down our operation because EBS has gotten slow, and we don't have any control over it.
Aaron Francis
Right.
Richard Crowley
The hardware is the same though, and when, when we have direct control over it, we can react to those failures in a more performance preserving way. We can re... elect a new primary and get someone back in business.
Aaron Francis
Okay. So that explains to me one of, one of the, um, one of the attributes of EBS was that durability. I think we've covered how y'all are, uh, how y'all are solving for the loss of that EBS durability, which is you've got those three, you do the surge, and then the scale down to make sure that you're not losing durability for any amount of time.
So that's a nice, uh, that's a nice reliability aspect, which of course you're very interested in, is the reliability. Talk to me about the performance aspects of once you do have these disks that are, like, right there, not over the network and not in triplicate, they're just right freaking there, what are the performance, um, characteristics that change because of that?
Richard Crowley
So the, the network hop to EBS is, uh, is a killer. You know, it, it may be, you may be able to paper over it in terms of throughput by pipelining your network requests and everything, but fundamentally, that storage is very far away and thus appears very slow. You, you expect to see EBS write latencies in the, you know, order of magnitude of milliseconds, and that gets slow sometimes, even slower sometimes.
You expect to see write latencies for locally attached NVMe storage on the order of 100 microseconds. You s- you expect an order of magnitude better performance from these devices, and we see that borne out with some of our very largest customers' databases all the way up at the query performance level. Uh, one One migration that we did early on in the metal, uh, GA phase saw a approximately 1,000-node
database running on very, very big, like, multi-terabyte storage servers. So 1,000 servers with three or four terabytes of storage each. And that workload's 99th percentile latency went from 50 milliseconds to five.
Aaron Francis
Good lord.
Richard Crowley
No other changes. That's it. Just storage technology and all the engineering that we did to make it w- viable, and they got an order of magnitude improvement in 99th percentile query performance.
Aaron Francis
And they didn't have to do... They didn't change anything.
Richard Crowley
They didn't change anything.
Aaron Francis
Yeah, that rules.
Richard Crowley
Their app just got faster.
Aaron Francis
Okay. Okay.
Richard Crowley
It was, you know, I'm, I'm joking about complaining about this, but the double-edged sword is then people get mad at me when their 95th percentile goes from 500 microseconds to 800 microseconds, and that's fine. They're, they're totally allowed to get mad at me about that.
Aaron Francis
Yes. We will, we... That is totally fine. Okay, so turns out speed of light, not that fast. So if you're hopping over a network to get to a disk and you're doing that all the time, it's gonna add up quite a bit. So bringing the disk right over next to the compute, uh, makes that latency go away. Talk to me about, uh, throughput.
So I keep seeing, I keep seeing IOPS, IOPS, IOPS, IOPS.
Richard Crowley
Mm-hmm.
Aaron Francis
Shirts, shirts.
Richard Crowley
Yeah.
Aaron Francis
Screen sa- DVD screensavers, IOPS, IOPS, IOPS. What the hell are we talking about with IOPS?
Richard Crowley
Talking about inputs and outputs per second. We're talking about writes here. And throughput is, is maybe a slightly different thing in that you can get pretty decent throughput out of a system that is high latency, uh, by pipelining those requests. This is how sequential reads would work on spinning rust hard drives 20 years ago.
And that's, that's fine, but it's so rare to actually be able to do sequential reads and writes in an OLTP system, where we're talking about, you know, me reading your user record off the list. And it's, it's this much data. It's not, it's not megabytes even of data.
Aaron Francis
Right.
Richard Crowley
And so the use of sequential IO is just not a realistic optimization for modern OLTP systems. What you need is random IO, and that's where SSDs were just a world-shifting advance in what databases could do, and they've continued to get better as the attachment technology and bandwidth has changed.
Um, I wish... I've been trying to find the source of this over the, over the years, but there used to be, I think possibly in the MyDotConf comments about how to tune MySQL, there was a note about how MySQL was designed around having about 100 IOPS, and now you can get an off-the-shelf instance from EC- EC2 that's approaching a million IOPS- ...
available to you just as commodity hardware. The game has really changed dramatically. You know-
Aaron Francis
Yeah, no kidding
Richard Crowley
... databases were never CPU bound until SSDs, and now they, they can very, very much be CPU bound. So having this immense amount of IO capacity, and it's random IO capacity, and it's fast random IO capacity, it's these, you know, well sub-millisecond reads and writes, that means that you can have a working set that's far larger than main memory without the typical historical performance penalty that that would bring.
Aaron Francis
Yeah. Okay. That's, that is super interesting. I mean, my- MySQL is how old now? What? 30 years probably?
Richard Crowley
It is just over 30 years old.
Aaron Francis
Okay. So-
Richard Crowley
They had a birthday party recently.
Aaron Francis
Yeah. So MySQL and, uh, my language of choice, PHP, are the exact same age, which is wild. And so going from 100 to a million in 30 years, eh, it kind of checks out. That, that seems to be about right. Um, okay, so you're getting all sorts of these performance benefits. Besides, um, besides this whole, like, surge thing, what were some of the engineering, uh, challenges or complications?
Sounds like you knocked out a proof of concept pretty quickly, but then to productionize it, product- to make it production ready-
Richard Crowley
Mm-hmm
Aaron Francis
... uh, what were some of the hard parts of, like, this new paradigm?
Richard Crowley
So the, the surging pattern writ large was, I think, the most significant change to the usual operational patterns that PlanetScale's operator would take for someone. Um, there were product challenges in how we present these fairly inflexible disk sizes and things, but the rest of the engineering work, I think is safe to say, was about handling edge cases in the launching, and mounting, and formatting, and management of these ephemeral volumes.
We've... At this point, we've, we like to think we've seen everything. I hope we've seen everything. We've seen instances come up without their drives. We've seen instances come up with malfunctioning drives. We've seen boot order problems that, uh, are related to Kubernetes and the, the volume provisioning technology we're using and how it interacts with PlanetScale Operator that we have to take great care in ensuring that we're really actually putting the data on the ephemeral drive and not
on, like, the root volume next to the MySQL D software.
Aaron Francis
Oh, wow.
Richard Crowley
And there's a bunch of things that are not in any, in any individual case hard, but just a lot of defense, a lot of-
Aaron Francis
Yeah
Richard Crowley
... protection for ourselves, imagining the most malicious possible boot order or state of the world when we get the instance, and ensuring that we can still get to either a functioning state or a bail out, terminate this one and give it back state. Um, 'cause to have-
Aaron Francis
So how is-
Richard Crowley
... the half-working instance, much like the slow EBS volume, is the worst state to be in.
Aaron Francis
All, all of those things would-- You'd be completely hosed if you had taken one of your three offline. So you take one of your three offline, you bring a new one up, and it's, like, has no drive attached or whatever. That, that is the ins- that is the situation you're guarding against by doing the surge and then c-c-contract, huh?
Richard Crowley
Oh, absolutely. Yeah.
Aaron Francis
And so let's say you get a bad instance. Um, do you just throw it back in the pool and grab another and hope it's better?
Richard Crowley
Pretty much, yeah.
Aaron Francis
Yeah.
Richard Crowley
Um, the, the a- the available technology for correcting such a, such an instance is not stupendously evolved. Um, there's a lot of dif- a lot of our defensive measures are not throwing the instance back, I should say. A lot of our defensive measures are waiting and controlling and fitting into the boot order so that the NVMe controller has initialized by the time we get there, and the-
Aaron Francis
Mm-hmm
Richard Crowley
... file system has had a chance to format before Kubernetes starts to try to put data in it, and all of that stuff. But there are definitely still contingencies that just if there's no device in the device tree, you can't use the instance.
Aaron Francis
Can't fix that.
Richard Crowley
There's nothing, nothing to do about it.
Aaron Francis
And so is that just, like, is that just the state of the world? That's just Amazon's doing their best, but sometimes they have problems too, and so you just throw it back and hope to get a better one?
Richard Crowley
So with a lot of things in EC2, and it's not just storage. For instance, if you want to understand which processes are using how much memory within your EC2 instance, you can't see that from outside. And so I don't know for sure, but there's a, a reasonable suspicion that the overall functioning and health of the NVMe drive might not be totally visible from outside the running hypervisor.
And so that may be a reason that it's not a perfect detection of failure because it's not a, it's not the machine exploded. It's more of a, a software, firmware-level malfunction. That's a suspicion, but it, it does check out that there are certain things you can't see from the outside. And with EC2, you know, the, the overall service is still, I think, a, you know, eighth wonder of the world level-
Aaron Francis
Mm
Richard Crowley
... magnificent thing. The, the by-the-second billing, the out- the, the scale and interconnectedness and network that all ties it together is really something, and I'm, I'm pleased to be able to work with it even when there are these oddities, uh, with capacity, with performance, with detecting failures.
Aaron Francis
Mm.
Richard Crowley
Um, I suppose you could, uh, you could chalk this up to AWS's shared responsibility model where there's a shared responsibility for detecting failures.
Aaron Francis
Mm.
Richard Crowley
They don't quite say it like that, but it, it stands to reason that that kind of counts, too. Um, a big thing that we do deal with a lot in EC2 that is quite frustrating is that the cloud is not infinite. It is not forever going and, and infinite in capacity. We get the insufficient instance capacity error quite often.
Aaron Francis
No way.
Richard Crowley
And that's the one where they just don't have any, and there are techniques for dealing with it. There are ways to get around and tolerate it, but fundamentally, sometimes the cloud is full. And, uh, and we've gotten fairly adept at dealing with that, um, sometimes, sometimes through expectation management and sometimes through, uh, calling the right people.
Aaron Francis
So back up. I know the cloud is not infinite, but that to me is, is not true. I mean, the cloud is functionally infinite. You're telling me the cloud is not functionally infinite? Like, you have actually bumped up against, "We don't have any more of that. Sorry, buddy."
Richard Crowley
Oh, yes. Often. Um, and then the-
Aaron Francis
What do you do?
Richard Crowley
Well, oftentimes you wait. Sometimes you, you call in favors. Sometimes you, um, sometimes you need to work with account managers to, to do capacity planning because the difference is that the cloud is functionally infinite for compute-only EBS-backed instance types.
Aaron Francis
Mm.
Richard Crowley
But it is very much not infinite for the fancy storage attached, multi-terabyte per CPU kinds of instances. Those are a bit rarefied, frankly, and, uh, they don't keep an excessive amount of spare capacity around for these very expensive instance types. Um-
Aaron Francis
Hmm
Richard Crowley
... they're a different chassis, I gather, than the, the ones that don't have storage in them, and so they are a different piece of hardware. Um, and they won't tell you how much is available. They won't tell you how many they have, but it's clearly not millions at a time.
Aaron Francis
Right. It's not enough. So without divulging company secrets, like, do you guys have reserved instances? Do you call up somebody and like, "Hey, can you just kinda make sure that we have enough ready to go?" Or like how, how does that work such that, you know, waiting is one option, of course.
What are the other options for solving this?
Richard Crowley
So for PlanetScale's multi-tenant, totally managed, hosted SaaS product, we, we do AWS savings plans and all of the normal kind of cl- cloud cost management and optimization, but we don't keep, uh, standing what they call on-demand capacity reservations to-
Aaron Francis
Mm
Richard Crowley
... to guarantee that we can launch things because most people who are launching in the multi-tenant product are launching relatively modest clusters. You're talking unsharded, so you're looking at three instances, or small sharded, like 4 to 8 to 16 shards. And so we're talking about, you know, well sub 100 instances for most of these people, which-
Aaron Francis
Yeah
Richard Crowley
... in our experience has not been a problem in most AWS regions. There are definitely some exceptions. For our very large customers, they use what we call PlanetScale Managed, which is essentially PlanetScale taking over an AWS account in the customer's organization. And so if we had capacity reservations, that would, if anything, negatively impact those customers.
Aaron Francis
It would deeply
Richard Crowley
So we work with those customers to do capacity planning, capacity reservations, advice on savings plans, and all of that kind of stuff to ensure that they get the, the scale that they need when they need it.
Aaron Francis
Yeah. That's interesting. I forgot... So what you're calling, um, the, the normie side is the multi-tenant. That's, that's what you're calling it, where you go online, you sign up, and you get, you know, a couple databases, whatever. The big guys are using, the big dogs are using, uh, you called it managed, and that's where you-
Richard Crowley
PlanetScale Managed.
Aaron Francis
Managed.
Richard Crowley
Mm-hmm.
Aaron Francis
That's where you get into, uh, their AWS account or sub-account or whatever, it doesn't matter. But you're managing with your software, your PlanetScale software, you're managing resources inside of an account where the billing is owned by somebody besides PlanetScale. Is that right?
Richard Crowley
Yes, exactly. And the biggest benefit to that, for, for a lot of folks, there are compliance and data governance kind of benefits, but truthfully, I think the biggest benefit is those customers get to use their own discounts, and they are-
Aaron Francis
Yeah
Richard Crowley
... oftentimes better than ours.
Aaron Francis
Yeah. And their own committed spend or whatever they, all those games they play over at AWS. Okay. Yeah, that makes a lot of sense. Now, um, so with... How, how long ago was Metal rolled out? When did you start offering this to, to, I guess, consumers?
Richard Crowley
Metal, Metal became generally available in March of this year.
Aaron Francis
Okay. So in March, PlanetScale started offering this ability to have attached drives under the cool name Metal. Um, what, besides the, the launch ca- case studies, which I'll link down below because they're very compelling, um, what has been the market's reaction to Metal?
Obviously, I saw online everybody thought it was super freaking cool. But then what do... Like, what do the customers think? What do new workloads look like? And when, um, you know, to the extent you can share, and when would people be well-served choosing Metal versus the traditional offering?
Richard Crowley
Let's see. In, uh, in broad strokes, the thing that most surprised us overall about Metal is that the most popular SKUs have been the smallest ones right from the b- the beginning, which suggests that the performance profile is very compelling to people who are at that, that medium scale, and that's, that's a, a, an instance with two CPUs and 16 gigabytes of RAM.
So it's, it's a, a full server-
Aaron Francis
Mm-hmm
Richard Crowley
... but it's not an enormous server, and these are often uncharted workloads, so we're not talking about crazy amounts of data. Half a terabyte of data or so fits on these things. And those price points, those, those scales are people that would otherwise be on not just the multi-tenant PlanetScale product, but actually potentially sharing a fraction of a larger EC2 instance or GCE instance, and that, that performance profile is what's selling those folks on that.
And the exception tends to be, as I mentioned before, the ones that have extremely large data size but very low query volume. So where the, the, the cost, if you will, in a Metal instance is kind of split between the CPU, RAM, and storage resources, and if you need one of them out of proportion to the other, uh, the EBS product remains sort of more compelling.
But it's, it's somewhat rare, to be honest with you, that as soon as someone reaches a level of scale that they fit on any Metal instance, it j- it becomes the more compelling offering almost immediately.
Aaron Francis
And so two questions on that. First, about the mismatch between the data and the compute. W- when would somebody have that? Is that just, like, a ton of cold, historic data that they're just-
Richard Crowley
It's-
Aaron Francis
... keeping around?
Richard Crowley
Yeah, it's largely that archival storage kind of pattern, um, that if you're able to cheaply keep your archival kind of storage in MySQL, not doing the engineering work to expire it to S3 is perhaps-
Aaron Francis
Right
Richard Crowley
... a good money in the bank, time in the books kind of a, kind of a decision.
Aaron Francis
Okay. That makes sense. My second question is, these people that could, uh, conceivably fit on the different instance offerings that you have but are opting to go Metal for, like you said, those performance benefits, um, what is the, what is the relative price difference between if they went Metal and if they went with the traditional PlanetScale offering?
'Cause that, to me, would inform how much better the Metal is-
Richard Crowley
Yeah
Aaron Francis
... if they're willing to pay that premium.
Richard Crowley
Absolutely.
Aaron Francis
So what does that look like?
Richard Crowley
Well, so for a lot of people, that performance, the, the right performance in particular, can be a factor in the decision that ultimately they delay sharding, uh, because they're able to do more traffic on fewer instances. And so that's-
Aaron Francis
That's interesting
Richard Crowley
... that's a potential cost saver right there, is that people delay that sharding decision altogether. But even if they don't-
Aaron Francis
So hold on. So if they're not pay, you know, maybe they- they're paying more monthly, but they're not hiring new engineers or keeping their engineers, you know, figuring out how to make sure... Or I guess y'all do all the sharding, but they don't-
Richard Crowley
We do the sharding. Yeah
Aaron Francis
... they don't wanna do sharding at all
Richard Crowley
The sharding is pushing buttons in the UI, but if you can handle your challenge by scaling up into Metal rather than-
Aaron Francis
Yeah
Richard Crowley
... sharding, that means that you don't have the scatter query concern that in your application-
Aaron Francis
Oh
Richard Crowley
... to use the test, you do have to think, uh, "Is this sharding scheme going to support the queries that I need to run?"
Aaron Francis
Right. Right, right, right.
Richard Crowley
And before you shard, you have a little more flexibility in index creation and, and the ability to kinda do whatever you want, uh, mean or otherwise, to your database.
Aaron Francis
Okay. Okay, so that's one-
Richard Crowley
But when people do, when people do make the move to Metal, what we see time and again is that- There are, because the, the granularity of Metal's instance sizes-
Aaron Francis
Mm-hmm
Richard Crowley
... uh, whereas the EBS storage size grows more uniformly as the data grows, um, there can be points where it's more or less expensive. But every single time, as soon as someone needs more than 3,000 IOPS, which is the baseline amount of I/O that an EBS volume can offer, as soon as someone needs more I/O than that, and an EBS volume can go up to 16,000 IOPS before you have to go to the Io2 class, which is incredibly expensive.
Aaron Francis
Mm.
Richard Crowley
And anything in that upper end of the GP3 volume IOPS range, like 6, 10,000, something like that, Metal becomes cheaper every time. Faster and cheaper as soon as you start ramping up how much I/O you need to do.
Aaron Francis
Gotcha. Okay. So I'm hearing two, I'm hearing two, um, potential cases here. One is you just wanna keep scaling up without having to think about sharding, and you just wanna push your current, you know, you wanna scale vertically up and not have to change anything, and just throw money at the problem and be happy with your life.
Sounds pretty great. The other is you're bumping into, um, you're bumping into IOPS limitations, and I, I'm not fully up to date on, like, you can burst up to a certain amount and then you're limited, but it sounds like once they reach a certain point, it's like, this is either not going to work or you're gonna pay through the nose for the second class, so you might as well move over to Metal.
And then the kind of general catch-all, uh, use case is it's just faster. And so if you just want everything to go faster, switch over to the one where the drives are right there. Is that pretty much-
Richard Crowley
That's all
Aaron Francis
... the shape of it?
Richard Crowley
That's all the levels. That's right.
Aaron Francis
Okay. I like that. Um, and so as we're, as we're wrapping up here, what are, um, what are future plans for Metal? It's in GA. It is, um, as far as I understand, very stable, very performant. So now what? Is that done? Like, did you just... Is, is it... Did you make software that is finished, or are there- ...
future plans for it?
Richard Crowley
I think there's, there's always more to do to keep up with the latest and greatest in instance classes and, and ways to take advantage of that I/O. Because right now we talk about Metal as offering unlimited IOPS, which is-
Aaron Francis
Mm-hmm
Richard Crowley
... sorta true and sort of not true. Um, obviously it is not true there's a spec on the instance types. They say what the maximum I/O capabilities are. The reality is that MySQL can never- cannot use it all right now. And so there's the ever-present quest to make software faster and use the hardware more efficiently. And so we expect that over time we'll be able to offer continually better I/O performance.
Aaron Francis
Cool.
Richard Crowley
Um, I also should mention, like, that, that Metal is in GCP as well, and there they made some different trade-offs and different decisions about how the drives are sized that created a, a, a frankly, a more flexible, slightly m- slightly more granular storage sizing, uh, situation.
And so we continue to keep up with both of the cloud providers to offer the latest and greatest instance types, storage types, performance profile that we can. Um, for instance, we are testing and soon launching the AWS I7i instances that they just launched in April. And, um, we'll continue to make the fastest database that we possibly can.
Aaron Francis
Cool. Well, congratulations. Congrats on bursting through the wall on week one and saying, "I got an idea," and shipping it-
Richard Crowley
Thanks
Aaron Francis
... to production and it being a massive success. That's pretty awesome. Um, okay.
Richard Crowley
Appreciate it.
Aaron Francis
While g- uh, while, while we're here, give people, give people your best pitch for PlanetScale through from $39 up to, you know, however much they wanna spend, $10 million. Um, and then tell people where they can learn more about you.
Richard Crowley
Sure. All right. So PlanetScale is the best production relational database management service based on the best production relational database, MySQL. And the Vitess middleware means that it's the best from the tiniest to the very largest, the, the fraction of a node to the thousands of nodes. And we run it for you, which is the other half of running a database, is not just having a good database, but operating it well.
And we have some of the best DBAs that I've ever worked with on our customer engineering team. The, the level of database operations here is, is better than anywhere I've ever worked, and our whole business is to share it with everyone else. Um, you can find all of PlanetScale's product documentation and everything at planetscale.com, and you can find me at rcrowley.org.
And, um, I'm gonna be out here making more databases.
Aaron Francis
Awesome.
Richard Crowley
Thanks, Aaron.
Aaron Francis
Yeah. Thank you. This has been a lot of fun. I'll leave links to everything we talked about and to your personal stuff down below. If y'all are watching on YouTube, there is an audio-only feed. If you're listening on audio, there is a YouTube video. Um, so let us know what you think. Y'all reach out to Richard and say thanks for doing this, but I will say it first. Thank you for coming on and taking time to explain all of this to me.
This has been a delight.
Richard Crowley
My pleasure. Thanks for having me.
Aaron Francis
All right. Talk soon.