Latest / Talk Python To Me / #533: Web Frameworks in Prod by Their Creators
Transcript
- 0:00Michael Kennedy: Today on Talk Python, the creators behind FastAPI, Flask, Django, Quart, and Litestar
- 0:05Michael Kennedy: get practical about running apps based on their frameworks in production.
- 0:10Michael Kennedy: Deployment patterns, async gotchas, servers, scalings, and the stuff that you only learn
- 0:15Michael Kennedy: at 2 a.m. when the pager starts going off.
- 0:17Michael Kennedy: For Django, we have Carlton Gibson and Jeff Triplich.
- 0:21Michael Kennedy: For Flask, we have David Lord and Phil Jones.
- 0:23Michael Kennedy: And on Team Litestar, we have Janek Nouvertné and Cody Fincher.
- 0:28Michael Kennedy: And finally, Sebastian Ramirez from FastAPI is here as well.
- 0:32Michael Kennedy: Let's jump in.
- 0:33Michael Kennedy: This is Talk Python To Me, episode 533, recorded December 17th, 2025.
- 0:55Michael Kennedy: Welcome to Talk Python To Me.
- 0:57Michael Kennedy: the number one Python podcast for developers and data scientists.
- 1:01Michael Kennedy: This is your host, Michael Kennedy.
- 1:02Michael Kennedy: I'm a PSF fellow who's been coding for over 25 years.
- 1:07Michael Kennedy: Let's connect on social media.
- 1:08Michael Kennedy: You'll find me and Talk Python on Mastodon, Bluesky, and X.
- 1:11Michael Kennedy: The social links are all in your show notes.
- 1:14Michael Kennedy: You can find over 10 years of past episodes at talkpython.fm.
- 1:18Michael Kennedy: And if you want to be part of the show, you can join our recording live streams.
- 1:21Michael Kennedy: That's right.
- 1:22Michael Kennedy: We live stream the raw uncut version of each episode on YouTube.
- 1:26Michael Kennedy: Just visit talkpython.fm/youtube to see the schedule of upcoming events.
- 1:30Michael Kennedy: Be sure to subscribe there and press the bell so you'll get notified anytime we're recording.
- 1:35Michael Kennedy: Hey, before we jump into the interview, I just want to send a little message to all the companies
- 1:39Michael Kennedy: out there with products and services trying to reach developers.
- 1:44Michael Kennedy: That is the listeners of this show.
- 1:46Michael Kennedy: As we're rolling into 2026, I have a bunch of spots open.
- 1:50Michael Kennedy: So please reach out to me if you're looking to sponsor a podcast or just generally sponsor
- 1:56Michael Kennedy: things in the community and you haven't necessarily considered podcasts, you really should.
- 2:00Michael Kennedy: Reach out to me and I'll help you connect with the Talk Python audience.
- 2:05Michael Kennedy: Thanks everyone for listening all of 2025. And here we go into 2026. Cheers.
- 2:11Michael Kennedy: Hello, hello, Carlton, Sebastian, David, Cody, Yannick, Phil, Jeff, welcome back to Talk Python,
- 2:19Michael Kennedy: all of you. Thanks for having us. Thank you for having us. Happy to be here again. We're here for
- 2:22Michael Kennedy: what may be my favorite topic for sure. Something I spend most of my time on is web API stuff,
- 2:30Michael Kennedy: which is awesome. So excited to have you here to give your inside look at how people should
- 2:36Michael Kennedy: be running your framework, at least the one that you significantly contribute to, depending on
- 2:42Michael Kennedy: which framework we're talking about, right? It's going to be a lot of fun, and I'm really excited
- 2:47Michael Kennedy: to talk about it. However, there's an interesting fact that I've been throwing out a lot lately is
- 2:51Michael Kennedy: that fully half of the people doing professional Python development have only been doing it for two
- 2:56Michael Kennedy: years or less. And some of you been on the show, it was maybe two years longer than that. Let's just
- 3:01Michael Kennedy: do a quick round of introductions for people who don't necessarily know you. We'll go around the
- 3:06Michael Kennedy: squares here in the screen sharing. So Carlton, you're up first. Oh, I get to go first. Brilliant.
- 3:11Carlton Gibson: Well, I'm Carlton. I work on the Django Red framework mostly. I'm a former Django fellow.
- 3:16Carlton Gibson: I maintain a number of packages in the ecosystem. And the last few years I've been back to building
- 3:20Carlton Gibson: stuff with Django rather than working on it. So I run a build startup that's, well, we're still
- 3:25Michael Kennedy: going. So I'm quite excited about that. Awesome. How is it to be building with Django than building
- 3:30Carlton Gibson: Django? Oh, I'm literally having the time of my life. Like I spent five years as a Django fellow
- 3:36Carlton Gibson: working on Django and I just built up this backlog of things I wanted to do and I had no time and no
- 3:42Carlton Gibson: capacity and no, no sort of nothing to work on with them. And it's just, it's just a delight.
- 3:46Carlton Gibson: And every day I sit down on my computer thinking, oh, what's today?
- 3:50Carlton Gibson: I look at the background.
- 3:51Carlton Gibson: Oh, yes.
- 3:52Carlton Gibson: And every day, a delight.
- 3:54Carlton Gibson: So I'm still just loving it.
- 3:56Carlton Gibson: That's awesome.
- 3:57Michael Kennedy: So more often you're appreciating your former self than cursing your former self
- 4:01Michael Kennedy: for the way you built.
- 4:04Michael Kennedy: Yeah, that's an interesting one.
- 4:05Michael Kennedy: I think we should move on before.
- 4:07Michael Kennedy: All right.
- 4:08Michael Kennedy: All right.
- 4:09Michael Kennedy: Speaking of building with and for Sebastian, FastAPI.
- 4:14Michael Kennedy: Hello.
- 4:14Michael Kennedy: Hello.
- 4:15Michael Kennedy: So, okay, intro for the ones that don't know me.
- 4:18Michael Kennedy: I'm Sebastian Ramirez.
- 4:19Michael Kennedy: I created FastAPI.
- 4:21Michael Kennedy: Yeah, that's pretty much it.
- 4:23Michael Kennedy: And now I have been building a company since the last two years, FastAPI Cloud, to deploy
- 4:27Michael Kennedy: FastAPI.
- 4:28Michael Kennedy: So, I get to drink from funny cups, as you can see.
- 4:33Michael Kennedy: The world's best boss.
- 4:35Michael Kennedy: Amazing.
- 4:36Michael Kennedy: So, I think you deserve to give a bit of a shout out to FastAPI Cloud.
- 4:39Michael Kennedy: That's a big deal.
- 4:40Michael Kennedy: Thank you.
- 4:40Michael Kennedy: Thank you very much.
- 4:41Michael Kennedy: Yeah, it's super fun.
- 4:42Michael Kennedy: And the idea is to make it super simple to deploy FastAPI applications.
- 4:47Michael Kennedy: The idea with FastAPI was to make it very simple to build applications, build APIs,
- 4:52Michael Kennedy: and get the idea from idea to product in record time.
- 4:57Michael Kennedy: That was the idea with FastAPI.
- 4:59Michael Kennedy: But then deploying that, in many cases, is just too cumbersome.
- 5:02Michael Kennedy: It's too complicated.
- 5:03Michael Kennedy: There are just so many things to that.
- 5:05Michael Kennedy: So I wanted to bring something for people to be able to say, like,
- 5:09Michael Kennedy: hey, just one command FastAPI deploy, and we take care of the rest.
- 5:12Michael Kennedy: And then we and the team, I have an amazing thing
- 5:15Michael Kennedy: that I've been able to work with.
- 5:17Michael Kennedy: We suffer all the cloud pains so that people
- 5:20Michael Kennedy: don't have to deal with that.
- 5:21Michael Kennedy: And yeah, it's painful to build, but it's so cool to use it.
- 5:25Michael Kennedy: You know, like that's the part when I say like, yes,
- 5:28Michael Kennedy: this was worth it.
- 5:29Michael Kennedy: When I get to use the thing myself, that is super cool.
- 5:32Michael Kennedy: MARK MANDEL: Yeah, I'm assuming you build FastAPI
- 5:34Michael Kennedy: Cloud with FastAPI somewhat.
- 5:35Michael Kennedy: FRANCISCO MOLIN: Yes, yes, yes, exactly.
- 5:37Michael Kennedy: FastAPI Cloud runs on FastAPI Cloud.
- 5:40Michael Kennedy: And I get just like now random things in there and like, yes.
- 5:44Michael Kennedy: Congrats to that again.
- 5:45Michael Kennedy: That's super cool.
- 5:46Michael Kennedy: David Lord, welcome.
- 5:47Michael Kennedy: Welcome back.
- 5:48David Lord: Yeah.
- 5:48David Lord: Hello.
- 5:49David Lord: I'm David Lord.
- 5:49David Lord: I'm the lead maintainer of Pallets, which is Flask, Jinja, Click, Werkzeug.
- 5:55David Lord: ItsDangerous, MarkupSafe.
- 5:56David Lord: And now Pallets Eco, which is a bunch of the famous extensions for Flask that are getting
- 6:02David Lord: community maintenance now.
- 6:04David Lord: I've been doing that since, I think I've been the lead maintainer since like 2019, but a
- 6:08David Lord: maintainer since like 2017.
- 6:09David Lord: So it's been a while.
- 6:10Michael Kennedy: That's been a while.
- 6:11Michael Kennedy: We're coming up on seven, eight years.
- 6:14Michael Kennedy: That's crazy.
- 6:15Michael Kennedy: Time flies.
- 6:15David Lord: It's always funny because I always feel like I've been doing it for way, way longer.
- 6:18David Lord: And then I look at the actual date that I got added as a maintainer.
- 6:21David Lord: I'm like, well, it couldn't have been that late.
- 6:22Michael Kennedy: I was doing stuff before that, right?
- 6:24Michael Kennedy: Well, I'm sure you were deep in flask before you got added as a maintainer of it, right?
- 6:28Michael Kennedy: Yeah.
- 6:28Michael Kennedy: Phil Jones, since you are also on the same org, next.
- 6:32Michael Kennedy: Hey, welcome back.
- 6:32Michael Kennedy: Hello.
- 6:33Phil Jones: Yeah, I'm Phil Jones.
- 6:34Phil Jones: I am the author of Quart, which is also part of Pallets.
- 6:37Phil Jones: I also work on Werkzeug and Flask and help out there.
- 6:42Phil Jones: And I've done a server called Hypercorn as well.
- 6:44Phil Jones: So a bit of interest in that part of the ecosystem.
- 6:47Phil Jones: What is Quart for people who don't know?
- 6:50Phil Jones: Quart is basically Flask with async await.
- 6:53Phil Jones: And that was the idea behind it really to make it possible to do async await.
- 6:57Phil Jones: So yeah, that's pretty much it.
- 6:58Phil Jones: If we, when we manage to merge them, we will.
- 7:00David Lord: And the goal now with Quart as part of palettes is to eventually have it be one code base with Flask.
- 7:07David Lord: But given that we both have small children now, we're moving a lot slower.
- 7:13Michael Kennedy: Having kids is great.
- 7:14Michael Kennedy: I have three kids.
- 7:15Michael Kennedy: Productivity is not a thing that they are known to imbue on the parents, right?
- 7:20Michael Kennedy: Especially in the early days.
- 7:21Michael Kennedy: I want to say, Phil, thank you.
- 7:23Michael Kennedy: I've been running Quart for a couple of my websites lately, and it's been amazing.
- 7:26Phil Jones: Nice.
- 7:27Phil Jones: Yeah, I also use it at work.
- 7:29Phil Jones: We've got all our stuff in Quart, which is, yeah, it's really good fun.
- 7:31Phil Jones: A bit like Carlton.
- 7:32Michael Kennedy: So when people, if they get, if they listen to the show or they go to the website of the show and they're not on YouTube, then that somehow involves Quart.
- 7:39Janek Nouvertné: Janek, welcome.
- 7:40Janek Nouvertné: Hey.
- 7:41Janek Nouvertné: Yeah, I'm Janek Nouvertné.
- 7:42Janek Nouvertné: I work on Litestar.
- 7:44Janek Nouvertné: I just looked up how long it's been because I was curious myself.
- 7:48Janek Nouvertné: I also had the same feeling that it's been a lot longer than, it's actually only been three years.
- 7:53Janek Nouvertné: Yeah.
- 7:53Janek Nouvertné: And I also, I noticed something with all you guys here in the room.
- 7:57Janek Nouvertné: I use almost all of the projects you maintain at work,
- 8:01Janek Nouvertné: which is quite nice.
- 8:04Janek Nouvertné: We have a very big Django deployment.
- 8:06Janek Nouvertné: We have some Flask deployments.
- 8:08Janek Nouvertné: We have a few FastAPI deployments.
- 8:10Janek Nouvertné: I think we have one Quart deployment
- 8:12Janek Nouvertné: and we also have two Litestar deployments,
- 8:15Janek Nouvertné: which obviously is a lot of fun to work with.
- 8:17Janek Nouvertné: And I find it really, really nice actually
- 8:20Janek Nouvertné: to work with all these different things.
- 8:23Janek Nouvertné: It's super interesting also because like everything
- 8:26Janek Nouvertné: has its own niche that it's really good at.
- 8:29Janek Nouvertné: And even, you know, you think
- 8:31Janek Nouvertné: if you maintain a framework yourself,
- 8:33Janek Nouvertné: you tend to always recommend it for everything.
- 8:36Janek Nouvertné: But I noticed it's not actually true.
- 8:38Janek Nouvertné: There's actually quite a few cases
- 8:40Janek Nouvertné: where I don't recommend Litestar.
- 8:42Janek Nouvertné: I recommend, you know, just, you know,
- 8:44Janek Nouvertné: use Django for this or, you know,
- 8:47Janek Nouvertné: use Flask for that or use FastAPI for this
- 8:49Janek Nouvertné: because, well, they are quite different after all.
- 8:52Janek Nouvertné: And I find that really, really interesting
- 8:55Janek Nouvertné: and nice. And I think it's a good sign of a healthy ecosystem if it's not just, you know,
- 9:00Janek Nouvertné: the same thing, but different, but it actually brings something very unique and different to
- 9:04Michael Kennedy: the table. I think that's a great attitude. And it's very interesting. You know, I feel like
- 9:08Michael Kennedy: there's a lot of people who feel like they've kind of got to pick their tech team for everything.
- 9:13Michael Kennedy: I'm going to build a static site. Like, well, I've got to have a Python-based static site builder.
- 9:17Michael Kennedy: Like, well, it's a static site. Who cares what technology makes it turn? You're writing Markdown,
- 9:21Michael Kennedy: and out comes HTML.
- 9:22Michael Kennedy: Who cares what's in the middle, for example, right?
- 9:24Michael Kennedy: And, you know, I feel like that's kind of a life lessons learned.
- 9:28Michael Kennedy: Absolutely, yeah.
- 9:29Michael Kennedy: Yeah, that's awesome.
- 9:30Michael Kennedy: Cody, hello, hello.
- 9:31Cody Fincher: Yeah, hey guys, I'm Cody Fincher.
- 9:32Cody Fincher: I'm also one of the maintainers of Litestar.
- 9:34Cody Fincher: I've been there just a little bit longer than Yannick.
- 9:37Cody Fincher: And so it's been about four years now.
- 9:40Cody Fincher: And Yannick actually teed this up perfectly
- 9:42Cody Fincher: because I was going to say something very similar.
- 9:43Cody Fincher: I currently work for Google.
- 9:44Cody Fincher: I've been there for about three and a half years now.
- 9:46Cody Fincher: And we literally have every one of the frameworks
- 9:49Cody Fincher: you guys just mentioned,
- 9:50Cody Fincher: and they're all in production.
- 9:51Cody Fincher: And so one of the things that you'll see
- 9:54Cody Fincher: on the Litestar org and part of the projects
- 9:56Cody Fincher: that we maintain are that we have these optional batteries
- 9:59Cody Fincher: and most of the batteries that we have
- 10:01Cody Fincher: all work with the frameworks for you guys.
- 10:03Cody Fincher: And so it's nice to be able to use that stuff,
- 10:06Cody Fincher: you know, regardless of what tooling you've got
- 10:08Cody Fincher: or what project it is.
- 10:10Cody Fincher: And so, yeah, having that interoperability
- 10:12Cody Fincher: and the ability to kind of go between the frameworks
- 10:14Cody Fincher: that work the best for the right situation is crucial.
- 10:16Cody Fincher: And so I'm glad you mentioned that, Yannick.
- 10:18Cody Fincher: But yeah, nice to see you guys
- 10:20Michael Kennedy: on the show. Cody, tell people what Litestar is. I know I had both you guys and Jacob on a while
- 10:25Michael Kennedy: ago, but it's been a couple of years, I think. Litestar at its core is really a web framework
- 10:30Cody Fincher: that kind of sits somewhere in between, I'd say, Flask and FastAPI and Django. So whereas, you know,
- 10:36Cody Fincher: Flask doesn't really, you know, bundle a lot of batteries. There's a huge amount of, you know,
- 10:41Cody Fincher: third-party libraries and ecosystem that's built around it that people can add into it, but there's
- 10:44Cody Fincher: not really like, for instance, a database adapter or a database plugin or plugins for
- 10:50Cody Fincher: Vite or something like that, right, for front end development. And so what we have been doing
- 10:54Cody Fincher: is building a API framework that is very similar in concept to FastAPI that is also extensible.
- 10:59Cody Fincher: So if you want to use the batteries, they're there for you. But if you don't want to use
- 11:03Cody Fincher: them, you don't have to, right? And so a lot of the tooling that we built for Litestar
- 11:07Cody Fincher: was birthed out of a startup that I was in prior to joining Google. And so having all
- 11:12Cody Fincher: this boilerplate, really, it needed somewhere to go.
- 11:15Cody Fincher: And so a lot of this stuff ended up being plugins,
- 11:17Cody Fincher: which is what we bundled into Litestar
- 11:19Cody Fincher: so that you can kind of add in this extra functionality.
- 11:22Cody Fincher: And so I know I'm getting long-winded.
- 11:24Cody Fincher: It's somewhere between Django and Flask,
- 11:27Cody Fincher: if you were to think about it in terms of a spectrum,
- 11:29Cody Fincher: in terms of what it gives you in terms of a web framework.
- 11:32Cody Fincher: But in short, it does everything that all the other guys do.
- 11:35Michael Kennedy: Very neat. It's definitely a framework I admire.
- 11:37Michael Kennedy: Jeff Triplett, so glad you could make it.
- 11:39Jeff Triplett: Yeah, thanks for having me.
- 11:40Jeff Triplett: Yeah, I'm Jeff Triplett. I'm out of Lawrence, Kansas.
- 11:42Jeff Triplett: I'm a consultant at a company called Revolution Systems.
- 11:45Jeff Triplett: I was on, some people know me from being on the Python Software Foundation board.
- 11:48Jeff Triplett: I've been off that for a few years.
- 11:50Jeff Triplett: As of last week, I'm the president of the Django Software Foundation.
- 11:53Jeff Triplett: So I've been on that board for a year.
- 11:54Jeff Triplett: I'm kind of a Django power user, I guess.
- 11:56Jeff Triplett: I've used it for about 20 years.
- 11:58Jeff Triplett: And I've kind of not really worked on, I don't even think I have a patch anymore in Django.
- 12:02Jeff Triplett: But I've done a lot with the community.
- 12:04Jeff Triplett: I've done a lot with contributing through conferences and using utilities.
- 12:09Jeff Triplett: I try to promote Carleton's applications like Neapolitan.
- 12:12Jeff Triplett: And if I like tools, Python tools in general, I try to advocate for it.
- 12:16Jeff Triplett: I've also used all of these applications.
- 12:18Jeff Triplett: Litestar, I haven't, but I have a friend who talks about it a lot.
- 12:21Jeff Triplett: And so I feel like I know a lot from it.
- 12:23Jeff Triplett: As a consultant, we tend to go with the best tool for the job.
- 12:25Jeff Triplett: So I've done a little bit of FastAPI.
- 12:27Jeff Triplett: I worked with Flask a lot over the years, even though we're primarily a Django shop.
- 12:31Jeff Triplett: It just depends on what the client needs.
- 12:32Michael Kennedy: And you see a lot of different sizes of web app deployments.
- 12:36Michael Kennedy: So I think that's going to be an interesting angle for sure.
- 12:38Jeff Triplett: Yeah, absolutely.
- 12:39Jeff Triplett: Small ones to hundreds of servers.
- 12:42Jeff Triplett: We don't see it as much anymore the last four or five years, especially with like CDNs and caching.
- 12:46Jeff Triplett: We just don't see load like we did, you know, 10 years ago or so.
- 12:50Jeff Triplett: And then I also do a lot of like small, I kind of call them some of them little dumb projects, but some are just fun.
- 12:55Jeff Triplett: Like I've got a FastAPI web ring that I wrote a year ago for April Fool's Day.
- 13:00Jeff Triplett: And for some reason that kind of took off and people liked it, even though it was kind of a joke.
- 13:03Jeff Triplett: So I started like peppering it on a bunch of sites and I maintain like Django packages.
- 13:08Jeff Triplett: I do a newsletter, Django News newsletter, just kind of lots of fun stuff.
- 13:11Michael Kennedy: Definitely looking forward to hearing all of your opinions.
- 13:14Michael Kennedy: So I've got a bunch of different your app in production topics
- 13:17Michael Kennedy: I thought we could just work around or talk over.
- 13:20Michael Kennedy: So I thought maybe the first one is what would you recommend,
- 13:24Michael Kennedy: or if you don't really have a strong recommendation,
- 13:26Michael Kennedy: what would you choose for yourself to put your app in your framework in production?
- 13:32Michael Kennedy: I'm thinking app servers, reverse proxies like Nginx or Caddy.
- 13:36Michael Kennedy: Do you go for threaded?
- 13:37Michael Kennedy: Try to scale out with threads.
- 13:39Michael Kennedy: you try to scale out with processes, Docker, no Docker, Kubernetes. What are we doing here,
- 13:44Michael Kennedy: folks? Carlton. I think we'll just keep going around the circle here. So you may get the first
- 13:49Michael Kennedy: round of everyone. No, I'll try to mix it up, but let's do it this time.
- 13:52Carlton Gibson: I do the oldest school thing in the book. I run Nginx as my front end. I'll stick a
- 14:00Carlton Gibson: WSGI server behind it with a pre-fork, a few workers, depending on CPU size, depending on
- 14:05Carlton Gibson: the kind of requests I'm handling. These days, in order to handle long-lived requests,
- 14:10Carlton Gibson: like server-sent events, that kind of, or WebSocket type things, I'll run an ASGI server as a kind
- 14:14Carlton Gibson: of sidecar. I've been thinking about this a lot, actually. But yeah, this is interesting.
- 14:18Carlton Gibson: If you're running a small site and you want long-lived requests, just run ASGI. Just use
- 14:22Carlton Gibson: ASGI. Because any of the servers, Hypercorn, Uvicorn, Daphne, Granian is the new hot kid on
- 14:29Carlton Gibson: the bot, right? All of those will handle your traffic, no problem. But for me, the scaling
- 14:34Carlton Gibson: Pallets and WSGI are so well known and just like i can do the maths on the back of the pencil i know
- 14:39Carlton Gibson: exactly how to scale it up having done it for so long for me for my core application i would still
- 14:45Carlton Gibson: rather use the wsgi server and then limit the async stuff to just to the use cases where it's
- 14:51Carlton Gibson: particularly suited so i'll do that um process manager i deploy using systemd if i want to if i
- 14:58Carlton Gibson: want a container i'll use podman by systemd it's as old school as it gets i'll very often run a
- 15:03Carlton Gibson: a Redis instance on localhost for caching,
- 15:05Carlton Gibson: and that will be it.
- 15:08Carlton Gibson: And that will get me an awful long way.
- 15:09Carlton Gibson: If I have to schedule,
- 15:10Carlton Gibson: I just get a bigger box.
- 15:12Carlton Gibson: And a bigger box.
- 15:13Carlton Gibson: Yeah, yeah, yeah.
- 15:13Carlton Gibson: I really, really, really need multiple boxes.
- 15:16Carlton Gibson: Well, then we'll talk.
- 15:16Michael Kennedy: I feel like you and I are in a similar vibe.
- 15:18Michael Kennedy: But one thing I want to sort of throw out there to you,
- 15:20Michael Kennedy: but also sort of the others is,
- 15:22Michael Kennedy: what are we talking with databases?
- 15:24Michael Kennedy: Like, who is bold enough to go SQLite?
- 15:26Michael Kennedy: Anyone's going SQLite out there?
- 15:28Cody Fincher: Yeah, it depends, right?
- 15:30Cody Fincher: It just depends on what you're doing, right?
- 15:31Cody Fincher: And how many concurrent users you're going to have.
- 15:33Cody Fincher: It really is amazing there.
- 15:34David Lord: The Palette's website is running on Flask,
- 15:37David Lord: which I wasn't doing for a while.
- 15:38David Lord: I was doing a static site generator.
- 15:39David Lord: Then I got inspired by Andrew Godwin's static dynamic sites.
- 15:43David Lord: And so it loads up all these markdown files,
- 15:46David Lord: static markdown files into a SQLite database at runtime
- 15:50David Lord: and then serves off of that
- 15:51David Lord: because you can query really fast.
- 15:53David Lord: Oh, that's awesome. I love it.
- 15:54David Lord: So I am using SQLite for the Palette's website.
- 15:56Janek Nouvertné: Yeah, I also do have a few small apps that use SQLite.
- 16:00Janek Nouvertné: And one recently that's Cody's fault
- 16:03Janek Nouvertné: because he put me on that track
- 16:05Janek Nouvertné: where it's running a SQLite database in the browser
- 16:08Janek Nouvertné: because nowadays it's quite easy to do that.
- 16:12Janek Nouvertné: And then you can do all sorts of stuff with it,
- 16:15Janek Nouvertné: like hook into it with DuckDB and perform some analysis.
- 16:19Janek Nouvertné: So you don't actually need to run any sort of server at all.
- 16:23Janek Nouvertné: You can just throw some files into Nginx and serve your data.
- 16:26Janek Nouvertné: And as long as that's static,
- 16:28Janek Nouvertné: you have a super, super simple deployment.
- 16:30Janek Nouvertné: So yeah, definitely SQLite.
- 16:32Michael Kennedy: If you can, I like it.
- 16:34Michael Kennedy: I agree.
- 16:35Michael Kennedy: It's interesting.
- 16:36Michael Kennedy: The database probably won't go down with that, probably.
- 16:38Michael Kennedy: Let's do this by framework.
- 16:40Michael Kennedy: So we'll do vertical slices in the visual here.
- 16:42Michael Kennedy: So Jeff.
- 16:43Jeff Triplett: Yeah, Django, Postgres, pretty old school stack.
- 16:46Jeff Triplett: I think putting a CD in front of anything is just a win.
- 16:49Jeff Triplett: So whether you like Fastly or Cloudflare,
- 16:51Jeff Triplett: you get a lot of mileage out of it.
- 16:52Jeff Triplett: You learn a lot about caching
- 16:53Jeff Triplett: because it's kind of hard to cache Django by default.
- 16:56Jeff Triplett: So you get to play with curl
- 16:57Jeff Triplett: and kind of figure out why very headers are there.
- 16:59Jeff Triplett: And it's a good learning experience to get through that.
- 17:02Jeff Triplett: I also like Coolify, which is kind of new, at least new to me and new to Michael.
- 17:06Jeff Triplett: We talk about this in our spare time a lot.
- 17:08Jeff Triplett: It's just kind of a boring service that'll launch a bunch of containers for you.
- 17:12Jeff Triplett: There's a bunch of one-click installs, so Postgres is a one-click.
- 17:15Jeff Triplett: It also does backups for you, which is really nice to have for free.
- 17:18Jeff Triplett: I run a couple dozen sites through it and really like it.
- 17:21Jeff Triplett: You can either do a hosted forum, I don't get any money from it, or you can run the open-source version.
- 17:26Jeff Triplett: I do both.
- 17:27Jeff Triplett: I've got like a home lab that I just run stuff using the open-source version.
- 17:30Jeff Triplett: And for five bucks a month, it's worth it to run a couple servers.
- 17:33Jeff Triplett: And like Carlton said, you can just scale up.
- 17:35Michael Kennedy: Yeah, it's got a bunch of one-click deploy for self-hosted SaaS things as well.
- 17:40Michael Kennedy: Like I want an analytics stack of containers that run in its own isolated bit.
- 17:44Michael Kennedy: Just click here and go.
- 17:46Jeff Triplett: Yeah, one-click, it's installed and you're up.
- 17:48Jeff Triplett: And then once you get one Django, Flask, FastAPI site working with it,
- 17:53Jeff Triplett: and it uses like a Docker container.
- 17:54Jeff Triplett: Once you get that set up, it's really easy to just kind of duplicate that site,
- 17:58Jeff Triplett: plug it in to GitHub or whatever your Git provider is.
- 18:01Jeff Triplett: And it's a nice experience for what normally is just our syncing files
- 18:05Jeff Triplett: and life's too short for that.
- 18:06Michael Kennedy: Sebastian, I want to have you go last on this one
- 18:09Michael Kennedy: because I think you've got something pretty interesting
- 18:12Michael Kennedy: with FastAPI Cloud to dive into.
- 18:14Michael Kennedy: But let's do Litestar next. Cody.
- 18:16Cody Fincher: I have actually bought all the way in on Granian.
- 18:19Cody Fincher: So for the ASGI server, I've actually been running Granian now
- 18:22Cody Fincher: for I'd say a year in production.
- 18:24Cody Fincher: It's worked pretty well.
- 18:26Cody Fincher: There's a couple of new things that I'm actually kind of
- 18:28Cody Fincher: with. I don't know how well they're going to work out. So I'm going to go ahead and throw this out
- 18:31Cody Fincher: there. But Granian is one of the few ASGI servers that supports HTTP2. And it actually can do HTTP2
- 18:38Cody Fincher: clear text. And so this is part of the next thing I'm going to say. Because I work for Google, I'm
- 18:42Cody Fincher: actively using lots of Kubernetes and Cloud Run mainly. And so most of the things that I deploy
- 18:47Cody Fincher: are containerized on Cloud Run. And I typically would suggest if you're not using something like
- 18:53Cody Fincher: SystemD and deploying it directly on bare metal, then you are going to want to let the container
- 18:57Cody Fincher: or whatever you're using to manage your processes,
- 19:00Cody Fincher: manage that and spin that up.
- 19:01Cody Fincher: And so I typically try to allocate,
- 19:04Cody Fincher: you know, like one CPU for the container
- 19:05Cody Fincher: and let the actual framework scale it up and down as needed.
- 19:09Cody Fincher: Cloud Run itself has a, like an ingress,
- 19:11Cody Fincher: like a load balancer that sits in front
- 19:13Cody Fincher: that it automatically configures.
- 19:14Cody Fincher: And you're required to basically serve up
- 19:17Cody Fincher: clear text traffic in when you run Cloud Run.
- 19:19Cody Fincher: And because now Granian supports HTTP2
- 19:22Cody Fincher: and Cloud Run supports HTTP2 clear text,
- 19:25Cody Fincher: you can now serve Granian as HTTP2 traffic.
- 19:28Cody Fincher: The good thing about that is that you get an unlimited upload size.
- 19:31Cody Fincher: And so there are max thresholds to what you can upload
- 19:33Cody Fincher: into the various cloud environments.
- 19:35Cody Fincher: HTTP2 usually circumvents that or gets around it
- 19:37Cody Fincher: because of the way the protocol works.
- 19:39Cody Fincher: And so you git additional features and functionality because of that.
- 19:42Cody Fincher: So anyway, that's what I typically do.
- 19:44Cody Fincher: And most of my databases are usually Postgres,
- 19:47Cody Fincher: AlloyDB if it needs to be something that's on the analytical side.
- 19:50Michael Kennedy: Yeah, I'm on Team Granian as well.
- 19:52Michael Kennedy: I think that's a super neat framework.
- 19:53Michael Kennedy: I had Giovanni on who's behind it a while ago.
- 19:57Michael Kennedy: It seems like it's not as popular,
- 20:00Michael Kennedy: but it's based on Hyper from the Rust world,
- 20:02Michael Kennedy: which has like 130,000 projects based on it or something.
- 20:05Michael Kennedy: So, you know, at its core, it's still pretty battle-tested.
- 20:11Michael Kennedy: this portion of talk python to me is brought to you by our course just enough python for data
- 20:16Michael Kennedy: scientists if you live in notebooks but need your work to hold up in the real world check out just
- 20:21Michael Kennedy: enough python for data scientists it's a focused code first course that tightens the python you
- 20:26Michael Kennedy: actually use and adds the habits that make results repeatable we refactor messy cells into functions
- 20:33Michael Kennedy: and packages, use Git on easy mode, lock environments with uv, and even ship with Docker.
- 20:39Michael Kennedy: Keep your notebook speed, add engineering reliability.
- 20:42Michael Kennedy: Find it at Talk Python Training.
- 20:44Michael Kennedy: Just click courses in the navbar at talkpython.fm.
- 20:47Michael Kennedy: Yannick, how about you?
- 20:49Michael Kennedy: You've got a variety, it sounds like.
- 20:50Michael Kennedy: Yeah, definitely.
- 20:53Janek Nouvertné: There's a pretty clear split between what I do at work and what I do outside of that.
- 20:59Janek Nouvertné: So at work, it's Kubernetes deployments.
- 21:01Janek Nouvertné: And we managed that pretty much the same way that Cody described.
- 21:05Janek Nouvertné: So it's one or two processes per pod max.
- 21:10Janek Nouvertné: So you can have Kubernetes scaled or even manually easily scale that up.
- 21:14Janek Nouvertné: You can just go into Kubernetes and say, OK, do me one to five more pods or whatever.
- 21:20Janek Nouvertné: And don't have to worry.
- 21:21Janek Nouvertné: Don't have to start calculating whatever.
- 21:23Janek Nouvertné: Most of the stuff we run nowadays with uvicorn or Django deployment
- 21:28Janek Nouvertné: up until I think three months ago or so was running under Gunicorn,
- 21:34Janek Nouvertné: but we switched that actually.
- 21:35Janek Nouvertné: And it's been a really great experience.
- 21:38Janek Nouvertné: I think we tried that a year ago and it didn't work out quite so well.
- 21:42Janek Nouvertné: There was some things that didn't work as expected or didn't perform great
- 21:47Janek Nouvertné: or Django was throwing some errors or Uvicorn was throwing some errors.
- 21:52Janek Nouvertné: And then apparently all of that got fixed
- 21:55Janek Nouvertné: because now it runs without any issue for the production.
- 21:58Michael Kennedy: Yeah, for people who don't know, the vibe used to be run Gunicorn, but then with uvicorn workers, if you're doing async stuff.
- 22:06Michael Kennedy: And then uvicorn kind of stepped up its game and said, you can actually treat us as our own app server.
- 22:12Michael Kennedy: We'll manage lifecycle and stuff.
- 22:14Michael Kennedy: And so that's the path you took, right?
- 22:16Janek Nouvertné: Yeah, exactly.
- 22:16Janek Nouvertné: Before that.
- 22:17Janek Nouvertné: Well, no, actually, before that, we didn't because our Django is fully synchronous.
- 22:22Janek Nouvertné: It doesn't do any async.
- 22:24Janek Nouvertné: So it was just bare metal Gunicorn.
- 22:26Janek Nouvertné: And it's still synchronous with just running it under Uvicorn.
- 22:30Janek Nouvertné: But interestingly, still quite a bit faster in a few cases.
- 22:34Janek Nouvertné: We tried that out and we low tested it in a couple of scenarios
- 22:38Janek Nouvertné: and we found that it makes a lot of sense.
- 22:41Janek Nouvertné: But outside of that, I do have a lot of, well,
- 22:44Janek Nouvertné: very simplistic deployments that are also just systemd
- 22:48Janek Nouvertné: and a couple of Docker compose files and containers
- 22:53Janek Nouvertné: that are managed through some old coupled together Ansible things.
- 22:59Janek Nouvertné: But I think the oldest one that I have still running is from 2017.
- 23:03Janek Nouvertné: And it's been running without a change for like four or five years.
- 23:07Janek Nouvertné: That is awesome.
- 23:08Janek Nouvertné: I don't see a reason to do anything about it because the app works.
- 23:11Janek Nouvertné: It's being used productively.
- 23:14Janek Nouvertné: So why change anything about that?
- 23:16Janek Nouvertné: No need to introduce.
- 23:17Janek Nouvertné: Just don't touch it.
- 23:18Janek Nouvertné: Yeah, I was actually looking into Coolify that you two guys mentioned.
- 23:22Janek Nouvertné: I was thinking about, you know, maybe upgrading it to that, but I played around with it and I thought, well, why?
- 23:28Janek Nouvertné: You know, if I have to look into that deployment maybe once a year.
- 23:31Janek Nouvertné: So that's really nothing to gain for me to make it more complicated.
- 23:36Janek Nouvertné: David, Team Flask.
- 23:38David Lord: I mentioned this before the show started, but I think I'm pretty sure I've said this the last time I was on Talk Python,
- 23:45David Lord: but the projects I do for work typically have less than 100 users.
- 23:51David Lord: And so my deployment is usually really simple.
- 23:54David Lord: And usually they've chosen like Azure or AWS already.
- 23:58David Lord: So we just have a Docker container
- 24:00David Lord: and we put it on the relevant Docker container host
- 24:03David Lord: in that service and it just works for them.
- 24:05David Lord: We have a Postgres database and we have like Redis.
- 24:08David Lord: But I never really had to deal with like scaling
- 24:11David Lord: or that sort of stuff.
- 24:13David Lord: But the funny thing is like, at least for my work,
- 24:16David Lord: I'm always, we're often replacing older systems.
- 24:19David Lord: And so even a single Docker container running a Flask application is way more performant and responsive than anything they're used to from like some 20 year old or 30 year old Java system.
- 24:32David Lord: Right. And it can just respond on a small container with like a little bit of CPU and a little bit of memory.
- 24:38David Lord: They're always shocked at like, how much do we need to pay for?
- 24:41David Lord: Oh, just like it'll run a potato.
- 24:44David Lord: You know, there's only 100 users and they're like, that's a lot of users.
- 24:48David Lord: So my recommendation is always start small and then scale up from there.
- 24:52David Lord: Don't try to overthink it ahead of time.
- 24:55David Lord: Yeah, for my personal stuff, I'm using like Docker containers now and fly.io.
- 24:59David Lord: I haven't gotten in.
- 25:00David Lord: So I do want to look into Granian and Coolify, but I haven't gotten there yet.
- 25:04David Lord: And for the Docker container, I can definitely recommend pythonspeed.org.
- 25:09David Lord: I don't remember off the top of my head who writes that, but it's somebody in the Python
- 25:13David Lord: ecosystem.
- 25:14David Lord: And they have a whole series of articles on how to optimize your Docker container.
- 25:18David Lord: And that sounds really complicated, but you end up with a Docker file that's like 20 lines
- 25:22David Lord: long or something.
- 25:23David Lord: So it's not like there's crazy things.
- 25:26David Lord: It's just you have to know how to structure it.
- 25:28David Lord: And then I just copy and paste that to the next project.
- 25:30David Lord: Nice.
- 25:30David Lord: Yeah.
- 25:31Michael Kennedy: I resisted doing Docker for a long time because I'm like, I don't want that extra complexity.
- 25:34Michael Kennedy: But then I realized the stuff you put in the Docker file is really what you just type in
- 25:38Michael Kennedy: the terminal once and then you forget.
- 25:41David Lord: I mean, always using Postgres, Redis, probably if I need some background.
- 25:44David Lord: tasks, just plain SMTP server for email. I wrote for all three of those things. I wrote new
- 25:51David Lord: extensions in the Flask ecosystem that I'm trying to get more people to know about now. So Flask
- 25:56David Lord: SQLAlchemy Lite, L-I-T-E, instead of Flask SQLAlchemy, takes a much more lightweight approach to
- 26:02David Lord: integrating SQLAlchemy with Flask. And then Flask Redis, I revived from like 10 years of
- 26:08David Lord: non-maintenance. And then I wrote this whole system, this whole pluggable email system called
- 26:12David Lord: email simplified, kind of inspired by Django, Django's pluggable system, except, and so there's
- 26:18David Lord: like Flask email simplified to integrate that with Flask. But unlike Django, you can use email
- 26:23David Lord: simplified in any library you're writing, in any Python application you're writing. It doesn't have
- 26:27David Lord: to be a Flask web framework. It's pluggable as the library itself. And then you can also integrate
- 26:32David Lord: it with Flask or something else. So Flask email simplified. I get like three downloads a month
- 26:38Michael Kennedy: right now. So it needs some popularity. Awesome. I've been doing the non-simplified email lately.
- 26:43Michael Kennedy: So I'm happy to hear that there might be a better way. Yeah. I think people do underappreciate just
- 26:48Michael Kennedy: how much performance you got out of Python web apps. You know, they're like, oh, we're going to
- 26:53Michael Kennedy: need to rewrite this and something else because the GIL or whatever. Like I decided just to make
- 26:59Michael Kennedy: a point to pull up the tail till my log running court, by the way. And each one of these requests
- 27:04Michael Kennedy: doing like multiple db calls and it's like 23 milliseconds six milliseconds three milliseconds
- 27:10Michael Kennedy: you know nine milliseconds it's like that's good enough for that's a lot of requests per second
- 27:16Michael Kennedy: per worker until you gotta you gotta have a lot of traffic speaking of court phil what's your take
- 27:21Phil Jones: on this one i think it's very similar i also build docker containers and uh with a postgres database
- 27:27Phil Jones: on the back end and i run hypercorn as the ascii server and put them behind a aws load balancer
- 27:34Phil Jones: and just run them in ECS.
- 27:36Phil Jones: And I think it's pretty simple,
- 27:38Phil Jones: but I guess it depends on your biases.
- 27:39Phil Jones: But yeah, that's all we do really.
- 27:41Phil Jones: And it goes a long way.
- 27:42Phil Jones: There are multiple ECS tasks,
- 27:45Phil Jones: mostly because if one falls over rather than scaling,
- 27:47Phil Jones: it's usually the database that you need to scale, I find.
- 27:50Phil Jones: But yeah, that's how we run it.
- 27:52Phil Jones: The nice thing for me about Hypercorn
- 27:54Phil Jones: is that I can play with HTTP 3.
- 27:56Phil Jones: So that's what we're doing at times.
- 27:57Michael Kennedy: Oh, HTTP 3, okay.
- 27:59Michael Kennedy: I've just been getting my HTTP 2 game down,
- 28:01Michael Kennedy: so I'm already behind the game.
- 28:03Michael Kennedy: What's the deal with HTTP/3?
- 28:05Phil Jones: It's obviously a totally new way of doing it over UDP now
- 28:08Phil Jones: rather than TCP.
- 28:10Phil Jones: Although at the application level,
- 28:11Phil Jones: you can't tell any difference really.
- 28:13Phil Jones: But I mean, I just find it interesting.
- 28:15Phil Jones: I'm not really sure it will help too much.
- 28:17Phil Jones: And it's probably best if you've got users who have not that
- 28:21Phil Jones: great a network connection.
- 28:22Phil Jones: But for most other cases, I don't think it matters too much.
- 28:25Michael Kennedy: Just keep blasting packets until some of them get through.
- 28:29Michael Kennedy: OK, fine.
- 28:30Michael Kennedy: We'll give you a page eventually.
- 28:31Michael Kennedy: There's three pages, actually.
- 28:32Michael Kennedy: All right, Sebastian, you are running not just FastAPI from your experience, but you're running FastAPI for a ton of people through FastAPI Cloud at, I'm sure, many different levels.
- 28:43Michael Kennedy: This probably sounds like a shameless plug, and it kind of is, but it's sort of expected.
- 28:48Michael Kennedy: I will deploy FastAPI or FastAPI Cloud.
- 28:51Michael Kennedy: Just because, well, the idea is just to make it super simple to do that.
- 28:54Michael Kennedy: You know, like if you are being able to run the command FastAPI run.
- 28:58Michael Kennedy: So FastAPI run has like the production server
- 29:01Michael Kennedy: that is using Uvicorn underneath.
- 29:03Michael Kennedy: And if you can run that,
- 29:04Michael Kennedy: then you can run also FastAPI deploy.
- 29:06Michael Kennedy: And then like, you know, like it will most probably just work.
- 29:10Michael Kennedy: And, you know, we just wrap everything and like deploy,
- 29:13Michael Kennedy: build, install, deploy, handle HTTPS, all the stuff
- 29:17Michael Kennedy: without needing any Docker file or anything like that.
- 29:19Michael Kennedy: And I think for many use cases,
- 29:20Michael Kennedy: it's just like simpler being able just to do that.
- 29:23Michael Kennedy: There are so many projects that I have been now building,
- 29:25Michael Kennedy: like random stuff that is not really important, but now I can.
- 29:30Michael Kennedy: And before it was like, yeah, well, I know how to deploy this thing like fully with like
- 29:34Michael Kennedy: all the bells and whistles, but it's just so much work that yeah, I know later.
- 29:38Michael Kennedy: So for that, I would end up just like going with that.
- 29:41Michael Kennedy: Now if I didn't...
- 29:42Michael Kennedy: Well, what I was going to ask is how much are you willing to tell us how things run inside
- 29:47Michael Kennedy: FastAPI Cloud?
- 29:48Michael Kennedy: Oh, I can't, it's just so much stuff that is going on.
- 29:52Michael Kennedy: And it's also, it's fun that nowadays that they're like,
- 29:57Michael Kennedy: we have Docker and we have Docker Swarm and there was Nomad
- 30:00Michael Kennedy: and Kubernetes and oh, Kubernetes won.
- 30:02Michael Kennedy: And then we have the cloud providers and there's AWS
- 30:06Michael Kennedy: and Google and Azure.
- 30:08Michael Kennedy: And you will expect that all these things
- 30:11Michael Kennedy: and all this complexity is like, now that it's like, okay,
- 30:14Michael Kennedy: these are the clear winners.
- 30:15Michael Kennedy: So it's like a lot of complexity to take on,
- 30:17Michael Kennedy: but once you do it all works, but it doesn't.
- 30:21Michael Kennedy: And it's just like so much work to get things to work together, to work correctly.
- 30:27Michael Kennedy: And the official resources from the different providers and things,
- 30:32Michael Kennedy: in many cases, it's like, oh, the solution is hidden in this issue somewhere in GitHub
- 30:36Michael Kennedy: because the previous version was obsolete,
- 30:38Michael Kennedy: but now the new version of this package or whatever is like, it's just, it's crazy.
- 30:43Michael Kennedy: But like, yeah, so if I didn't have FastAPI Cloud, I will probably use containers.
- 30:50Michael Kennedy: I will probably use Docker.
- 30:51Michael Kennedy: If it's like something simple,
- 30:53Michael Kennedy: I will deploy with Docker Compose,
- 30:55Michael Kennedy: probably try to scale minimum replicas.
- 30:57Michael Kennedy: I don't remember Docker Compose has that.
- 30:59Michael Kennedy: I remember that Docker Swarm had that,
- 31:01Michael Kennedy: but then Docker Swarm sort of lost against Kubernetes.
- 31:05Michael Kennedy: I will put a traffic load balancer in front
- 31:08Michael Kennedy: to handle HTTPS and, yeah, well, like regular load balancing.
- 31:12Michael Kennedy: And, yeah, just regular Uvicorn.
- 31:14Michael Kennedy: What some of the folks we were talking about before,
- 31:18Michael Kennedy: At some point, we needed to have Gunicorn on top of Uvicorn
- 31:22Michael Kennedy: because Uvicorn wouldn't be able to handle workers.
- 31:25Michael Kennedy: But now Uvicorn can handle its workers like everything
- 31:27Michael Kennedy: and handle the main thing was some VE processes
- 31:30Michael Kennedy: and reaping the processes and handling the stuff.
- 31:34Michael Kennedy: Now it can't just do that.
- 31:35Michael Kennedy: So you can just run plain Uvicorn.
- 31:37Michael Kennedy: So if you're using FastAPI and you say FastAPI run,
- 31:40Michael Kennedy: that already does that.
- 31:41Michael Kennedy: So if you're deploying on your own,
- 31:42Michael Kennedy: you can just use the FastAPI run command.
- 31:44Michael Kennedy: Then, of course, you have to deal with the scaling
- 31:47Michael Kennedy: and HTTPS and a lot of balancing
- 31:48Michael Kennedy: and all the stuff,
- 31:49Michael Kennedy: but the core server,
- 31:51Michael Kennedy: you can just run it directly.
- 31:53Michael Kennedy: If going beyond that,
- 31:55Michael Kennedy: then there will probably be
- 31:56Michael Kennedy: some cluster Kubernetes
- 31:58Michael Kennedy: and trying to scale things,
- 32:00Michael Kennedy: figure out the ways to scale things
- 32:02Michael Kennedy: based on the load of the requests,
- 32:05Michael Kennedy: like scaling automatically.
- 32:08Michael Kennedy: Having normally one container per process
- 32:10Michael Kennedy: to be able to scale that more dynamically
- 32:13Michael Kennedy: without depending on the local memory
- 32:14Michael Kennedy: for each one of the servers
- 32:15Michael Kennedy: and things like that,
- 32:16Michael Kennedy: I'm probably saying too much.
- 32:17Michael Kennedy: But yeah, actually, you know, like if I didn't have a CPI cloud,
- 32:20Michael Kennedy: I will probably use one of the providers that abstract those things a little bit away,
- 32:27Michael Kennedy: you know, like render, railway, fly, like, I don't know.
- 32:31Michael Kennedy: Like, I don't really think that a regular developer should be dealing with,
- 32:36Michael Kennedy: you know, like the big hyperscalers and like Kubernetes
- 32:39Michael Kennedy: and like all that complexity for a common app.
- 32:42Michael Kennedy: Most of the cases, I think it's just really too much complexity to real with.
- 32:47Michael Kennedy: It's kind of eye-watering to open up the AWS console or Azure or something.
- 32:52Michael Kennedy: Whoa.
- 32:52Michael Kennedy: Oh, the other day, you know, like the other day I had to, in one of the AWS accounts, I had to change the account email.
- 32:59Michael Kennedy: I think I spent four hours.
- 33:01Michael Kennedy: I know.
- 33:01Michael Kennedy: Because I had to create the delegate account that has the right permissions to roll.
- 33:05Michael Kennedy: And they're like, oh, no, this is, you know, like,
- 33:08Michael Kennedy: sometimes it's just overwhelming the amount of complexity
- 33:11Michael Kennedy: that needs to be dealt with.
- 33:13Michael Kennedy: And, yeah, I mean, it's great to really have, like,
- 33:16Michael Kennedy: you know, like the infra people that I have working with me
- 33:20Michael Kennedy: at the company that I can deal with all that mess
- 33:22Michael Kennedy: and, like, can make sure that everything is just running perfectly
- 33:26Michael Kennedy: and it just works.
- 33:27Michael Kennedy: So it's like, you know, like, sort of SRE as a service,
- 33:30Michael Kennedy: DevOps as a service for everyone.
- 33:32Michael Kennedy: It's like a cloud product that provides DevOps as a service,
- 33:36Cody Fincher: I spent a number of years doing nothing but cloud migrations to these hyperscalers for enterprises.
- 33:42Cody Fincher: And I can tell you that when you mentioned the eye-watering comment about the network and all that stuff,
- 33:48Cody Fincher: it's so incredibly complicated now, right?
- 33:49Cody Fincher: There's literally every kind of concept that you need to know to deploy these enterprises now,
- 33:55Cody Fincher: move them from on-prem to the cloud.
- 33:56Cody Fincher: So it does get incredibly complicated.
- 33:58Cody Fincher: Having something simple like what Sebastian is talking about, I think, is super helpful
- 34:02Cody Fincher: when you're just trying to get started
- 34:04Cody Fincher: and get something up and running quickly.
- 34:06Michael Kennedy: I've got a lot of questions
- 34:07Michael Kennedy: and I realize that we will not be getting through all of them.
- 34:10Michael Kennedy: So I want to pick carefully.
- 34:12Michael Kennedy: So let's do this one next.
- 34:15Michael Kennedy: Performance, what's your best low effort tip?
- 34:18Michael Kennedy: Not like something super complicated,
- 34:21Michael Kennedy: but I know there's a bunch of low hanging fruit
- 34:23Michael Kennedy: that people maybe missed out on.
- 34:26Michael Kennedy: And this time let's start with Litestar.
- 34:28Michael Kennedy: Cody, back at you.
- 34:29Cody Fincher: I'm going to stick to what I know,
- 34:30Cody Fincher: which is databases because I deal with that.
- 34:32Cody Fincher: every single day. There's a couple of things that I see as like gotchas that I constantly see over
- 34:38Cody Fincher: and over. One, SQLAlchemy kind of obfuscates the way it's going to execute things and what kind of
- 34:45Cody Fincher: queries it's going to actually execute. So it's really easy if you're not kind of fluent in how
- 34:49Cody Fincher: it works to create N plus one types of issues. And so when people start talking about sync or async,
- 34:55Cody Fincher: it's really, in my mind, it's less of that because you're going to spend more time waiting on the
- 34:59Cody Fincher: network and database and those kind of things, then you're going to spend serializing just
- 35:04Cody Fincher: generally, right? And or processing things on the web framework. And so, one, making sure that you,
- 35:10Cody Fincher: your relationships dialed in correctly so that you don't have N plus one queries. The other thing is
- 35:15Cody Fincher: oversized connection pooling into Postgres and just databases in general, because what people don't
- 35:21Cody Fincher: tend to know is that each of those connections takes up CPU cycles and RAM of the database.
- 35:26Cody Fincher: And so when you slam the database with hundreds of connections, you're just taking away processing power that can be done for other things, right?
- 35:33Cody Fincher: And so you end up ultimately slowing things down.
- 35:35Cody Fincher: So I've seen databases that have had so many connections that all of the CPU and all the stuff is actually doing things, just managing connections and can't actually do any database work.
- 35:44Michael Kennedy: And so what about this socket?
- 35:45Michael Kennedy: Is it busy?
- 35:46Michael Kennedy: What about this socket?
- 35:46Michael Kennedy: Is it busy?
- 35:47Michael Kennedy: It's just round robin that, right?
- 35:48Cody Fincher: Paying attention to the database is kind of my first kind of rule of thumb.
- 35:52Michael Kennedy: 100%.
- 35:52Michael Kennedy: I like that one a lot.
- 35:53David Lord: I'll throw in putting stuff or identifying work that doesn't need to be done immediately for the user and putting in a background task.
- 36:02David Lord: Having a background worker defer things till later.
- 36:05David Lord: So sending email is an example, although there's nuances there about knowing that it's sent and everything.
- 36:10David Lord: But yeah, if you user kicks off some process and then you wait to do that process in the worker, you're holding that worker up, which is more relevant in WSGI than ASGI.
- 36:20David Lord: but and you're making them wait for their page to load again versus record what they wanted to do
- 36:26David Lord: send it off to the background let them see the status of it but let the background worker handle
- 36:30Michael Kennedy: it all right yeah like i said as you guys go for it i'm not sure if that's some sort of
- 36:35Janek Nouvertné: it's not really a trick or a tip or more more like a i think the most common mistake i see when i
- 36:41Janek Nouvertné: is ASGI specific but when i look at ASGI apps that people have written who are maybe not as
- 36:46Janek Nouvertné: familiar with ASGI or async Python at all, if you make something an async function, you should be
- 36:53Janek Nouvertné: absolutely sure that it's non-blocking. Because if you're running an ASGI app and you're blocking
- 36:59Janek Nouvertné: anywhere, your whole application server is blocked completely. It doesn't handle any other requests
- 37:04Janek Nouvertné: at the same time. It's blocked. I don't think I've had any mistake more times when I've looked through
- 37:11Janek Nouvertné: some apps that someone has written or that i've came across somewhere so this is really it's super
- 37:18Janek Nouvertné: super common and it has such a such a big impact on the overall performance in every every metric
- 37:26Janek Nouvertné: imaginable so i would say unless and that's nowadays what i tell people unless you're 100
- 37:33Janek Nouvertné: sure that you know what you're doing and you know it's it's non-blocking don't make it async put it
- 37:39Janek Nouvertné: in a thread pool, execute it in a thread, whatever.
- 37:42Janek Nouvertné: All of the ASGI frameworks and Django
- 37:45Janek Nouvertné: give you a lot of tools at hand to translate your stuff
- 37:49Janek Nouvertné: to from sync to async so you can still run it.
- 37:52Janek Nouvertné: Do that unless you're very sure that it actually fully supports
- 37:57Janek Nouvertné: async.
- 37:57Michael Kennedy: MARK MANDEL: Yeah, that's good advice.
- 37:58Michael Kennedy: Sebastian.
- 37:59Michael Kennedy: SEBASTIAN BASTIAN: Hey, I'm actually going to second, Yannick.
- 38:02Michael Kennedy: I think, yeah, like it's--
- 38:04Michael Kennedy: and it's maybe counterintuitive that one
- 38:08Michael Kennedy: of the tips of performance is to try to not optimize that much performance at the beginning.
- 38:13Michael Kennedy: You know, like, I think the idea with async is like, oh, you can get so much performance
- 38:17Michael Kennedy: and throughput in terms of accuracy, whatever.
- 38:20Michael Kennedy: But the thing is, in most of the cases, you know, like, till apps grow so large, they
- 38:26Michael Kennedy: actually don't need that much extra throughput, that much extra performance.
- 38:30Michael Kennedy: And in a framework like, you know, like, as Yannick was saying, well, in my case, I know
- 38:35Michael Kennedy: FastAPI, but like, you know, like also many others.
- 38:38Michael Kennedy: If you define the function with async, it's going to be run async.
- 38:41Michael Kennedy: If you define it non-async and regular def,
- 38:44Michael Kennedy: it's going to be run on a thread worker automatically.
- 38:46Michael Kennedy: So it's just going to do the smart thing automatically.
- 38:50Michael Kennedy: So it's like fair, you know, like it's going to be good enough.
- 38:54Michael Kennedy: And then you can just start with that and just keep blocking code everywhere.
- 38:58Michael Kennedy: You know, like just not use async until you actually know
- 39:01Michael Kennedy: that you really need to use async.
- 39:03Michael Kennedy: And once you do, you have to be, as Yannick was saying,
- 39:05Michael Kennedy: you know, like 100% sure that you are not running blocking code inside of it.
- 39:11Michael Kennedy: And if you need to run blocking code inside of Async code,
- 39:14Michael Kennedy: then make sure that you are sending it to a thread worker.
- 39:17Michael Kennedy: Sending it to a thread worker sounds the own thing,
- 39:20Michael Kennedy: but yeah, like, you know, like Django has tools,
- 39:23Michael Kennedy: any IO has tools.
- 39:23Michael Kennedy: I also built something on top of any IO called asyncer,
- 39:27Michael Kennedy: that is just to simplify these things,
- 39:29Michael Kennedy: to asyncify a blocking function,
- 39:31Michael Kennedy: keeping all the type information
- 39:33Michael Kennedy: so that you get autocompletion and inline errors and everything.
- 39:35Michael Kennedy: even though it's actually doing all the stuff
- 39:37Michael Kennedy: of sending the thing to the thread work.
- 39:40Michael Kennedy: So the code is super simple.
- 39:42Michael Kennedy: You keep very simple code,
- 39:43Michael Kennedy: but then underneath it's just like doing
- 39:45Michael Kennedy: all the stuff that should be done.
- 39:46Michael Kennedy: But you know, like that's normally
- 39:48Michael Kennedy: when you actually need to hyper-optimize things.
- 39:51Michael Kennedy: In most of the cases,
- 39:51Michael Kennedy: you can just start with just not using async at first.
- 39:55Michael Kennedy: Also, now that you're going to have Python multi-threaded,
- 39:58Michael Kennedy: then suddenly you're going to have
- 40:00Michael Kennedy: just so much more performance out of the blue
- 40:02Michael Kennedy: without even having to do much more.
- 40:05Michael Kennedy: So, yeah, actually that's, you know, like, sorry, I kept speaking so much, but here's a tip for improving performance.
- 40:12Michael Kennedy: Upgrade your Python version.
- 40:14Michael Kennedy: I was just chatting today with Savannah.
- 40:17Michael Kennedy: She was adding the benchmarks to the, you know, like Python benchmark, the official Python benchmarks that they run for the CPython, the faster CPython program.
- 40:29Michael Kennedy: And the change from Python 3.10 to Python 3.14
- 40:36Michael Kennedy: when running FastAPI is like almost double the performance
- 40:40Michael Kennedy: or something like that.
- 40:40Michael Kennedy: It was like, it was crazy.
- 40:42Michael Kennedy: It was just crazy improvement in performance.
- 40:44Michael Kennedy: So you can just upgrade your Python version.
- 40:46Michael Kennedy: You're gonna get so much better performance just out of that.
- 40:50Michael Kennedy: - Yeah, that's an awesome piece of advice
- 40:52Michael Kennedy: that I think is often overlooked.
- 40:53Michael Kennedy: And it's not only CPU speed,
- 40:55Michael Kennedy: it's also memory gets a lot lower.
- 40:57Michael Kennedy: Whoever's gonna jump in, go ahead.
- 40:58David Lord: Last year, I was looking at MarkupSafe, which is an HTML escaping library that we use and
- 41:04David Lord: has a C extension for speedups.
- 41:05David Lord: And I almost convinced myself that I can stop maintaining the C extension because just Python
- 41:11David Lord: itself got way faster.
- 41:13David Lord: But then it turned out that I could do something to the C extension to make it faster also.
- 41:17David Lord: So I'm still maintaining.
- 41:18David Lord: But just the fact that I almost convinced myself like, oh, I can drop a C extension for just
- 41:23David Lord: a Python upgrade instead was pretty impressive.
- 41:26David Lord: They've done a lot, especially with like string handling
- 41:29David Lord: and, you know, which you're going to use
- 41:30David Lord: for templating for web apps.
- 41:32Phil Jones: Phil.
- 41:32Phil Jones: Yeah, well, I definitely echo looking at your DB queries
- 41:36Phil Jones: because by far and large, that's always where
- 41:38Phil Jones: our performance issues have been.
- 41:39Phil Jones: It's either badly written query or we're returning
- 41:42Phil Jones: most of the database when the user just wants to know
- 41:44Phil Jones: about one thing or something silly like that.
- 41:46Phil Jones: I was thinking about low-hanging ones,
- 41:47Phil Jones: which I think you asked about.
- 41:48Phil Jones: So I'd say uvloop, which is still a noticeable improvement.
- 41:53Phil Jones: And also, because I think it's likely a lot of us are returning JSON, often changing the
- 41:59Phil Jones: JSON serializer to one of the faster ones can be noticeable as well and obviously quite easy to do.
- 42:04Michael Kennedy: So yeah, that's my key.
- 42:05Michael Kennedy: That's really good advice.
- 42:06Michael Kennedy: I didn't think about the JSON serializer.
- 42:08Michael Kennedy: What one do you recommend?
- 42:09Michael Kennedy: I think, is it ujson?
- 42:11Michael Kennedy: Or is it orjson?
- 42:12Phil Jones: I can't remember which one was deprecated.
- 42:15Phil Jones: But yeah, if you look at the TechEmpower benchmarks, everyone's changing the JSON serializer
- 42:21Phil Jones: to get that bit extra speed.
- 42:22Michael Kennedy: But yeah, you're like, our framework looks bad because our JSON serializer is like third
- 42:27Michael Kennedy: of the performance.
- 42:28Phil Jones: We changed, well, David added a JSON provider to Flask.
- 42:31Phil Jones: And yeah, you could see it make a difference in the tech and power benchmarks.
- 42:35Phil Jones: So that was really good.
- 42:36Phil Jones: Yeah, cool.
- 42:36David Lord: Yeah, it's pluggable now.
- 42:37David Lord: But if you're not installing Flask or orjson, I mean, I don't know what other JSON library
- 42:43David Lord: you'd be using at this point, unless you're already using one.
- 42:45David Lord: But orjson is very, very fast.
- 42:47Michael Kennedy: Okay, this is something I'm going to be looking at you later.
- 42:49Michael Kennedy: So over to Django, Jeff, David talked about running stuff in the background and was it Django 5 or Django 6 that got the background task thing?
- 42:57Jeff Triplett: Yeah, Django 6 just came out a couple of weeks ago.
- 43:00Jeff Triplett: And I'll hand that off to Carlton in a second because I think Carlton's had more to do with the actual plumbing being on the steering council.
- 43:07Jeff Triplett: My advice to people is the best way to scale something is just to not do it, avoid the process completely.
- 43:12Jeff Triplett: So like I mentioned to CDN earlier, it's content heavy sites, cache the crap out of stuff.
- 43:16Jeff Triplett: It doesn't even have to hit your servers.
- 43:17Jeff Triplett: You can go a lot, as we mentioned earlier, too, just by doubling the amount of resources a project has.
- 43:22Jeff Triplett: Django is pretty efficient these days, especially with async views.
- 43:25Jeff Triplett: Like everybody else has said, too, any blocking code, move off to threads, move off to a background queue.
- 43:31Jeff Triplett: Django Q2 is my favorite one to use because you can use a database.
- 43:35Jeff Triplett: So for those little side projects where you just want to run one or two processes, you can use it.
- 43:39Jeff Triplett: It works great.
- 43:40Jeff Triplett: And Carlton, if you want to talk about Django internals.
- 43:43Carlton Gibson: Yeah, OK.
- 43:43Carlton Gibson: So the new task framework I just mentioned, the main thing, the main sort of bit about it is that it's, again, this pluggable Django API.
- 43:51Carlton Gibson: So it gives a standard task API.
- 43:53Carlton Gibson: So if you're writing a third-party library and you, I know, you need to send an email.
- 43:57Carlton Gibson: It's the canonical example, right?
- 43:58Carlton Gibson: You need to send an email in your third-party library.
- 44:01Carlton Gibson: Before, you'd have had to tie yourself to a specific queue implementation, whereas now Django is providing a kind of like an ORM of tasks.
- 44:07Carlton Gibson: Right, right.
- 44:08Michael Kennedy: You got to do Redis, you got to do Celery, and you got to manage things and all that.
- 44:11Carlton Gibson: You don't have to pick that now as the third-party package author.
- 44:14Carlton Gibson: You can just say, right, just use Django,
- 44:17Carlton Gibson: wrap this as a Django task and queue it.
- 44:18Carlton Gibson: And then the developer, when they come to choose their backend,
- 44:22Carlton Gibson: if they want to use Celery or they want to use Django Q2
- 44:25Carlton Gibson: or they want to use the Django task backend,
- 44:26Carlton Gibson: which Jake Howard, who wrote this for Django provided as well,
- 44:30Carlton Gibson: you can just plug that in.
- 44:32Carlton Gibson: So it's a pluggable interface for tasks,
- 44:34Carlton Gibson: which is, I think, the really nice thing about it.
- 44:37Carlton Gibson: In terms of quick wins, everybody's mentioned almost all of mine.
- 44:40Carlton Gibson: I'm going to, Cody and Phil, they mentioned the database.
- 44:43Carlton Gibson: That's the big one.
- 44:44Carlton Gibson: Django, the ORM, because it does lazy related lookups,
- 44:48Carlton Gibson: it's very easy to trigger in M plus one where, you know,
- 44:51Carlton Gibson: the book has multiple authors and suddenly you're iterating through the books
- 44:55Carlton Gibson: and you're iterating through the authors and it's a lookup.
- 44:57Carlton Gibson: So you need to do things like prefetch related, select related.
- 45:00Carlton Gibson: You need to just check that you've got those.
- 45:02Carlton Gibson: Django debug toolbars are a great thing to run in development
- 45:05Carlton Gibson: where you can see the queries and it'll tell you where you've got the duplicates.
- 45:08Carlton Gibson: And then the slightly bigger one is to just check your indexes.
- 45:11Carlton Gibson: The ORM will create the right indexes if you're leaning,
- 45:14Carlton Gibson: if you're going through primary keys or unique fields.
- 45:16Carlton Gibson: But sometimes you're doing a filter on some field,
- 45:19Carlton Gibson: and then there's not the right index there,
- 45:21Carlton Gibson: and that can really slow you down.
- 45:22Carlton Gibson: So again, you can do the SQL explain on that and find that.
- 45:26Carlton Gibson: And then the thing I was going to say originally was caching,
- 45:30Carlton Gibson: is get a Redis instance, stick it next to your Django app,
- 45:34Carlton Gibson: and as Jeff said, don't do the work.
- 45:36Carlton Gibson: If you're continually rendering the same page and it never changes,
- 45:40Carlton Gibson: cache it and pull it from the cache rather than rendering.
- 45:43Carlton Gibson: Because template DB queries are one of your biggest things.
- 45:45Carlton Gibson: The second one's always going to be serialization.
- 45:47Carlton Gibson: It's either serialization or template rendering.
- 45:49Michael Kennedy: So if you can avoid that by caching, you can save an awful lot of time on your account.
- 45:53Michael Kennedy: Yeah.
- 45:54Michael Kennedy: I was wondering if somebody would come back with database indexes,
- 45:56Michael Kennedy: because that's like a 100x multiplier for free almost.
- 46:01Michael Kennedy: It's such a big deal.
- 46:03Carlton Gibson: It really can be.
- 46:03Carlton Gibson: If you're making a particular query and it's doing a full table scan
- 46:06Carlton Gibson: all of a sudden you put the index in, it's instant. It's like, oh, wow. You don't have to be a DBA or
- 46:12Michael Kennedy: master information architect sort of thing. I don't know about Postgres. I'm sure it has it.
- 46:16Michael Kennedy: Somebody can tell me. But with Mongo, you can turn on in the database, I want you to log all
- 46:21Michael Kennedy: slow queries and slow for me means 20 millisecond or whatever. Like you put a number in and then
- 46:27Michael Kennedy: you run your app for a while and you go, look at what's slow by slowest. And then you can see,
- 46:31Michael Kennedy: well, maybe that needs an index, right? Like just let your app tell you what you got to do.
- 46:35Carlton Gibson: Yeah, there is a post.
- 46:37Carlton Gibson: I'm just trying to see if I can quickly look it up now.
- 46:38Carlton Gibson: There's a Postgres extension,
- 46:40Carlton Gibson: which will automatically run explain
- 46:42Carlton Gibson: on the slow queries and log them for you.
- 46:44Carlton Gibson: So it'll...
- 46:45Carlton Gibson: There you go.
- 46:46Cody Fincher: See if I can find...
- 46:47Cody Fincher: It's pg_stat_statements, I think,
- 46:48Cody Fincher: is what you're thinking about.
- 46:49Cody Fincher: Right, okay.
- 46:49Michael Kennedy: If you're unsure about your database indexes,
- 46:52Michael Kennedy: do this, or at least go back and review your queries.
- 46:55Michael Kennedy: Yeah, I agree.
- 46:56Michael Kennedy: Very good.
- 46:57Michael Kennedy: All right, I can see we're blazing through these questions.
- 47:00David Lord: I had one more.
- 47:01David Lord: If I can mention one.
- 47:01David Lord: No, please go ahead.
- 47:02Michael Kennedy: Yeah, go ahead, David.
- 47:03David Lord: If you want to like get some more responsive parts of your website, like make your website a little more responsive or interactive with the user, HTMX or Datastar, especially like if you're using Quart or another ASGI where you can do SSE, server sent events or WebSockets, streaming little bits of changes to the web front end and then rendering them with the same HTML you're already writing can make things a lot more responsive.
- 47:28David Lord: We had talk about that from Chris May at FlaskCon last year, which you can find on YouTube.
- 47:33Michael Kennedy: This is not one of the questions, but let me just start out for a quick riff on this, folks.
- 47:38Michael Kennedy: Out in the audience, someone was asking, what about HTMX?
- 47:41Michael Kennedy: And I think more broadly, I am actually a huge fan of server-side-based, template-based apps.
- 47:48Michael Kennedy: I think it just keeps things simpler in a lot of ways, unless you need a lot of interactivity.
- 47:51Michael Kennedy: But things like HTMX or a little bit of JavaScript can reduce a lot of the traffic and stuff.
- 47:57Michael Kennedy: Where do people land on those kinds of things?
- 47:59Janek Nouvertné: I absolutely love HTMX, not just because you don't have to write a lot of JavaScript or whatever,
- 48:06Janek Nouvertné: but mostly because if I'm just building a simple app that needs a bit more than just be a static HTML page,
- 48:14Janek Nouvertné: it needs some interactivity, a little bit of reactivity.
- 48:18Janek Nouvertné: I feel like having the whole overhead of building an SPA or whatever tools you need for the whole JavaScript, TypeScript, whatever stack, it's just so much work to get a little bit to make a simple thing a little bit nicer, a little bit more reactive.
- 48:34Janek Nouvertné: And I feel like HTMX just fits right in there.
- 48:37Janek Nouvertné: It's super great.
- 48:39Janek Nouvertné: I've built a couple of things with it now,
- 48:41Janek Nouvertné: a few of my own projects, a few things that work.
- 48:45Janek Nouvertné: And it makes things so much easier
- 48:47Janek Nouvertné: where the work probably wouldn't have been done
- 48:50Janek Nouvertné: if it was just because it's too much.
- 48:52Janek Nouvertné: If you're doing a whole front end thing
- 48:55Janek Nouvertné: that you have then to deploy and build and whatever,
- 48:57Janek Nouvertné: or it would have been less nice.
- 48:59Janek Nouvertné: So it's an amazing, really amazing thing.
- 49:02Cody Fincher: As the maintainer and author, though, one of the things that is not frustrating, but it's understandable is that HTMX is not for everybody, right?
- 49:10Cody Fincher: There's not like you can't use HTMX in all occasions or Datastar, right?
- 49:15Cody Fincher: And so there are people that are always going to want to use React and there's going to be people that want to use all these other frameworks.
- 49:20Cody Fincher: And so having some cohesive way to make them all talk together, I think, is important.
- 49:24Cody Fincher: I don't have that answer yet, but I just know that like I can't always say HTMX is it, right?
- 49:29Cody Fincher: And then you'll have a great time because I'll inevitably meet somebody that says I need to do this.
- 49:33Cody Fincher: And it's right. And it's in a single page application or something is more appropriate for that.
- 49:37Cody Fincher: And so it's obviously the right tool for the right job when you need it.
- 49:41Cody Fincher: But, you know, I want to make something that is cohesive depending on whatever library you want to use.
- 49:45Jeff Triplett: I would throw one thing in there, though.
- 49:47Jeff Triplett: I would rather somebody start with HTMX than I would start with React if you don't need it.
- 49:51Jeff Triplett: Because React can be total overkill. It can be great for some applications.
- 49:54Jeff Triplett: But oftentimes the consultant, we see people like having an about page and they throw a React at it.
- 49:59Jeff Triplett: Like, why do you need that?
- 50:00Jeff Triplett: Like, especially for small things with partials.
- 50:02Jeff Triplett: Do you mean you don't want to start with Angular?
- 50:03Jeff Triplett: You know, it's fine if you need it,
- 50:06Jeff Triplett: but I don't think you really need it.
- 50:07Jeff Triplett: Like, introduce tools as you need them.
- 50:10Jeff Triplett: Django 6.0 just added template partials,
- 50:12Jeff Triplett: and I guess my job here is to hand off to Carlton
- 50:14Jeff Triplett: because this is his feature.
- 50:15Michael Kennedy: Yeah, I was happy to see that come in there, Carlton.
- 50:17Michael Kennedy: Nice job.
- 50:17Carlton Gibson: No, it's okay.
- 50:19Carlton Gibson: Plug the new feature.
- 50:20Carlton Gibson: So, I mean, I stepped down as a fellow in 2023
- 50:24Carlton Gibson: into a new business,
- 50:25Carlton Gibson: and I read the essay about template fragments
- 50:28Carlton Gibson: on the htmx website where it's this like named reusable bits in the in the templates and i was
- 50:34Carlton Gibson: like i need that so i built django template partials released as a third-party package and it's now just
- 50:38Carlton Gibson: been merged into core for django 6.0 and i have to say about htms it's really changed the way i write
- 50:44Carlton Gibson: websites before i was the fellow i used to write mobile applications and do the back do the front
- 50:49Carlton Gibson: end of the mobile application then the back end in django using django rest framework and i was
- 50:52Carlton Gibson: that's how i got into you know open source was by django rest framework and since starting the
- 50:58Carlton Gibson: we're three years in we've hardly got a json endpoint in sight it's like two three four of
- 51:02Carlton Gibson: them in the whole application and it's oh it's just a delight again you know you asked me at the
- 51:08Carlton Gibson: beginning michael am i having fun yeah i really am having fun and htmx is the reason i do grant
- 51:12Michael Kennedy: there are you know these use cases awesome all right let's talk about our last topic and we have
- 51:18Michael Kennedy: five minutes ish to do that so we gotta we gotta stay on target quick but let's just go around
- 51:24Michael Kennedy: run real quick here we talked about upgrading the python version getting better performance out of
- 51:29Michael Kennedy: it i mentioned the lower memory side but i think one of the underappreciated aspects of this you
- 51:36Michael Kennedy: know the instagram team did a huge talk you know on it a while ago is the memory that you run into
- 51:43Michael Kennedy: when you start to scale out your stuff on the server because you're like oh i want to have four
- 51:47Michael Kennedy: workers so i can have more concurrency because of the gills so now you've got four copies of
- 51:51Michael Kennedy: everything that you cache in memory and just like the runtime and now you need eight gigs instead of
- 51:56Michael Kennedy: what would have been one or who knows right but with free threaded python coming on which i've
- 52:02Michael Kennedy: seen a couple of comments in the chat like hey tell us about this like it's we could have true
- 52:08Michael Kennedy: concurrency and we wouldn't need to scale as much on the process side i think giving us both better
- 52:13Michael Kennedy: performance and the ability to say well you actually have four times less memory so you could
- 52:17Michael Kennedy: run smaller servers or whatever what's the free threaded story for all the frameworks carlton
- 52:22Carlton Gibson: let's go back to you for do it in reverse i'm really excited about it i don't know how it's
- 52:26Carlton Gibson: going to play out but i'm really excited about it all it can do is help django the async story in
- 52:31Carlton Gibson: django is nice and mature now uh but still most of it's sync like you know you're still going to
- 52:36Carlton Gibson: default the sync you're still going to write your sync views you still got template rendering you
- 52:39Carlton Gibson: know django's template template based kind of framework really you're still going to want to
- 52:43Carlton Gibson: run things synchronously, concurrently, and proper threads are going to be, yeah, they can't but help.
- 52:50Carlton Gibson: I don't know how it's going to roll out. I'll let someone else go because I'm getting locked up.
- 52:53Michael Kennedy: Yeah, I just like elaborated that for people out there before we move on is you could set up your
- 52:59Michael Kennedy: worker process to say, I want you to actually run eight threads in this one worker process.
- 53:05Michael Kennedy: And when multiple requests come in, they could both be sent off to the same worker to be processed.
- 53:10Michael Kennedy: And that allows that worker to do more unless the GIL comes along and says, stop, you only
- 53:15Michael Kennedy: get to do one thing in threads in Python.
- 53:17Michael Kennedy: And all of a sudden, a lot of that falls down.
- 53:19Michael Kennedy: This basically uncorks that and makes that easy all of a sudden.
- 53:22Michael Kennedy: Even if you yourself are not writing async, your server can be more async.
- 53:26Carlton Gibson: Yeah.
- 53:26Carlton Gibson: And this is the thing that we found with ASCII is that you dispatch to a, you know, using
- 53:31Carlton Gibson: to async or you dispatch it to a thread, a thread pool executor, but Python doesn't run
- 53:36Carlton Gibson: that concurrently.
- 53:37Carlton Gibson: And so it's like, or in parallel.
- 53:39Carlton Gibson: So it's like, ah, it doesn't actually go as fast as you want it to.
- 53:42Carlton Gibson: And so you end up wanting multiple processes still.
- 53:45Carlton Gibson: All right, let's keep it with Django.
- 53:46Carlton Gibson: Jeff, what do you think?
- 53:47Jeff Triplett: I'm going to defer to the others on this.
- 53:48Jeff Triplett: I have the least thoughts.
- 53:49Michael Kennedy: All right, write down the stack, Sebastian.
- 53:51Michael Kennedy: Write down the video, not website, web framework.
- 53:55Michael Kennedy: I think it's going to be awesome.
- 53:56Michael Kennedy: This is going to help so much, so many things.
- 53:59Michael Kennedy: The challenge is going to be third-party libraries used by each individual application
- 54:05Michael Kennedy: and if they are compatible or not.
- 54:07Michael Kennedy: That's where the challenge is going to be.
- 54:08Michael Kennedy: But other than that, it's just going to be free extra performance for everyone.
- 54:13Michael Kennedy: Just, you know, like just upgrading the version of Python.
- 54:15Michael Kennedy: So that's going to be us.
- 54:16Michael Kennedy: Cody.
- 54:16Cody Fincher: Yeah, I'm going to echo what Sebastian just said.
- 54:18Cody Fincher: The third party libraries, I think, are going to be the big kind of sticky point here.
- 54:21Cody Fincher: I'm looking forward to seeing what we can do.
- 54:23Cody Fincher: I'm going to kind of hold my thoughts on that.
- 54:24Cody Fincher: Yannick kind of speak a little bit on it because I know that he's looked at msgspec specifically
- 54:28Cody Fincher: and some of the other things that might, you know, give some better context here.
- 54:31Cody Fincher: But yes, the third party libraries are going to be the kind of the sticky issue.
- 54:36Cody Fincher: but I'm looking forward to seeing what we can make happen.
- 54:38Janek Nouvertné: I'm super excited, actually, specifically about async stuff,
- 54:43Janek Nouvertné: because for most of the time, it's like,
- 54:46Janek Nouvertné: if you can already saturate your CPU,
- 54:50Janek Nouvertné: async doesn't help you much.
- 54:51Janek Nouvertné: Well, now, if you have proper threads,
- 54:53Janek Nouvertné: you can actually do that in async as well.
- 54:56Janek Nouvertné: And I think it's going to speed up a lot of applications
- 55:00Janek Nouvertné: just by default,
- 55:01Janek Nouvertné: because almost all async applications out there
- 55:06Janek Nouvertné: use threads in some capacity because, well, most of things aren't async by nature.
- 55:12Janek Nouvertné: So they will use a thread pool and it will run more concurrently.
- 55:16Janek Nouvertné: And so that's going to be better.
- 55:18Janek Nouvertné: But I'm also a bit scared about a few things that mainly, as a few others have said now,
- 55:26Janek Nouvertné: third-party libraries extension is specifically those that are Python C extensions.
- 55:33Janek Nouvertné: just recently, I think like three weeks ago,
- 55:36Janek Nouvertné: so got a msgspec released for Python 3.14
- 55:40Janek Nouvertné: and proper free threading support.
- 55:42Janek Nouvertné: And that took a lot of work.
- 55:44Janek Nouvertné: Fortunately, a few of the Python core devs
- 55:47Janek Nouvertné: chimed in and contributed to PRs
- 55:49Janek Nouvertné: and helped out with that.
- 55:52Janek Nouvertné: And all around the ecosystem,
- 55:54Janek Nouvertné: the last few years,
- 55:55Janek Nouvertné: there's been a lot of work going on.
- 55:57Janek Nouvertné: But especially for more niche libraries
- 56:01Janek Nouvertné: that are still here and there,
- 56:02Janek Nouvertné: I think there's still a lot to do and possibly also quite a few bugs lurking here and there
- 56:09Janek Nouvertné: that haven't been found or are really hard to track down.
- 56:13Janek Nouvertné: I'm curious and a bit maybe scarce, too hard of work, but I'm cautious.
- 56:18Michael Kennedy: It's going to be a little bit of a bumpy ride as people turn that on
- 56:22Michael Kennedy: and then the reality of what's happening.
- 56:24Michael Kennedy: However, I want to take Cody's warning and turn it on its head
- 56:28Michael Kennedy: about these third-party libraries,
- 56:29Michael Kennedy: Because I think it's also an opportunity for regular Python developers who are not async fanatics to actually capture some of that capability.
- 56:39Michael Kennedy: Say if some library says, hey, I realize that if we actually implement this lower level thing, you don't actually see the implementation of in true threading.
- 56:48Michael Kennedy: And then you use it, but you don't actually do threading.
- 56:50Michael Kennedy: You just call even a blocking function.
- 56:52Michael Kennedy: You might get a huge performance boost, a little bit like David was talking about with markup safe.
- 56:57Michael Kennedy: And you could just all of a sudden, with doing nothing
- 57:00Michael Kennedy: with your code, goes five times faster on an eight core
- 57:04Michael Kennedy: machine or something in little places where it used to matter.
- 57:06Janek Nouvertné: I'm super excited for--
- 57:09Janek Nouvertné: we currently focused on the things that are out there
- 57:12Janek Nouvertné: right now and that might need to be updated.
- 57:15Janek Nouvertné: But I'm super excited for what else might come of this,
- 57:19Janek Nouvertné: new things that will be developed or stuff
- 57:23Janek Nouvertné: that we are currently not thinking about
- 57:25Janek Nouvertné: or have that hadn't been considered for the past 30 years or so,
- 57:29Janek Nouvertné: because it just wasn't feasible or wasn't possible or didn't make sense at all.
- 57:33Janek Nouvertné: I think it would pay off definitely.
- 57:36Janek Nouvertné: All right. Team Flask.
- 57:37Phil Jones: You guys got the final word.
- 57:39Phil Jones: I think it would probably be more advantageous to WSGI apps
- 57:42Phil Jones: than it will for ASGI apps.
- 57:44Phil Jones: And when I've been playing with it, it's mostly on the WSGI Flask side
- 57:47Phil Jones: where I'm quite excited about it.
- 57:48Phil Jones: At the same time, like the others are a bit worried because not clear to me,
- 57:52Phil Jones: for example, that green threading is going to work that well
- 57:55Phil Jones: with free threading.
- 57:56Phil Jones: And that may have been fixed,
- 57:57Phil Jones: but I don't think it has yet.
- 57:58Phil Jones: And that might then break a lot of WSGI apps.
- 58:02Phil Jones: So next, I think.
- 58:03Phil Jones: But yeah, very excited for Flask in particular.
- 58:06David Lord: Thanks for bringing up green threading.
- 58:07David Lord: I added that to my notes
- 58:09David Lord: of mention right now.
- 58:11David Lord: So Flask already has emphasized
- 58:14David Lord: for years and years and years
- 58:16David Lord: that don't store stuff globally,
- 58:18David Lord: don't have global state,
- 58:19David Lord: bind stuff to the request response cycle
- 58:21David Lord: if you need to store stuff,
- 58:23David Lord: look stuff up from a cache otherwise.
- 58:24David Lord: And my impression is that that emphasis is pretty successful.
- 58:27David Lord: I don't, there's any well-known extensions using like global state or anything like that.
- 58:31David Lord: It's helped that the dev server that we have is threaded by default.
- 58:36David Lord: Like it's not going for performance, obviously, it's just running on your local machine, but
- 58:39David Lord: it's already like running in a threaded environment, running your application in a
- 58:42David Lord: threaded environment, not a process-based one by default.
- 58:45David Lord: I don't know if anybody even knows that you can run the dev server as process-based.
- 58:49David Lord: And we also already had for a decade or more than a decade,
- 58:53David Lord: Gevent to enable the exact same thing that free threading is enabling for Flask,
- 58:59David Lord: which is concurrent work and connections.
- 59:03David Lord: And so plenty of applications are already deployed that way
- 59:06David Lord: using Gevent to do what kind of ASGI is enabling.
- 59:10David Lord: I've run all the test suites with pytest FreeThreaded,
- 59:14David Lord: which checks that your tests can run concurrently in the free threaded builds.
- 59:18David Lord: so go check that out by Anthony Shaw.
- 59:20David Lord: And I'm pretty sure Granian already supports free-threading.
- 59:23David Lord: Not sure though, I haven't looked into Granian enough.
- 59:25Michael Kennedy: But like-
- 59:26Michael Kennedy: You know, I'm not sure either.
- 59:27Michael Kennedy: It does have a runtime threaded mode
- 59:30Michael Kennedy: but I don't know if that's truly free-threaded or not.
- 59:32David Lord: All of those things combined make me pretty optimistic
- 59:35David Lord: that Flask will be able to take advantage of this
- 59:38David Lord: without much work from us.
- 59:40David Lord: I mean, I know that's a big statement right there
- 59:42David Lord: and I haven't tested it
- 59:43David Lord: but the fact that we've emphasized
- 59:45David Lord: all these different parts for so long already
- 59:47David Lord: makes me confident about it.
- 59:48Michael Kennedy: I'm also super excited about it.
- 59:49Michael Kennedy: And just one final thought I'll throw out there
- 59:51Michael Kennedy: before we call it a show,
- 59:52Michael Kennedy: because we could go on for much longer,
- 59:54Michael Kennedy: but we're out of time.
- 59:55Michael Kennedy: I think once this comes along,
- 59:57Michael Kennedy: whatever framework out of this choice you're using out there,
- 1:00:01Michael Kennedy: there's a bunch of inner working pieces.
- 1:00:04Michael Kennedy: One of them may have some kind of issue.
- 1:00:06Michael Kennedy: And I think it's worth doing some proper load testing
- 1:00:08Michael Kennedy: on your app, you know, point something like locust.io at it
- 1:00:12Michael Kennedy: and just say, well, what if we gave it 10,000 concurrent users
- 1:00:14Michael Kennedy: for an hour?
- 1:00:15Michael Kennedy: Does it stop working?
- 1:00:16Michael Kennedy: Does it crash?
- 1:00:17Michael Kennedy: Or does it just keep going?
- 1:00:18Michael Kennedy: You're like, so that seems like a pretty good thing to do the first time before you deploy
- 1:00:22Michael Kennedy: your first free threaded version.
- 1:00:23Michael Kennedy: Yeah.
- 1:00:24Michael Kennedy: All right, everyone.
- 1:00:25Michael Kennedy: I would love to talk somewhere.
- 1:00:26Michael Kennedy: This is such a good conversation, but I also want to respect your time and all that.
- 1:00:31Michael Kennedy: So thank you for being here.
- 1:00:32Michael Kennedy: It's been an honor to get you all together and have this conversation.
- 1:00:35Michael Kennedy: Thank you very much for having us.
- 1:00:37Janek Nouvertné: Thank you.
- 1:00:37Janek Nouvertné: Yeah.
- 1:00:37Janek Nouvertné: Thanks for having us all.
- 1:00:38Janek Nouvertné: Thanks, everybody.
- 1:00:39Janek Nouvertné: Yeah.
- 1:00:39Janek Nouvertné: It's nice being here.
- 1:00:40Janek Nouvertné: Yeah.
- 1:00:40Janek Nouvertné: Thanks for having us.
- 1:00:41Michael Kennedy: Thanks for having us all.
- 1:00:42Michael Kennedy: Bye.
- 1:00:42Michael Kennedy: Bye-bye.
- 1:00:44Michael Kennedy: This has been another episode of Talk Python To Me.
- 1:00:47Michael Kennedy: Thank you to our sponsors.
- 1:00:48Michael Kennedy: Be sure to check out what they're offering.
- 1:00:49Michael Kennedy: It really helps support the show.
- 1:00:51Michael Kennedy: If you or your team needs to learn Python,
- 1:00:53Michael Kennedy: we have over 270 hours of beginner and advanced courses
- 1:00:57Michael Kennedy: on topics ranging from complete beginners to async code,
- 1:01:00Michael Kennedy: Flask, Django, HTMX, and even LLMs.
- 1:01:03Michael Kennedy: Best of all, there's no subscription in sight.
- 1:01:06Michael Kennedy: Browse the catalog at talkpython.fm.
- 1:01:09Michael Kennedy: And if you're not already subscribed to the show
- 1:01:11Michael Kennedy: on your favorite podcast player, what are you waiting for?
- 1:01:14Michael Kennedy: Just search for Python in your podcast player.
- 1:01:16Michael Kennedy: We should be right at the top.
- 1:01:17Michael Kennedy: If you enjoyed that geeky rap song, you can download the full track.
- 1:01:20Michael Kennedy: The link is actually in your podcast blog or share notes.
- 1:01:23Michael Kennedy: This is your host, Michael Kennedy.
- 1:01:24Michael Kennedy: Thank you so much for listening.
- 1:01:26Michael Kennedy: I really appreciate it.
- 1:01:27Michael Kennedy: I'll see you next time.
- 1:01:38I started to meet.
- 1:01:40And we're ready to roll.
- 1:01:43Upgrade the code.
- 1:01:45No fear of getting whole.
- 1:01:48We tapped into that modern vibe over King Storm.
- 1:01:53Talk Python To Me, async is the norm.
- 1:02:24Редактор субтитров А.Семкин Корректор А.Егорова