Welcome to Talk Python in Production. I wrote this book to give you a real-world look at how we run our applications at Talk Python. Here, we run the podcast website and handle that traffic, of course, but we also run a full SaaS e-commerce app for our Python courses and a set of APIs to support our mobile apps that work with those courses. Many behind-the-scenes applications keep things running smoothly as well. It's not crazy complicated, but it's definitely far beyond a toy application or personal blog. How we've managed our infrastructure over time and how we're running it today should give you a lot of experience running and designing your own web applications and APIs.
If you're reading this book, I imagine you would like to have more control of your application's destiny. You may feel trapped in Platform as a Service (PaaS) offerings that handle the job but lack the performance you would like, cost way more than you want, and have incidents entirely out of your control. Here, you will learn how to create a server of your own that can handle a massive amount of traffic and compute. At the same time, it will provide the reliability and isolation that you would expect from handing your app over to the cloud.
The idea of running your own Linux server might be scary to you. How are you going to keep it up to date? What happens if the power goes out? What if the internet goes down? How will you have redundancy for all of these things? Don't worry. We're not creating our own data centers or running our own hardware. We're just co-opting a small slice of the cloud while avoiding the deep lock-in that the hyperscale cloud providers want to entice you to build into your application.
One of the biggest concerns people have running their applications in the cloud is cost. And while the number of cloud services you can choose to help run your application, such as serverless functions, managed databases, log aggregation, and so many more, keep growing, they also each come with their own cost and complexity. Before you know it, you can find yourself locked into paying a hefty sum without many options. Today, headlines like "Amazon's cloud unit records highest profit margin in at least a decade" and "The Dangers of Serverless Hosting: A Cautionary Tale of a $96,000 Cloud Bill" should serve as a warning to budding Python app developers. AWS has its highest profits because they are massively over charging for their services and locking customers in as they grow. Explosive bills come from a misunderstanding of costs and just letting the cloud scale things up as needed (so simple, we got your scaling covered for you!).
At Talk Python, we handle over 15 TB of traffic and 9M requests per month for under $100 in total with over 99.99% uptime. This cost will only go up if we increase our traffic to over 20x what it currently is. Much of what is covered in this book is how I've accomplished that with the infrastructure that we have chosen today.
My guidance and recommendations here are not all or nothing. We will cover many ideas. You can take the ones you think work best for you and others you don't feel fit your situation; you can leave them behind. The first half of this book is more theoretical, setting the stage for many of the ideas we cover. In the second half, we get hands-on looking at specific configuration files, how we build out servers, how we build out containers, and how we do this quickly and efficiently.
It's an amazing journey that has been very rewarding for me at Talk Python and has served us extremely well over the last couple of years. Much of this advice will serve you well. I hope you enjoy this journey. Let's dive in.