Latest / Talk Python To Me / #421: Python at Netflix
Transcript
- 0:00When you think of Netflix as a technology company, you probably imagine them as cloud innovators.
- 0:05They were one of the first companies to go all in on a massive scale for cloud computing,
- 0:10as well as throwing that pesky chaos monkey into those servers.
- 0:13But they have become a hive of amazing Python activity.
- 0:18From their CDN, their demand predictions and failover, security, machine learning,
- 0:23executable notebooks, and lots more, the Python at play is super interesting.
- 0:28And on this episode, we have Zoran Simic and Amjith Ramanujan on the show to give us this rare look inside.
- 0:34This is Talk Python To Me, episode 421, recorded June 8th, 2023.
- 0:40Welcome to Talk Python To Me, a weekly podcast on Python.
- 0:56This is your host, Michael Kennedy.
- 0:58Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython,
- 1:03both on fosstodon.org.
- 1:06Be careful with impersonating accounts on other instances.
- 1:08There are many.
- 1:09Keep up with the show and listen to over seven years of past episodes at talkpython.fm.
- 1:14We've started streaming most of our episodes live on YouTube.
- 1:19Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.
- 1:26This episode is brought to you by JetBrains, who encourage you to get work done with PyCharm.
- 1:32Download your free trial of PyCharm Professional at talkpython.fm/done dash with dash PyCharm.
- 1:39And it's brought to you by InfluxDB.
- 1:42InfluxDB is the database purpose built for handling time series data at a massive scale for real-time analytics.
- 1:49Try them for free at talkpython.fm/InfluxDB.
- 1:52Hey, Zorin.
- 1:54Hey, I'm G.
- 1:55Hello, Michael.
- 1:55Hello, Michael.
- 1:56Welcome to Talk Python To Me, you guys.
- 1:58It's excellent to have you here.
- 1:59Thank you very much.
- 2:00I'm a big fan, so it's very nice to be on the show, actually.
- 2:04Awesome.
- 2:04Yeah.
- 2:05We've got to meet a couple times at PyCon, which is honestly one of my favorite purposes of PyCon,
- 2:10is to meet people and just hang out and have those experiences, you know?
- 2:14Yeah, absolutely.
- 2:15Yeah.
- 2:15Yeah.
- 2:16And nice to have you on the show, Zorin.
- 2:17Yeah.
- 2:18Big fan as well.
- 2:19Thank you very much.
- 2:20That's very kind to both of you.
- 2:21So we're going to talk about a pretty awesome tech company, I think.
- 2:26Netflix.
- 2:27You both work at Netflix, and people who are watching the video, you're coming to us from
- 2:31the Netflix headquarters, which I've got the chance to be there for some Python stuff going
- 2:36on there before as well.
- 2:37Got cool posters and sort of movie studio feel.
- 2:40So that's the backdrop you both have going on, which is excellent.
- 2:44Yeah.
- 2:44Yeah.
- 2:45Yeah.
- 2:45It's pretty nice to work at Netflix.
- 2:48It's a very good company.
- 2:49I'm very happy.
- 2:50A lot of Python we're going to learn.
- 2:52Yes.
- 2:53Yeah.
- 2:53We do use a lot of Python.
- 2:54Yeah.
- 2:55Excellent.
- 2:56So we're going to talk about Python and Netflix, a wide ranging sort of survey of a lot of projects
- 3:01you all have created.
- 3:02How are you using it?
- 3:03Some other ones that you both of you personally created, either tied to or not tied to Netflix.
- 3:09But I think people are going to really enjoy this look inside what you all got going on.
- 3:13Before we get to that, though, let's start with your stories.
- 3:15Quick introduction.
- 3:17How do you get here working on Python?
- 3:19Soren, you want to go first?
- 3:20Yeah.
- 3:21So I was hooked into programming ever since I saw my first computer.
- 3:26Age of 13 in middle school.
- 3:28I was in Amstrad CPC.
- 3:30Right.
- 3:30I was like, yeah, that was the thing I wanted to do.
- 3:33So yeah, I started programming as a hobby at first.
- 3:36And fun fact, way back then, later on in high school, one of my math teachers told me, hey,
- 3:42do something real, don't do programming.
- 3:44It's like a dead end, you know, you won't be able to find a job.
- 3:48Did they tell you things like these drag and drop visual tools are going to replace all the
- 3:55programmers and like the low code of the 80s and 90s, maybe?
- 4:00Yeah.
- 4:00You know, yeah.
- 4:02Back then, I guess it was very, well, didn't seem that obvious.
- 4:06Yeah.
- 4:07Yeah.
- 4:07And then, yeah, I decided to go computer science anyway, because
- 4:12that's what I wanted to do.
- 4:13And then I spent the vast majority of my career in a language that is not very much known or
- 4:19used, I think, iPhone.
- 4:21So I spent more than a decade on doing iPhone mostly.
- 4:25And then I discovered Python once I joined LinkedIn in 2011.
- 4:29And that's when I kind of, well, got hooked and decided to do more and more things Python.
- 4:35And now at Netflix, even more so trying to support NetPython across the board.
- 4:41You're kind of doing MetaPython in the sense that your team does a lot of stuff to facilitate
- 4:47other people doing Python too, right?
- 4:49Exactly.
- 4:50Yes.
- 4:50Yeah.
- 4:51That's our team at Netflix.
- 4:53Like we enable other Python developers to be more productive by building tools or building
- 4:58the infrastructure necessary to ship their code faster or build their products sooner, things
- 5:04like that.
- 5:04Yeah.
- 5:05Cool.
- 5:05How about you, Amjith?
- 5:06Oh, I got introduced to programming in high school.
- 5:10We had like one hour of computer lab every week.
- 5:13I got to learn GW Basic.
- 5:15That was my first language.
- 5:17It was fantastic.
- 5:18I still have fond memories of like trying to draw circles on the screen.
- 5:22And then I went to college.
- 5:23I learned C and C++.
- 5:25I liked those.
- 5:26But then after I got a job, I wanted to learn, you know, how to be a better programmer.
- 5:30And somebody mentioned, you know, oh, functional programming is the bee's knees.
- 5:33You should actually, you know, if you learn how to do functional programming, your general
- 5:36programming will get better.
- 5:37And the best language to learn functional programming is Haskell.
- 5:40And so I took a book called Learn You a Haskell.
- 5:44And then I went through like the first few chapters and it was mind blowing.
- 5:47It was like a really fantastic language.
- 5:49And I got first introduced to a concept of REPL and like trying out like little snippets in
- 5:55the interpreter and getting answers.
- 5:56And it was fantastic.
- 5:57And I got introduced to list comprehension in Haskell and it was just mind blowing.
- 6:02It's like, you know, without having to write a, write like five lines of for loop, you could
- 6:06just, it's a single line thing.
- 6:08And I quickly realized that, you know, you can't find actual jobs writing Haskell or at
- 6:14least, you know, not.
- 6:15So I figured out like, what's a language that has list comprehension that is actually employable,
- 6:22you know, that I could find jobs.
- 6:24And that's how I found Python because I came to Python because of list comprehension.
- 6:28Oh, awesome.
- 6:29Yeah.
- 6:29Okay.
- 6:30Learn You a Haskell for Great Good, a beginner's guide.
- 6:33Is that the book?
- 6:33That is the book.
- 6:34Yeah.
- 6:35And it's actually still available online for free that anybody could read.
- 6:39I'm fairly certain.
- 6:40And I actually bought like a paper copy of the book.
- 6:42It's, it's a good book.
- 6:43It's fun one to go through.
- 6:45Yeah.
- 6:46It looks like it's really got a playful nature to it.
- 6:48Yeah, exactly.
- 6:49Yeah.
- 6:50You know, your thoughts about list comprehension really connects with me as well.
- 6:55I guess my first exposure to something like that was LINQ, L-I-N-Q and C-sharp.
- 7:00Mm-hmm.
- 7:00Which is, it's, honestly, I think it's better than Python list comprehensions.
- 7:04I wish Python had just a little bit more.
- 7:06Nice.
- 7:06A little bit.
- 7:07Just one or two things more.
- 7:09For example, wouldn't it be nice in a list comprehension if you could specify a sort?
- 7:13Mm-hmm.
- 7:14Because I find myself often doing a list comprehension and then sorting the thing in the end afterwards.
- 7:19But if you could just say order by and give it an expression like you would to lambda, pass a lambda over to a, you know.
- 7:25So there's room for more.
- 7:27What is it?
- 7:27What PEP do I need to write to get sort in a list comprehension?
- 7:30I don't know, but I want it.
- 7:31Yeah.
- 7:32Yeah.
- 7:32So I really think that that's a cool language feature.
- 7:35And, you know, it's also one of the areas that they're applying some of these speedups in the faster CPython work that's coming.
- 7:42And they're doing, you know, list comprehensions for isolation purposes.
- 7:46And Python 3 are basically hidden function calls with their own stack frame and variables that you don't actually see, right?
- 7:53Mm-hmm.
- 7:54You don't write it, but that's kind of the execution level.
- 7:56And now they're inlining those to make them a little bit faster.
- 7:58Nice.
- 7:59I don't know.
- 8:00Yeah.
- 8:00I think the faster Python team is doing like a fantastic job.
- 8:04Like there was a talk that I attended at PyCon, not this year, but the previous year, where they introduced like switch case, how they were doing the case statements.
- 8:11It's not the exact switch case, but, you know, coming from C and C++, I knew what switch cases are.
- 8:15And when I saw what is possible with the pattern matching, like structural pattern matching in Python, it's like take switch case and then like turn it up to 11.
- 8:24And that's what this is.
- 8:25And you're right.
- 8:26I mean, there is always more that can be done, but I think it's going in a great direction.
- 8:30I think it's fantastic.
- 8:31Yeah.
- 8:32Let's talk about that.
- 8:33I mean, we're going to dive into the details of Netflix and stuff.
- 8:37But just, you know, this whole Python 3.11, 3.12, these are really big performance improvements coming along.
- 8:45Yeah.
- 8:45Are you able yet to take advantage of those at Netflix?
- 8:48And is that making a big difference?
- 8:49You know, like, are you guys still running, you know, 3.8 or are you more closer to the cutting edge in terms of releases?
- 8:56So I think one of the advantages here at Netflix is that every team has the freedom to choose the tools that they need to use.
- 9:03And it's great and also kind of painful for central teams because now, you know, there is like a bifurcation of all kinds of different versions out there.
- 9:10But where I'm going with this is that every team is allowed to choose what is what they need to use in order to get their job done.
- 9:17And so my previous team, we were at the cutting edge, like we used 3.11 or we still use 3.11 in the projects that we built and the services that we used.
- 9:25And it is a nice boost.
- 9:26Like we could certainly see.
- 9:28So, for instance, there is like a periodic job that runs and it's like a sort of a cron job that runs every five minutes or so.
- 9:35And we had put in like so much optimization so that it will actually finish within the five minutes because we were doing a lot of data crunching and so forth.
- 9:42And just so we don't like stack up the cron tasks.
- 9:45But when we switched from, I think from like we did jump from 3.9 to 3.11 directly, we didn't we did not like go to 3.10.
- 9:52But then when we jumped, it felt like, you know, things that were taking like four minutes were now finishing in like two minutes.
- 9:58And it was it was like it was like a huge improvement that you could see.
- 10:02And like it felt very rewarding to see that.
- 10:04So, yeah, absolutely.
- 10:05So every team gets to choose what they want to use.
- 10:08And our job as a central Python team that Zoran and I are currently part of is to try and enable people to use that use whatever is the latest that is available.
- 10:17So, you know, whatever internal tools that we have, we have to make sure that it actually gets exercised in the latest Python version that got released and make sure that everything is building and deploying as they are supposed to do.
- 10:29And so on.
- 10:29OK, excellent.
- 10:30That's pretty cool.
- 10:31That story is speeding up your cron jobs.
- 10:33That's.
- 10:34Yes.
- 10:34That's a non-trivial.
- 10:35And it's probably wasn't a lot of work to move from 3.9 to 3.11.
- 10:39I know my upgrade path was rebuild some virtual environments on the server.
- 10:43And now we're good to go.
- 10:44Exactly.
- 10:45Yeah.
- 10:45Yeah.
- 10:46Yeah.
- 10:47Yeah.
- 10:47So, Ren, do you want to add about that 3.11, faster CPython side?
- 10:51Oh, yeah.
- 10:52So, yeah, absolutely.
- 10:54It's so faster.
- 10:54So much faster.
- 10:56Yeah.
- 10:56The main issue when upgrading is the lack of wheels if you're like stuck on older libraries.
- 11:02But we do have like a few numbers.
- 11:05Like the most used right now is Python 3.10 across the board, right?
- 11:08It will depend on the team, right?
- 11:10Everybody is upgrading at their own pace.
- 11:13And 3.11 is starting to grow a bit.
- 11:15But yeah, most used right now is 3.10 statically.
- 11:19Honestly, that sounds really quite good for a company the size of Netflix and how much Python you're doing.
- 11:26That's pretty close to pushing the envelope.
- 11:28Yeah.
- 11:29And there are still some teams that are sort of stuck on 3.8 or 3.7, I want to say.
- 11:34Simply because they provide a platform that allows data scientists to write their code.
- 11:40And they have this pre-built image with all of the necessary libraries pre-installed in there.
- 11:47And so they have like a pretty tight control over which libraries will get upgraded on what cadence and so on.
- 11:53And so for them, I think they're still running on 3.7.
- 11:57And I'm sure when they switch to 3.10 or 3.11, it's going to be like a screaming fast improvement.
- 12:03So I'm looking forward to that migration to happen.
- 12:06Yeah, excellent.
- 12:07This number is very static, right?
- 12:09It's a number of like pre-short Pythons across repos.
- 12:13But yeah, dynamically, right?
- 12:15Like you may have lots of instances who still run on 3.7 and they will massively move to a...
- 12:20So that team is moving from 3.7 to 3.10, for example.
- 12:24Right.
- 12:24Yeah.
- 12:25Yeah, so upgrade paths.
- 12:28This portion of Talk Python To Me is brought to you by JetBrains and PyCharm.
- 12:32Are you a data scientist or a web developer looking to take your projects to the next level?
- 12:37Well, I have the perfect tool for you, PyCharm.
- 12:40PyCharm is a powerful integrated development environment that empowers developers and data scientists like us to write clean and efficient code with ease.
- 12:49Whether you're analyzing complex data sets or building dynamic web applications, PyCharm has got you covered.
- 12:55With its intuitive interface and robust features, you can boost your productivity and bring your ideas to life faster than ever before.
- 13:02For data scientists, PyCharm offers seamless integration with popular libraries like NumPy, Pandas, and Matplotlib.
- 13:09You can explore, visualize, and manipulate data effortlessly, unlocking valuable insights with just a few lines of code.
- 13:16And for us web developers, PyCharm provides a rich set of tools to streamline your workflow.
- 13:20From intelligent code completion to advanced debugging capabilities, PyCharm helps you write clean, scalable code that powers stunning web applications.
- 13:29Plus, PyCharm's support for popular frameworks like Django, FastAPI, and React make it a breeze to build and deploy your web projects.
- 13:38It's time to say goodbye to tedious configuration and hello to rapid development.
- 13:43But wait, there's more!
- 13:44With PyCharm, you get even more advanced features like remote development, database integration, and version control, ensuring your projects stay organized and secure.
- 13:53So whether you're diving into data science or shaping the future of the web, PyCharm is your go-to tool.
- 13:58Join me and try PyCharm today.
- 14:00Just visit talkpython.fm/done-with-pycharm, links in your show notes,
- 14:07and experience the power of PyCharm firsthand for three months free.
- 14:11PyCharm.
- 14:12It's how I get work done.
- 14:16Let's start by talking about kind of the broad story of Python at Netflix.
- 14:23Maybe we could start with what you all do day-to-day in terms of what's your role?
- 14:29Because you kind of support other people's Python, as I hinted before.
- 14:33So maybe we could get a sense of what you all do day-to-day.
- 14:35And then we'll...
- 14:36Omg, you wrote a nice blog article that's a big, broad, pure survey of how Python's being used in all these different places.
- 14:43So maybe start with what you all do day-to-day on your team, and then we'll go into that.
- 14:47Yeah, sure thing.
- 14:48I've been with Netflix for about six years now.
- 14:51And previously, I was in a different team, and we were doing failovers, which was a way of running...
- 14:57You know, if Netflix ever goes down in one of the AWS regions, we are the team that gets paged in,
- 15:02and we go and move all the traffic from that region to another...
- 15:05Other two regions that we run in.
- 15:06So that's what I was doing up until, like, February of this year.
- 15:10And let me just take a step back real quick with you.
- 15:13Netflix is kind of all in on AWS, right?
- 15:16Like, there's been a lot of stories about how you all have set loose the chaos monkey into your data centers
- 15:22and how you worked on failover from AWS regions.
- 15:26And so I don't know if you all are the largest users of AWS,
- 15:30but certainly one of the more interesting, complicated deployments out there, right?
- 15:34Yeah, so I think we were the earliest adopters of cloud computing when AWS first came out.
- 15:40And so AWS has used as the poster child for, you know, see, big companies can run in cloud,
- 15:46and you don't have to be on-prem.
- 15:48And so we think of them as partners, not so much as, you know, like this client-owner relationship or anything like that.
- 15:55So we consider AWS as our business partners.
- 15:58And yes, we are full in on AWS.
- 16:00And Chaos Monkey, even now, yes, it functions in AWS.
- 16:05Like, it goes around, and just inside our VPC, it does terminate instances,
- 16:10occasionally, or not occasionally, like once every day, one instance every day on every service.
- 16:15That is so wild.
- 16:17I mean, obviously, you don't want to set it loose on other people's AWS instances, right?
- 16:22Yeah.
- 16:23But no, that's a really interesting way to force people to think about developers and infrastructure folks to think about what happens if the cloud somehow, your server dies.
- 16:34And maybe it's not even the cloud's fault, right?
- 16:35It's just like, okay, there's a Linux machine running, and that thing died.
- 16:38It could have been running anywhere.
- 16:39It happened to be in AWS.
- 16:41But to force them to think about it going, like, we will.
- 16:43It's not an eventuality.
- 16:45This will happen.
- 16:46And so you plan for it.
- 16:47Yeah.
- 16:48It's even more than just the idea of, like, it will happen, so we plan for it thing.
- 16:53It's more like, you know, it's a way of building software where you need to build software that's resilient and has enough fallbacks built in.
- 17:00And so, for instance, if you are not able to reach the database, do you have a cache in front that can sort of, you know, keep the thing going for the few network calls that are failing to reach the database?
- 17:09Those are, like, basic common things, paradigms that have become commonplace nowadays in software development where, you know, building fallbacks automatically is like standard practice these days.
- 17:20But when Chaos Monkey was created, which was about 10 years ago, you know, these were, like, new concepts that people were not using.
- 17:26And it was assumed that, you know, once you have a server and you put your software on the server and you run it, it's basically done, like, until you do the next deploy, which takes another month or so to refresh that server, refresh that code.
- 17:37But that all changed once we went to cloud where, you know, we started doing deployments on a daily basis or maybe even more hourly basis and things like that.
- 17:44And so when you are doing that, you know, when you are shutting down one server with old version and bringing up the new server with a new version, how are you going to make sure that the connections are not going to fall?
- 17:54And how are you going to make sure that the network continuity continues and so forth?
- 17:57So, yeah, Chaos Monkey was just introduced as a way to ensure that people are building software in a way that is resilient.
- 18:04And this is just a way to sort of test that on an ongoing basis.
- 18:09Yeah, it's quite an operational challenge.
- 18:11I mean, I don't recall seeing Netflix saying, our scheduled maintenance is coming up on Sunday.
- 18:15We'll be down for five hours.
- 18:17Not acceptable, is it?
- 18:19It just makes you laugh when you think about it.
- 18:21Especially not on a Sunday.
- 18:23Okay.
- 18:23I've even seen government sites.
- 18:26I can't remember which government it was saying that the website was closed.
- 18:29Like the website had business hours.
- 18:31That's a different deal.
- 18:32Like you came at night, like, oh, you can't come here right now.
- 18:34It's like, what?
- 18:35Yeah.
- 18:35It's the web.
- 18:36I don't understand what's going on.
- 18:37All right.
- 18:38So let's go through this blog post that you wrote here entitled just Python at Netflix on the Netflix technology blog.
- 18:45Yeah.
- 18:45So you wrote this in preparation of PyCon.
- 18:48This is PyCon 2023?
- 18:49No, this was 2019, actually.
- 18:52So this is old by at least two or three days, three years now.
- 18:56Okay.
- 18:56Yeah.
- 18:57You had pointed out before we press record that some of these projects mentioned here that used to be internal things are now also open source.
- 19:03So there's a little more access to these than the blog posts might indicate.
- 19:07Yeah.
- 19:07Some of the things that are mentioned here, yes, they have been open source since then.
- 19:11So specifically the one that I remember right now is Metaflow, which is a infrastructure.
- 19:16It's like a platform orchestration infrastructure framework that is used by our machine learning organization where, you know, scientists would try and build their model or they use existing models from like XGBoost or like tons of other Python libraries.
- 19:33And their interest and their expertise lies in, you know, crafting those models, training those models and building the correct algorithm to do the predictions and so on.
- 19:43They are not so interested in like, you know, making sure that enough compute is available to run these models or they're not interested in making sure that the plumbing works or this model's data is now going to the next step of this algorithm or even like getting it deployed and making it available in the production environment.
- 20:00So that's all that abstraction is taken care of by Metaflow.
- 20:04So Metaflow is the project that was mentioned here and that allows you to make it easy for machine learning folks to get their system running and as well as deploying it out to production.
- 20:14And now that is now open sourced and it is available for folks to use.
- 20:19And I think some other companies have actually adopted to using that as well.
- 20:22So, yeah.
- 20:23Kind of operate like a DevOps-y automation for machine learning.
- 20:28So the people they're writing, creating the models and the data scientists don't have to also be DevOps people.
- 20:34Right.
- 20:34It's slightly more than DevOps as well because it also does the pipelining work to make it possible for someone to, you know, bring the data from this database and load it in.
- 20:45All of that work is already taken care of or at least there are libraries that are built into Metaflow that makes it possible to bring those in.
- 20:50And then it allows you to also do orchestration.
- 20:53So, for instance, machine learning models typically happen in multi-steps and multi-stages.
- 20:57And so the data gets processed by this function and then it gets moved on to this other function and then it gets moved on to this other thing and so forth.
- 21:04And so it does the plumbing to make sure that the data can flow through this topology and actually produce results and so on.
- 21:10Yeah.
- 21:11Yeah.
- 21:11You probably have enough data that that's a lot of data to move.
- 21:14All right.
- 21:16A quick question from the audience before we dive into the topics here is Diego asks, on such a big platform with so many software engineers with different coding practices, do you all get together and follow some set norms by Netflix or is it more team by team basis?
- 21:30It is very much team by team basis.
- 21:32So each team has their style and their areas that they focus on.
- 21:35So, for instance, like machine learning engineers are not going to care too much about like, how do I make this like, you know, production grade, like super heavily fortified or whatever.
- 21:45And security engineers might be focusing on completely different things.
- 21:48So it is different.
- 21:49But at the same time, I do want to mention that there are certain norms that are common across the entire company where, you know, so for instance, Chaos Monkey is one of those things where since since Netflix operates in a way,
- 22:00where, you know, every team is given the freedom to choose and operate the way they see fit, there is no edict that can come from a VP or a president that says, like, you must write code in this way, like that doesn't happen.
- 22:12And so what that means is, how are you going to enforce, like, you know, you have to write resilient software or how are you going to make sure that your software will continue to run if one of the servers out of the hundred servers has gone down?
- 22:24And so there is not a good way to enforce that.
- 22:26And Chaos Monkey was created as a way to enforce that, which is, yes, we're not going to be able to tell you how to write software, but this particular service that exists, it's going to go around killing servers.
- 22:36And so you better make sure that your software is actually resilient to servers going down.
- 22:40So that's a way in which we influence people to write the, to produce the right outcome without telling them how to do it.
- 22:48I see. So sort of, you agree on a common principle of design for failure and design for resiliency, and then it's up to people how to make that happen.
- 22:58Yes. And also we have the concept of paved paths, our paved road, which is we have certain libraries that are made to operate within our infrastructure.
- 23:08So there is an internal discovery tool and there is an internal metrics collection tool and there is an internal, you know, like a failure recovery tool and so forth.
- 23:15And these libraries that are provided in these languages, they make it really that simple to just integrate with these, with these services.
- 23:23And so it makes it the obvious choice for people to start using those libraries rather than, you know, paving their own path, for instance.
- 23:30Right.
- 23:30So we try and make it as easy as possible to do the right thing.
- 23:34And so people generally like fall into that paved road solutions that we have.
- 23:38Excellent.
- 23:39And we try to make it also now, especially as a central Python team to promote good practices, right?
- 23:46Like you should have a pipeline, you should choose a release strategy.
- 23:50You should have tests and we, we help.
- 23:53If you don't, we can help you set that up and choose a good relevance release strategy for you, et cetera.
- 24:00Excellent.
- 24:00Yeah, that's, that's really good.
- 24:01So let's dive into this blog post.
- 24:03Now it was written by Amjit, but Soren, jump in as well as, as we talk about, please.
- 24:08So the first one is related to bandwidth.
- 24:12To some what?
- 24:14Like delivering the content.
- 24:15And there's some interesting articles and stuff.
- 24:18How much of the internet's bandwidth does Netflix use?
- 24:21And I don't know how accurate this is, but maybe give us a sense of like, you got to have a lot of traffic, right?
- 24:26Yes.
- 24:27So I think when I first joined Netflix, I was told that we use about one third of all of internet's bandwidth, but that was back in 2017.
- 24:35So things have changed quite a bit since then.
- 24:38Our use of bandwidth is slightly interesting in the sense the actual, when somebody goes to their website and they're browsing around, all of that data is served directly from AWS servers.
- 24:50And so we have servers running in AWS that does the search functionality, the thumbs up, the thumbs down, the, you're selecting something and reading the review or looking at related things and whatnot.
- 25:00But as soon as they click on the play button on a particular video, the actual video file itself is not streaming from AWS, but instead it's coming from a CDN called Open Connect.
- 25:12And this is a proprietary thing that we built where we ship these CDNs to various internet exchanges that are already, you know, filled with the right videos and they get populated with the correct, correct videos that are getting released like overnight or on a regular basis.
- 25:30The reason we do that is because we want the videos to stream from the closest possible place for the end user.
- 25:36And so when a end user in Florida clicks on it, it's coming from an internet exchange that is located in Florida.
- 25:42And that's why you don't see a lot of buffering when videos are playing from Netflix is because there's, you know, it's inside their, their network to a large extent.
- 25:50That's our Open Connect team.
- 25:51And that's, that's what they do.
- 25:53And yeah.
- 25:53Yeah.
- 25:54That's CDNs are awesome.
- 25:56And they really are just, they're kind of a bit of magic performance.
- 25:59performance dust you can sprinkle on, on sites that works for SS, for CSS and JavaScript and stuff.
- 26:08But, but when it comes to large content, then it makes all the difference.
- 26:11Yeah.
- 26:12So in the blog post you write, let's see.
- 26:15Yeah.
- 26:15It says various software systems are needed to design and build and operate the CDN infrastructure.
- 26:20And a big part of them are written in Python.
- 26:22The network devices that underlie a large portion of it are mostly managed by Python and so on.
- 26:28Give us a sense of where Python fits in this.
- 26:30Right.
- 26:31Open Connect CDN that you all run.
- 26:33Sure.
- 26:33Yeah.
- 26:33So the CDNs themselves run like high performance code to, to stream the video.
- 26:38That obviously that software is not written in Python, but the software, all the software that orchestrates
- 26:43and makes sure that these CDNs are remaining healthy, getting metrics out of them, as well as,
- 26:48you know, managing them and forecasting, like what sort of videos are going to be going into these,
- 26:53these CDNs and so forth, those are all orchestrated using Python applications.
- 26:57So these are all internal tools.
- 26:58There's like an OC tools team.
- 27:00OC stands for the Open Connect, which is the name of the CDN.
- 27:03And OC tools team is the one that builds that.
- 27:05And they use quite a lot of Python for not just tracking our CDNs, but also for projecting, you know,
- 27:12which videos and what shapes they should be going into.
- 27:14So for instance, like to give you a quick example, like if we are launching, let's say like Stranger Things,
- 27:18like the newest season, we know for a fact that these videos are going to be, you know,
- 27:22they're either going to be streamed like 90% of the time from television, like a 4K definition television,
- 27:28or people are going to be watching on their iPhone.
- 27:31So all these videos get encoded in different formats, like for different resolutions.
- 27:36And how much do we put into the CDNs and how do we get them prepared?
- 27:40Do we need like multiple copies so that multiple streams can be read without having to have contention and so on?
- 27:46Things like those kinds of projections, those are all done using Python applications.
- 27:50You probably can't put every version of every video at every location all the time, right?
- 27:56I don't know how much that is, but that's a large amount of video content, large amount of files.
- 28:00You probably got to predict, right?
- 28:02Like these, we can fall back to, you know, letting them stream from some higher upstream thing,
- 28:08but then it'll get cached after it gets viewed a little bit.
- 28:10But these were preloading, right?
- 28:12Yeah, yeah.
- 28:13Actually, Zoran used to work on the team that did all the encoding in different shapes and sizes,
- 28:18and they used quite a bit of Python as well.
- 28:21He'd be able to tell you more about that stuff.
- 28:23Yeah, did you just have like a huge office, like a whole building full of GPUs and just go in the whole time?
- 28:29Well, encoding is a lot of work.
- 28:31Yeah, tell us about this.
- 28:32Yeah, encoding is a lot of work.
- 28:33So that was my original start here, and we do a lot of Python as well.
- 28:37And yeah, we sum it up.
- 28:39We kind of try and scour, scavenge as many instances that we can put our hands on.
- 28:44So if we have any, say, AWS reservations that it so happens that nobody's using right now,
- 28:51we come and grab them and spawn our workers dynamically on it as much as we can.
- 28:59Interesting.
- 28:59Almost like grid computing, like a steady at home.
- 29:02Yeah, exactly.
- 29:03Like steady at home.
- 29:04Exactly.
- 29:04Yeah.
- 29:04And if we do have something like that is high priority, well, you know, there's not enough
- 29:09like kind of workers laying around, then we can go and get some on the spot, you know, market
- 29:15or, well, get to grab more reservations if need be.
- 29:18So that is the encoding is basically we take these big master files, right?
- 29:24Like we have these originals, and we encode them for every single variation where it makes
- 29:29sense.
- 29:29Like for this TV, for that phone, for, you know, Android phone, iOS phone.
- 29:33What is the product of all the different resolutions and different platforms?
- 29:36How many video files do you have to make for how many formats do you have to have for one
- 29:41movie?
- 29:42Do you know?
- 29:43That changes per lead.
- 29:44And, you know, we kind of keep fine tuning how we want the smallest files with the best
- 29:51quality, right?
- 29:51So that keeps evolving.
- 29:53And sometimes we re-encode the full catalog because now we have like a better way of encoding,
- 29:58say, anime things versus, you know, action movies versus like it gets to us.
- 30:04I see.
- 30:04You might choose a different encoder for a cartoon-like thing versus the planet Earth type
- 30:10of video.
- 30:11Yeah.
- 30:11Okay.
- 30:11Yeah.
- 30:12Yeah.
- 30:12And all of this, basically by way of a product of all of this, ends up on Open Connect.
- 30:17I mean, S3, but also Open Connect.
- 30:20Yep.
- 30:20Yep.
- 30:20Excellent.
- 30:21One thing in there that is mentioned on my team, very interesting project called vMath.
- 30:26So that is written in Python.
- 30:27It's machine learning.
- 30:28And once you have encoded, right?
- 30:31Like, let's say you're trying a new way of encoding to make the files even smaller, right?
- 30:36You want to know during while you're researching, right?
- 30:40You want to know, did you come up with a very good, better encoder than before?
- 30:44So vMath is like a little bot that will look at encode a new file and give it a human-like,
- 30:51score.
- 30:52Like, what quality would the human assess this to be?
- 30:56And it has to be, you know, basically excellent quality.
- 30:59Get a high score.
- 31:01I think 90 out of 100, roughly, to pass.
- 31:06And then this is better, right?
- 31:07Like, we have a smaller file, but the quality is still excellent.
- 31:10And perceptibly, it's as good as before.
- 31:13It was just a fairly smaller.
- 31:14Then we could decide and re-encode the full catalog with that.
- 31:18Yeah.
- 31:18I see.
- 31:18That's really interesting.
- 31:19So what you're telling me is you have an AI that you just make watch Netflix movies all
- 31:24the time.
- 31:25All the time.
- 31:25All the time.
- 31:26All the time.
- 31:26And we have other AIs that watch the whole catalog, for example, and find where text appears,
- 31:33say.
- 31:33You know, so that when we put subtitles, we can move them up or down, you know, to not put
- 31:37text on text.
- 31:38And all kinds of metadata, like where can we find landscapes?
- 31:42Where does Brad Pitt show up?
- 31:43Things like that.
- 31:44Incredible.
- 31:46I had no idea.
- 31:47People are always full of a lot of surprises.
- 31:49This portion of Talk Python To Me is brought to you by Influx Data, the makers of InfluxDB.
- 31:56InfluxDB is a database purpose built for handling time series data at a massive scale for real-time
- 32:03analytics.
- 32:04Developers can ingest, store, and analyze all types of time series data, metrics, events,
- 32:09and traces in a single platform.
- 32:11So, dear listener, let me ask you a question.
- 32:14How would boundless cardinality and lightning-fast SQL queries impact the way that you develop
- 32:19real-time applications?
- 32:20InfluxDB processes large time series data sets and provides low-latency SQL queries, making
- 32:26it the go-to choice for developers building real-time applications and seeking crucial insights.
- 32:31For developer efficiency, InfluxDB helps you.
- 32:34Create IoT, analytics, and cloud applications using timestamped data rapidly and at scale.
- 32:40It's designed to ingest billions of data points in real-time with unlimited cardinality.
- 32:46InfluxDB streamlines building once and deploying across various products and environments from
- 32:52the edge, on-premise, and to the cloud.
- 32:54Try it for free at talkpython.fm/InfluxDB.
- 32:58The link is in your podcast player show notes.
- 33:01Thanks to InfluxData for supporting the show.
- 33:06And I think the VMAP software that's written in Python, I believe that is open source, right,
- 33:11Zoran?
- 33:11It is.
- 33:12It is open source, yes.
- 33:13And I think it's one of the Emmy Award winning software.
- 33:16I did not know that software could win Emmy Awards before this one.
- 33:20And it apparently won an Emmy Award for something.
- 33:25Videography or something?
- 33:28Probably, yeah.
- 33:29Wow.
- 33:29That's awesome.
- 33:30All right.
- 33:31The next major section is demand engineering.
- 33:34Yeah.
- 33:34This is kind of like DevOps type stuff, right?
- 33:37Keeping things running, capacity planning.
- 33:39Yes.
- 33:40That is exactly right.
- 33:40Yeah.
- 33:41That was the team that I was in previously.
- 33:43And the regional failover is the one where I mentioned where you could traffic from one
- 33:47of the AWS regions into the other two regions.
- 33:49And so we run in three separate AWS regions.
- 33:51And anytime any of those regions is having a difficulty, we can easily move the traffic
- 33:56to the other two regions without users even noticing that there was a glitch or any kind
- 34:00of issue there.
- 34:01How long does it take?
- 34:03If you say you've got to move 50% of the traffic out of U.S. East Virginia to somewhere else,
- 34:10is that hours, minutes?
- 34:12So the fastest we have done is, so on average, it takes about seven minutes.
- 34:18Do all of that.
- 34:19And that was our target.
- 34:20So when I first joined, I was given as a target.
- 34:22It used to be around 45 minutes at the time.
- 34:24And we built some, you know, interesting things to make it possible to run it inside seven minutes.
- 34:29But the fastest we've done is like around five minutes in like an emergency where, you know,
- 34:33oh God, the entire region is tanked and people in the U.S. are not happy about this.
- 34:38Let's move as fast as we can.
- 34:40And we can do it in five minutes.
- 34:41Doesn't happen often, but you know when it happens, especially, you know, when AWS Virginia
- 34:47goes down because a quarter of the internet stops working.
- 34:50Sure.
- 34:51But it's not just AWS that goes down.
- 34:54Sometimes we shoot our spells in the foot.
- 34:58One of the interesting things to make sure that we release software that is safe is we do something
- 35:02called regionally staggered releases.
- 35:05And so when a new software or when a new version gets released, since it's like hundreds of microservices
- 35:10that are running inside of Netflix to make it all possible, every service will deploy.
- 35:14And when they start to deploy, they deploy it into a single region, wait about like five to 10 minutes
- 35:20to make sure that, you know, nothing bad has happened.
- 35:21And then they proceed to the next one and then the next one.
- 35:24And so when they release it to the first region, they can either, if they find out that it's
- 35:29bad, they can either quickly roll it back or we could just evacuate out of that region because
- 35:34we can do that in like under seven minutes.
- 35:36And so if the rollback takes longer than seven minutes, then a call will be made by the core
- 35:41team, which will say, let's evacuate out.
- 35:43We haven't figured out what the problem is.
- 35:45So and then, you know, we evacuate and then we'll debug, you know, oh, which service did
- 35:49a release and what do we need to roll back and so on.
- 35:53Because there are like hundreds of services that are simultaneously releasing at the same
- 35:57time.
- 35:57So it's like quickly trying to identify which service that we need to roll back can sometimes
- 36:01be tricky.
- 36:01So we have used failovers for that as well.
- 36:04Yeah.
- 36:04So it's not just AWS's fault.
- 36:06Yeah, sure.
- 36:06And I don't mean to pick on AWS because all these data centers go down.
- 36:11The difference is when AWS goes down, like the internet goes down, you know, the observability
- 36:17of it is so high because so much runs on there.
- 36:20It's like that in Cloudflare when they go down too.
- 36:23You're like, oh, I see everything's broken.
- 36:24Okay.
- 36:24Yeah.
- 36:25When sites go down in production, even for places way smaller than Netflix, it's really
- 36:30stressful and you might make it worse by trying to fix it.
- 36:34So the ability to just go, let's buy ourselves some time to figure this out and just get everyone
- 36:39out and then we're going to look at it.
- 36:40And then we'll get bring them back.
- 36:41That's, that's pretty cool.
- 36:42You did write an article called how Netflix does failovers in seven minutes flat, which
- 36:47I'll put in the show notes so people can read more about that if they want.
- 36:50Thanks.
- 36:50So this demand engineering side, talk about obviously tools are primarily built in Python
- 36:57there.
- 36:57You got some NumPy and SciPy and even the B Python shell.
- 37:02Tell us about some of the Python stuff going on here.
- 37:04Before I joined Netflix, like when I actually first started learning Python, I loved the REPL,
- 37:09but I always felt like the REPL did not have auto-completion in it.
- 37:13And that like B Python is a, is a alternate REPL for Python that provides you with like
- 37:18auto-completion and syntax highlighting and all that stuff.
- 37:21So I am a, I'm a huge fan of B Python.
- 37:23One of the things that we have done, like demand engineering specifically is, you know, we get
- 37:28paged and we have to go in and try and rescue our traffic out of that region into the other
- 37:33two regions.
- 37:34And sometimes our software itself will not work because if an entire region is down,
- 37:39let's say it's because of a network connectivity issue or something, then the things that we
- 37:43call out to in order to make these, you know, changes to, to scale up the other regions and
- 37:48like evacuate and make the NS changes or whatever, that itself might be broken.
- 37:51And when that's broken, like literally SSH into the box and we will open up like a shell,
- 37:57Python shell and do whatever we need to do.
- 38:01That has not happened in like the last four years, I would say, but six years ago, yeah,
- 38:05that was the thing that we used to do.
- 38:06And I wanted to call out B Python specifically in this, in this particular case, because it was so
- 38:11much more useful than trying to remember, oh, I remember I wrote this function.
- 38:15Like, what is it?
- 38:16Like, instead of like opening my IDE to try to find out what that function is, like I just
- 38:19import the module and then I do the module dot and it lists me all the functions and I could
- 38:24invoke it.
- 38:24And yeah, it's such a time saver.
- 38:26Yeah.
- 38:26The Python REPL is cool, but it, it leaves a lot to be desired in terms of.
- 38:30Right.
- 38:31History.
- 38:31Or even if you want to edit a function that is five lines long, it's, it's, it's, it's
- 38:38hard to go through.
- 38:39It becomes cumbersome.
- 38:39Another one is PT Python that I'm.
- 38:42Yeah.
- 38:42I'm also a fan of that one.
- 38:44Yes.
- 38:44They're kind of the same category, right?
- 38:46Yeah.
- 38:47Prompt Toolkit, the one that powered PT Python, written by Jonathan Slenders, actually.
- 38:51And it's like a fantastic library.
- 38:54I just like kudos to, to Jonathan for doing that.
- 38:57That was, it's a fantastic library.
- 38:58Yeah.
- 38:59Awesome.
- 39:00So are you, you got a particular enhancement there for your, your REPL?
- 39:05I'm not like that big of a user of REPL.
- 39:07In the terminal, we do like, you know, ask questions for generating new projects, et cetera.
- 39:12I'm much more of a PyCharm user myself.
- 39:14Like I go in the computer over there.
- 39:16As you bring that up, you know, one of the really nice Python REPLs is the, what I guess
- 39:20it's called probably the Python console in PyCharm, right?
- 39:23Because if you go to that, you get the Python REPL, but you get PyCharm's autocomplete and,
- 39:28you know, type consistency and it automatically modifies the path to import your project.
- 39:33So yeah.
- 39:33And like, you got one in there.
- 39:34Yeah.
- 39:35Just that one's yours.
- 39:36All right.
- 39:36Let's see the core team alerting and statistical work.
- 39:41What's this one about?
- 39:42Core team is our frontline SRE.
- 39:45So demand team is like building tools that the core team will leverage to, to get us out
- 39:50of trouble.
- 39:50So core team is the one that, you know, anytime there is like, they monitor a lot of metrics,
- 39:54not just streaming metrics, but also things like error rates between services that are happening
- 40:00and how many requests are successfully coming back and so forth.
- 40:03They obviously use Python to kind of keep tabs on, like obviously a person can't be sitting
- 40:08in front of a dashboard, just monitoring it themselves.
- 40:11So they use quite a bit of Python to analyze the data from all of the hundreds of microservices
- 40:16and between them, the inter-process communication that actually happens and the metrics that
- 40:20come through and so forth.
- 40:21So they use Python for alerting.
- 40:23And so actually they use the monitoring.
- 40:25The next section that I was, that's right there is a monitoring, alerting and auto remediation.
- 40:29We have an internal observability organization that has built our own time series database that's
- 40:36not in Python, but you know, it's open source called Atlas.
- 40:39And that uses, that collects all of the time series data from all of these services.
- 40:44And then they try and do alerting and remediation, auto remediation.
- 40:48So when a particular alert condition is met, they can, you can run a small Python script inside
- 40:54of a framework called Winston.
- 40:56That's again, internal that allows you to do more complicated things.
- 40:59So for instance, if you have like this one bad instance in like this, this collection of
- 41:0420 instances, instead of a user going and terminating that instance, you can now automate that by
- 41:09writing a script that says, you know, automatically restart that, that instance or just kill it.
- 41:14And so on.
- 41:15That's, that's our.
- 41:16Cool.
- 41:16That's part of the auto, auto remediation of it.
- 41:18And it says it's built on Gunicorn flask and flask rest plus.
- 41:24I'm familiar with the first batch, but the flask rest plus, this is new, an extension for flask that adds
- 41:30support for quickly building rest APIs.
- 41:33Okay.
- 41:33Interesting.
- 41:34Because flask itself already does rest.
- 41:36I don't like, so rest plus I think provides things like a swagger endpoints automatically.
- 41:40So you could, you know, try it out on the browser and so on.
- 41:44I have not used flask rest plus myself, but that team uses it quite a bit.
- 41:48Yeah.
- 41:48Cool.
- 41:49Probably some of the, some, some similarities to like what FastAPI kind of brings in addition
- 41:54to standard flask, I'd imagine.
- 41:56Exactly.
- 41:56Yeah.
- 41:57Yeah.
- 41:57You use more FastAPI nowadays.
- 41:59Yes.
- 42:00Oh yeah.
- 42:00Yeah.
- 42:01We're using quite a bit of FastAPI in most of our internal tools actually.
- 42:04Yeah.
- 42:05Just from reading through this article, it sounds like there's a lot of APIs and just a lot of
- 42:10connectivity through.
- 42:11There's probably a lot of JSON going around Netflix.
- 42:14Yes.
- 42:14Yeah.
- 42:14So the, some of the heavy, heavier data stuff or like high streaming services like that
- 42:21are in the streaming path are all typically written in Java and they use for inter-process
- 42:25communication.
- 42:25They use gRPC and that uses protobuf to communicate and so forth.
- 42:30But most of our internal tools that are written in Python either use JSON directly or sometimes
- 42:36they need to talk to a gRPC service.
- 42:38And so they use Python gRPC to get the work done.
- 42:41Maybe we'll have some time to come back to gRPC.
- 42:44I'm not sure.
- 42:44We got a lot of things to talk about here.
- 42:46Yeah.
- 42:47We don't have to go through every section here.
- 42:49I mean.
- 42:50No, I know.
- 42:50But there's, there's just so many interesting angles.
- 42:52Right.
- 42:53And so.
- 42:53Yeah.
- 42:53The next one here is information security, which obviously if you just put anything on
- 42:58the internet and just tail the log of it within minutes, you'll see a request for,
- 43:03you know, WP admin.php.
- 43:05You know, like it's just, it's already just constantly being, you know, people are just after it.
- 43:11Right.
- 43:11Yep.
- 43:12Yep.
- 43:12One of the things you have here that looks interesting is security monkey written in Python,
- 43:17which is, I guess, like chaos monkey, but.
- 43:20It is kind of like chaos monkey.
- 43:21I think this project may have been archived or it's not actively in development.
- 43:28It tries to scan our infrastructure for unsafe practices.
- 43:31That's like a, an umbrella term to try to add like whatever is like good practices that
- 43:37should exist for, for, from the security standpoint.
- 43:39Yeah.
- 43:40Okay.
- 43:40So people can check it out.
- 43:41Maybe it's not totally active anymore, but they can take it as inspiration.
- 43:44Right.
- 43:45Yeah.
- 43:45Yeah.
- 43:45Yeah.
- 43:45Yeah.
- 43:46Like back in 2019, it was one of our most active projects.
- 43:48But apparently 2023 is a different world.
- 43:52It is a different world.
- 43:53And one of the areas in which 2023 is a different world is really the AI ML side.
- 43:59And you all are doing a lot of stuff with personalization algorithms, recommendation engines, machine learning.
- 44:06And you talked about Metaflow, which is now available.
- 44:09Yeah.
- 44:09The personalization one, I think we've just mentioned a bunch of things that we use from
- 44:14the open source world here.
- 44:14So I think XGBoost is a, is a library that does machine learning.
- 44:19So personally, I am not, I am not in this field.
- 44:21So I just went and interviewed the team and asked them to give me a blurb.
- 44:25So I wouldn't be able to talk in detail about any of the personalization stuff here,
- 44:30but yeah, this is just a showcase of how much this team relies on Python and the, and the
- 44:37open source ecosystem that comes with Python in general.
- 44:40So it's like heavy users of Panda TensorFlow and PyTorch and so on.
- 44:45Yeah.
- 44:46So let me ask you, is it your, both of your, your team supports Python developers and Python
- 44:53applications indirectly in that way, but is it different to support the data scientists than
- 44:58it is to support, say software developers?
- 45:00Like, do you have to think about that differently?
- 45:02How so?
- 45:03Yes.
- 45:04Yes.
- 45:04We do have like a, a team that is dedicated to supporting all the data scientists and we
- 45:08are like the team that supports the team who supports the data scientists.
- 45:11They should.
- 45:12Right now.
- 45:13So, so yeah, we were, definitely like now in 2023, you know, betting more on
- 45:19Python before Python was more like, if it makes sense for you because of freedom and responsibility,
- 45:24if it makes sense to use Python in your team, you use Python, you know, and now we're trying
- 45:28to provide basically like a better base path.
- 45:31This is, me and Amjit with this new team that we started, we're trying to kind of enhance
- 45:36this base path better and better for all these teams.
- 45:39And we, you know, it's hard to know all the specifics in every single team, but we're
- 45:46trying to provide them with as good practices and automation as possible.
- 45:50So I think you asked like, how is it different, supporting one versus the other?
- 45:55I think we built, so when we first started the team, we met with 10 different organizations
- 46:00inside of Netflix to find out like how they use Python.
- 46:03And we found that there were some commonalities, but the way, for instance, like algorithms
- 46:08engineering uses Python is very different from the way a SRE team uses Python.
- 46:12And it's very, very different from how our animation studio uses Python.
- 46:16So our VFX animation uses Python in a way where they, once they start, like this is apparently
- 46:23common in all of, the movie industry, which is once they start a particular project, whatever
- 46:28they have chosen at the start of that project, they will stick to it until that project is
- 46:32completed.
- 46:32So if that movie takes two years to finish, you cannot upgrade anything inside of that particular
- 46:37hermetically sealed, environment, development environment that you have.
- 46:42So that is very different from like another, like a machine learning person who's interested
- 46:46in like, you know, I just want to write my algorithm.
- 46:48Like I don't, I don't care about how pip works or like how I pip install.
- 46:52Like I don't want to worry about like virtual environments and things like that.
- 46:55Whereas a person who's writing internal tools, they want to like main, like, you know, own
- 46:59the entire tool chain.
- 47:00It's like, I not only want to maintain virtual environment, I also want this thing to work
- 47:05with a front end that is written in react.
- 47:07And so I would like you to be able to like make it possible to do like npm and, and, and
- 47:12pip to coexist and, and live together.
- 47:14That's not like a hard thing to do, but it's one of those things where it's like, if I'm
- 47:19trying to solve a problem, let's say I'm, I'm bringing in like Python dependency locking
- 47:23as a, as a mechanism to help these web developers, right?
- 47:26Because they, they don't want to automatically upgrade anytime they build their system and,
- 47:30and suddenly break in production.
- 47:31Now that might be completely useless for someone who's working in machine learning.
- 47:36And so they're like, you know, why are you solving that problem?
- 47:38This, you know, you bringing like locking to packaging doesn't help me in any way.
- 47:43Like, why are you wasting your time?
- 47:44And so we had to sort of build personas for various ways in which Python is used inside
- 47:50of Netflix.
- 47:50So that when we are working on a particular feature, we can tell them we are now targeting
- 47:54this persona.
- 47:55We are working towards making life easy for animation engineers.
- 47:58So if it doesn't work for you, that's fine.
- 48:01You know, that's fine.
- 48:02We will get to you.
- 48:03It's just that our persona that we're targeting right now is not yours.
- 48:06So that's, that's how it's different.
- 48:08I'd say.
- 48:08Yeah.
- 48:09Yeah.
- 48:10Data scientists have a lot less legacy code.
- 48:13That's just still cranking along because a lot of times once they get, they discover
- 48:16an insight, they don't need to run it again.
- 48:18Right.
- 48:18They, or the algorithms are changing so fast.
- 48:20They can just, well, now we're using large language models instead of whatever, you know?
- 48:26Yeah.
- 48:26There you go.
- 48:26Yeah.
- 48:27Yeah.
- 48:27Whereas once you get a web app running, you might not touch that thing if it doesn't
- 48:32need touching.
- 48:32Right.
- 48:32So you just.
- 48:33Exactly.
- 48:33Stability is what you need there.
- 48:35So anything else you want to call out out of this article before we move on?
- 48:40We don't have a ton of time left, honestly, but.
- 48:42No, no.
- 48:43I think this was a great article, but yeah, two things.
- 48:47With regard to this, let's just leave people with this idea that we only touched on a small
- 48:53part of what is laid out here and all the projects and all the ways in which it's being
- 48:58used.
- 48:58So certainly check out the article just called Python at Netflix that I'll put in the show
- 49:02notes.
- 49:03It's hard to cover it all in just one hour.
- 49:05It sure is.
- 49:06It sure is.
- 49:08So let's maybe talk for a minute here about this project that you're involved with, Soren,
- 49:13called Portable Python.
- 49:14You know, I not long ago had Nathaniel Smith on to talk about PEP 7-11, distributing Python
- 49:21binaries and maybe treating like CPython runtimes as wheels almost.
- 49:28And you guys also have a way that you've been using for a while internally to package up
- 49:33Python into something that can run as well called Portable Python, which is open source.
- 49:37You want to talk a bit about that?
- 49:38Yes.
- 49:39That is in PEP 7-11.
- 49:41I discovered it by listening to your podcast.
- 49:44Right around PyCon, I think.
- 49:45Yes.
- 49:46It would be very interesting to see if we could partner up once this is.
- 49:50So Portable Python is, we want to provide Python, of course, to all Python developers inside.
- 49:56Right?
- 49:57You can always grab your own Python via all kinds of ways.
- 50:00Right?
- 50:01PyN, Docker image, et cetera.
- 50:03But we also provide builds of Python inside to be used internally.
- 50:07So Portable Python is trying to solve, adjust that.
- 50:11Well, one particular issue, how do you go and distribute Python on laptops?
- 50:15So the end goal is we want to provide a tarball, just like that PEP says, you know, like a wheel.
- 50:23A tarball that you can download and drop somewhere, typically in, you know, a user's own folder,
- 50:30tilde slash, you know, mypythons.
- 50:33And we want it to work from there.
- 50:34So you could use PyN for that, but with PyN, we need to wait for it to build.
- 50:39Right?
- 50:39And we want to basically build it ahead of time.
- 50:42And as soon as it's available and, you know, make it available internally.
- 50:46So what Portable Python is designed to do is to do such a build, we call it Portable,
- 50:51and drop it in Artifactory.
- 50:53And then our tooling can just go fetch that real quick, unzip, and it's ready to go.
- 50:58So your tooling, the Portable Python tooling, basically says,
- 51:01I'm on this platform.
- 51:03So I'm on macOS and it's Apple Silicon.
- 51:06So here's the, and they want this version of Python.
- 51:09So that means this binary.
- 51:11Let's go grab it.
- 51:12Right.
- 51:12Right.
- 51:13So Portable Python is invoked by our building machinery.
- 51:16There's one worker on macOS, x86, macOS M1, Linux, x86, Linux, ARM64.
- 51:24And there's some external internal tooling that kind of detects that the new open source version
- 51:31is available using Portable Python.
- 51:33So Portable Python can report you.
- 51:35What is the latest?
- 51:363.11, for example.
- 51:38By looking at the ftp.python.org, basically.
- 51:41Okay.
- 51:41So the latest is 3.11.3.
- 51:43Let's see.
- 51:44Do we have it internally?
- 51:45No.
- 51:45Okay.
- 51:45Let's kick off a build.
- 51:46So we kick off one build for M1, one build for Linux, et cetera.
- 51:51And with Portable Python, we fit the configuration.
- 51:55We say we want OpenSSL, that version.
- 51:57We want SQLite, that version.
- 51:59And Portable Python goes ahead and does the build, produces a tarball.
- 52:02We take that tarball and publish it internally.
- 52:05That's interesting.
- 52:06So you can control a little bit some of the internals as well, like the OpenSSL version
- 52:10and SQLite version, maybe a bit more carefully.
- 52:12Yes.
- 52:13Yes.
- 52:13And since it's written in Python, then it's able to also inspect, say, any Python.
- 52:20Like you could run Portable Python, inspect path to this installation, and it will tell
- 52:24you, okay, it has a SSL, that version, SQLite, that version.
- 52:27It does it use like homebrew, shared libraries or what.
- 52:32It can report on that.
- 52:34And, oh yeah, it generates a thing that I find very important, like a little file that says
- 52:40it's called manifest.yaml.
- 52:42So every time it builds anything, it generates a dot manifest.yaml where it says, well, I did
- 52:48the build with dash dash, LTO optimization, dash dash, like it says everything that was
- 52:53used to kind of inform what the build had and which worker it ran on, what time, what was
- 52:59the platform.
- 53:00Like a little bit of metadata, which sometimes.
- 53:02So you could even see things like what C compiler optimization flags were enabled when you created
- 53:07it, for example.
- 53:08Yes.
- 53:09Okay.
- 53:09And there is one additional thing.
- 53:11So Portable Python does not install Python on your system for you.
- 53:15So it is a builder.
- 53:16So it builds them and produces tarballs that can be used in a standalone manner.
- 53:21And so if you want to bring Python onto your system, you just download the tarball from our
- 53:26internal artifact storage and then expand it.
- 53:29And that we have another tool that automatically does that.
- 53:32And so when somebody bootstraps a brand new Python project and they say, I would like to
- 53:37use 3.11.3, which are 3.11.4, I think that got released yesterday.
- 53:41Then we will already have a binary ready for them that is in the artifactory, in our internal
- 53:46artifactory.
- 53:47And when they run their build for the very first time, it will bring the appropriate Python
- 53:52version that they have specified in either pyproject.toml or in their tox.ini or somewhere.
- 53:57And it will bring that appropriate Python, install it or expand it in a known location, and it
- 54:02will use that for their building their project and so forth.
- 54:05So this is, it's a way to make it easy for people to not have to manage their Python on their
- 54:10laptop individually.
- 54:11And also this can build Python with a specific prefix.
- 54:15So on servers, on our internal servers, what we do is we install Python in a specific location.
- 54:21Like we always put it inside, let's say, for example, slash app slash Python, for example.
- 54:25It will build it in a way that it makes it easy for Debiants to be built.
- 54:29And when you install the Debian, it will put the Python in a specific location.
- 54:33And also it has other benefits, such as it tries to make the Python binary as small as
- 54:40possible because we're trying to deploy it out to like hundreds of thousands or a hundred
- 54:44thousand servers.
- 54:45So we would try to reduce the amount that we need to put on that server.
- 54:49It does that.
- 54:50The final product that Zoran checked yesterday, I believe it was only 50 megabytes compared to
- 54:55what other like buy-in on other things are producing, which was 200 megabytes.
- 54:59It does it by a few tricks.
- 55:01It looks like it removes the test folder because, you know, once you have built it, like, you
- 55:05know, having the test folder as part of your final artifact makes no sense.
- 55:08That was like a hundred megabytes savings right there.
- 55:10So things like that, some optimizations that we do that is custom for our work.
- 55:15Yeah.
- 55:15That's a really interesting system.
- 55:16I think there's increasing momentum around having some kind of tool that is outside of
- 55:23Python for managing Python, right?
- 55:24So far, primarily what we've had is things like Pip, PipX, Soarin' You have a project called
- 55:30Pickley.
- 55:31And it's all about like, okay, you have Python.
- 55:33Now, how do you go forward?
- 55:35But I think a lot of people are realizing like, wait, that assumption that I have Python, now
- 55:39what, is not a great assumption, right?
- 55:41And so people are starting to look at tools like RustUp, which actually is kind of like Pip,
- 55:46but it brings Rust into it, yeah.
- 55:48Over, yeah.
- 55:48So we're going to see something there, I think.
- 55:50I don't know what it is, but it'll be interesting.
- 55:52Yeah.
- 55:52Did you see the one Rai?
- 55:54Rai is the package manager that Armin wrote, which...
- 55:58Yeah, from Armin Roenker.
- 55:59Yeah.
- 56:00That brings Python for you.
- 56:02His inspiration is from RustUp, apparently.
- 56:05So Rai is actually written in Rust, and it does all the things that Poetry and PDM and
- 56:11other package managers does.
- 56:12But in addition to that, it also brings Python for you.
- 56:15And it's using a different Python called StandalonePython or something that you already had a link
- 56:20for, I forgot.
- 56:21But it brings Python from there to expand it into your system.
- 56:25Yeah, Python Build Standalone, that's the project that it uses.
- 56:27Yeah, I've heard of that.
- 56:29I haven't done anything with it, but it looks interesting.
- 56:31Yeah.
- 56:31All right.
- 56:32I think we have time.
- 56:33We're getting short on time here.
- 56:34I think we have time for one more really quick thing, something that you're participating in,
- 56:38Amjith.
- 56:39I'm sure I don't know if you are as well.
- 56:41But Command Line Database Clients with Autocomplete and Syntax Highlighting.
- 56:46Tell us about this.
- 56:47This looks cool.
- 56:47Yeah.
- 56:48This is just my personal project that I wrote before.
- 56:51This was a while back.
- 56:52But the idea is, at the time, I was trying to learn Postgres, and I didn't know how to do,
- 56:58like, I was learning Postgres, and I was using PSQL to do this.
- 57:01And every time I come to, like, a table, I'd be like, you know, oh, what columns were there?
- 57:06I forgot the exact name of the column, and I tried to find it and so forth.
- 57:10And so, finally, you know, I broke down and decided to write, like, a shell for Postgres called PGCLI
- 57:17that uses, actually, PromToolkit, like the same toolkit that's used by PtPython.
- 57:21I was going to say, it looks a lot like PtPython.
- 57:24It's got that Emacs mode.
- 57:25Yep.
- 57:26You've got Autocomplete for basically the whole SQL language, but also the database schema that
- 57:31you're connected to, right?
- 57:32Yes, that is correct.
- 57:33So, it reads the tables and the columns in that database, and then it tries to Autocomplete
- 57:38as part of the SQL statement.
- 57:39So, after a where clause, it'll only suggest columns.
- 57:42And after a from clause, it'll only suggest tables and so on.
- 57:45Wow.
- 57:46Okay.
- 57:46So, after PGCLI, people wanted something for MySQL.
- 57:50So, I created MyCLI, and then Microsoft came over and said, like, we would like to fork
- 57:55PGCLI to make one for Microsoft's MS SQL server.
- 57:58So, they did that themselves.
- 58:00Like, we didn't.
- 58:01So, they took PGCLI source code, and then they created that.
- 58:03And then another person created Lite CLI, which is for SQLite.
- 58:07And, yeah.
- 58:08And there's other things now.
- 58:09iRedis is, like, for a Redis client that's similar to these things, but there's a lot more,
- 58:14like, more friendlier shells for databases in general.
- 58:17Excellent.
- 58:17All right.
- 58:18This looks really cool, I think.
- 58:20Yeah, this has got nothing to do with Netflix.
- 58:22It's mostly just, like, hey, it's my personal project, and, you know, just what I do in my
- 58:27free time sort of a thing.
- 58:28Yeah.
- 58:28Well, it looks really helpful for people, because talking to databases just in your terminal,
- 58:34it can be tricky, right?
- 58:35And having autocomplete, especially not so much, you know, the select and where people get that
- 58:40pretty quick, but the database schema understanding keeps you in your flow pretty well.
- 58:45Right.
- 58:45Yeah.
- 58:45Yeah.
- 58:45Again, inspired by Bpython, actually.
- 58:47Took the inspiration from them.
- 58:49Yeah.
- 58:49Excellent.
- 58:50All right.
- 58:50Well, that'll be in the show notes as well.
- 58:52Guys, I think that is it for time that we have today.
- 58:55So we're going to have to wrap it up with the final two questions here and recommendations.
- 58:59Let's start with a PyPI project.
- 59:02Not necessarily the most popular one, but something that you're like, oh, this is awesome.
- 59:05People should know about it.
- 59:07Soren, got a recommendation for folks?
- 59:08I'm going to say Pickly.
- 59:09Go check out Pickly.
- 59:11Pickly.
- 59:11Okay.
- 59:12So give us the elevator pitch on Pickly.
- 59:14It's a CLI tool that allows you to install other CLI tools, very similar to Pipex in that sense.
- 59:21The main difference is being that if you Pickly install Poetry, every time you run Poetry,
- 59:26it will keep itself up to date in the background.
- 59:29So it will keep self-upgrading by default.
- 59:32You can tell it also not to do that, but that's its main useful thing.
- 59:36Cool.
- 59:36So when you launch it, basically you're launching like a shim that says run this and then the
- 59:41background check for update.
- 59:42And when it exits, if there's an update, just update it.
- 59:44Yes.
- 59:45You can take a look at the little shell script, shell wrapper that it wraps it with.
- 59:49Yes.
- 59:49All right.
- 59:50Pickly.
- 59:50Awesome.
- 59:50Amjith.
- 59:51Oh, I guess I could plug again for Bpython.
- 59:54Like good design aesthetics.
- 59:55I think, yeah, it's an overall better shell than Python shell.
- 59:59Yeah.
- 59:59Oh, actually PDB++.
- 1:00:01That's the one that I would actually recommend.
- 1:00:03So if you ever use PDB and you wish that PDB had auto-completion, it's PDBPP in PyPy.
- 1:00:10You don't have to change your thing at all.
- 1:00:13All you have to do is pip install PDBPP.
- 1:00:15And then anytime you do a breakpoint and it stops you there, you can do like a variable
- 1:00:21dot and it'll give you auto-completion.
- 1:00:23And yeah.
- 1:00:24I don't know.
- 1:00:24I'm a huge fan of auto-completion.
- 1:00:26Yeah.
- 1:00:26I was going to say, you and I are kindred spirits.
- 1:00:29I am all about the auto-completion.
- 1:00:31I'm like, this tool is broken if it doesn't give me auto-complete.
- 1:00:33Because it sends you into the documentation.
- 1:00:36You'll be like, oh, I need to create one of these client libraries.
- 1:00:39What does it take?
- 1:00:40Oh, star args, star, star, kwrgs.
- 1:00:42Great.
- 1:00:42Now what am I supposed to do?
- 1:00:43Right?
- 1:00:44Like, you know, the auto-complete, it really makes you more productive.
- 1:00:49All right.
- 1:00:49And then if you're going to write some Python code, what editor, if you're not in the Ripple,
- 1:00:54are you using?
- 1:00:54For me, it's PyCharm.
- 1:00:56PyCharm mostly sublime text and VI if I'm SSHing somewhere.
- 1:01:02Excellent.
- 1:01:03And Amjith?
- 1:01:03Vim all the way.
- 1:01:05You know, even if I don't know how to quit it, I can restart my computer.
- 1:01:11That is the source of, the endless source of jokes.
- 1:01:14You know, like, I saw some laptop, a picture of a laptop, and it was just smashed to pieces.
- 1:01:20And it said, finally figured out how to quit Vim.
- 1:01:22For the longest time, actually, I had colon Q as a way to quit out of PGCLI because I, by
- 1:01:31instinct, just kept hitting colon Q.
- 1:01:33And yeah.
- 1:01:34That's amazing.
- 1:01:35All right, you guys.
- 1:01:37Well, it's been great to have you on the show.
- 1:01:39Thanks for being here.
- 1:01:40Thanks for giving us this look at what you're all doing up over at Netflix and your personal
- 1:01:44projects.
- 1:01:44Yeah.
- 1:01:45Thank you, Michael.
- 1:01:45I just would like to mention that we have a lot of jobs at Netflix that require Python.
- 1:01:50So if you are at all interested, please go to jobs.netflix.com and type in Python, and you
- 1:01:55should get all of the Python job openings that are available.
- 1:01:58There's a wide variety.
- 1:01:59If you want to do infrastructures of, there's that.
- 1:02:02If you want to do data science, there's that, right?
- 1:02:04Like a lot of coolers.
- 1:02:05Yes, absolutely.
- 1:02:06All right.
- 1:02:07Have a great day, guys.
- 1:02:08Thank you.
- 1:02:09Bye.
- 1:02:09Bye.
- 1:02:10Bye.
- 1:02:10This has been another episode of Talk Python To Me.
- 1:02:13Thank you to our sponsors.
- 1:02:15Be sure to check out what they're offering.
- 1:02:17It really helps support the show.
- 1:02:18The folks over at JetBrains encourage you to get work done with PyCharm.
- 1:02:24PyCharm Professional understands complex projects across multiple languages and technologies,
- 1:02:29so you can stay productive while you're writing Python code and other code like HTML or SQL.
- 1:02:35Download your free trial at talkpython.fm/done with PyCharm.
- 1:02:41Influx data encourages you to try InfluxDB.
- 1:02:44InfluxDB is a database purpose-built for handling time series data at a massive scale for real-time
- 1:02:50analytics.
- 1:02:51Try it for free at talkpython.fm/InfluxDB.
- 1:02:55Want to level up your Python?
- 1:02:56We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:03:00Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:03:05And best of all, there's not a subscription in sight.
- 1:03:08Check it out for yourself at training.talkpython.fm.
- 1:03:11Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 1:03:16We should be right at the top.
- 1:03:17You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:03:22and the direct RSS feed at /rss on talkpython.fm.
- 1:03:26We're live streaming most of our recordings these days.
- 1:03:30If you want to be part of the show and have your comments featured on the air,
- 1:03:33be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:03:38This is your host, Michael Kennedy.
- 1:03:40Thanks so much for listening.
- 1:03:41I really appreciate it.
- 1:03:42Now get out there and write some Python code.
- 1:03:44Why?
- 1:03:45Why?
- 1:03:46Why?
- 1:03:47I'll see you next time.