Skip to Content
Scaling Python with Dask
book

Scaling Python with Dask

by Holden Karau, Mika Kimmins
July 2023
Intermediate to advanced
223 pages
5h 24m
English
O'Reilly Media, Inc.
Content preview from Scaling Python with Dask

Chapter 7. Adding Changeable/Mutable State with Dask Actors

Dask is focused on scaling analytic use cases, but you can use it to scale many other types of problems. So far, most of the tools you have used in Dask are functional. Functional programming means that previous calls do not impact future calls. Stateless functions are common in distributed systems like Dask, as they can safely be re-executed multiple times on failure. Updating the weights of a model during training is an example of state common in data science. One of the most common ways of handling state in a distributed system is with the actor model. This chapter will introduce both the general actor model and Dask’s specific implementation.

Dask futures offer a non-mutable distributed state, where values are stored on the workers. However, this doesn’t work well for situations in which you want to update the state, like changing a bank account balance (an alternative solution is illustrated in Example 7-1), or updating machine learning model weights during training.

Tip

Dask actors have a number of limitations, and we believe that in many cases the right answer is to keep mutable state outside of Dask (like in a database).

Of course, you don’t have to use distributed mutable state. In some cases, you may choose to not use distributed state and instead put it all in your main program. This can quickly lead to bottlenecks on the node responsible for your main program. Other options include storing your state outside ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Scaling Python with Ray

Scaling Python with Ray

Holden Karau, Boris Lublinsky

Publisher Resources

ISBN: 9781098119867Errata Page