I'd like to take a little bit of time to dig into the CAP theorem. Now, if you took the first course in this series, you've gone through the proof of the CAP theorem, you've read the paper. We're not going to go through those in detail today, but what we are going to do is go through what the CAP theorem means in practice. So just as a refresher, the CAP theorem stands for consistency, availability and partition tolerance. Consistency means each server returns the right response to request, availability means that each request eventually receives a response. And partition tolerance means that the system tolerates communication failures. So if you have two servers on the network, for example, your systems resilient to the fact that the network might go down. And what the CAP theorem says, the statement of the CAP theorem is that you can't have all three at once. You can't have a system that's correct, that's always available that always returns a response and that is subject to communication failures. So at first this might seem like kind of a bummer, it'd be really nice if we could achieve all three at the same time. And I guess in fact it is a little bit of a bummer, but for me it's actually kind of a powerful thing to use in practice and always good to keep in mind as we're designing our systems. So yeah, how do we go about using the CAP theorem? Basically you always need to be partition tolerant, right, we're deploying apps on the cloud now. Apps go down if you're deploying to Kubernetes, Kubernetes might scale your app down, scale it back up, kill some containers, spin up some new ones. The network might be, or if you're deploying onto the cloud, you should assume that the network isn't going to be 100% reliable. So every app that we build now should be partition tolerant. So really when it comes down to it, the cap theorem just tells us that we have to balance availability and consistency, we're not going to have both at the same time. Now that sounds a little bit scary, but the nice thing is you don't have to choose one or the other, right? There might be somewhere in between. So sometimes you might favor consistency strongly, you might use something like Postgres. Sometimes you might favor availability, you might use something like Cassandra, but often you go with a hybrid approach. We actually saw that in the email verifier where we decided to put rabbit in front of Postgres that gave us a little bit less consistency and a little bit more availability. So whatever choice you're making you kind of want to figure out you want to have this continuum in mind between consistency and availability. And you want to think about where you are on this continuum. Know that you're making some tradeoffs if you have a really nice relational database. and you think well it's not as fast as I'd like, I'd like to put something in front of it so we have more availability. So more we can answer more requests as they're coming in. Just know that by the CAP theorem, by the statement of the CAP theorem, you're sacrificing some consistency for that availability and that's probably okay, right. But know that you're doing it, the worst thing that you can do is develop like a really, really, really complicated system to try and achieve this availability and consistency. Because you're never going to do it and oftentimes I've seen lots of cases where people are chasing this. Chasing a system that's available and consistent and all they do is end up adding complexity. So at the end of the day it really just boils down to what solution fits the problem, right. Look at what problem you're trying to solve and then does that problem lend itself better to needing consistency or doesn't need availability. So if you're routing 911 calls for example, you want to be really, really far to the consistency side. If you're making movie recommendations, you want to be really, really far to the availability side, right. You don't care if things are necessarily accurate, you just want to get people a response but many problems that you'll deal with along the way are somewhere in between. So I hope this is helpful, definitely dig into the readings, there are some lots of great papers. We have a couple linked in this course, but you'll find a lot more in a Google search that talk about the implications of a CAP theorem. So so check those out but I always like to draw this diagram up on a white board when I'm having these conversations. So yeah, enjoy the readings and we'll see you on the next lecture.