Debian Codegraph @

docs/source/why.rst

raw
1 :orphan:
2
3 .. this page is refernenced from dask.org. It might move to there some day.
4
5 Why Dask?
6 =========
7
8 This document gives high-level motivation on why people choose to adopt Dask.
9
10 .. contents:: :local:
11
12 Python's role in Data Science
13 -----------------------------
14
15 Python has grown to become the dominant language both in data analytics and
16 general programming:
17
18 .. image:: images/growth_of_languages.png
19 :alt: Graph showing the growth of major programming languages based on Stack Overflow’s question views in World Bank high-income countries. A line graph with time from 2012 to 2018 on the x-axis and percent of overall question views each month on the y-axis. Python’s question views increase from about 4% to about 11% from 2012 to 2018, reaching the popularity of Java and JavaScript.
20 :width: 75%
21
22 This is fueled both by computational libraries like Numpy, Pandas, and
23 Scikit-Learn and by a wealth of libraries for visualization, interactive
24 notebooks, collaboration, and so forth.
25
26 .. image:: images/growth_of_libraries.png
27 :alt: Graph showing the growth of major python packages based on Stack Overflow's question views in World Bank high-income countries. A line graph with time on the x-axis from 2012 to 2018 and percent of overall question views each month on the y-axis. Pandas question views increased to about 0.9% in 2018, exceeding Django and NumPy.
28 :width: 75%
29
30 However, these packages were not designed to scale beyond a single machine.
31 Dask was developed to scale these packages and the surrounding ecosystem.
32 It works with the existing Python ecosystem to scale it to multi-core
33 machines and distributed clusters.
34
35 *Image credit to Stack Overflow blogposts*
36 `#1 <https://stackoverflow.blog/2017/09/06/incredible-growth-python>`_
37 *and*
38 `#2 <https://stackoverflow.blog/2017/09/14/python-growing-quickly/>`_.
39
40
41 Dask has a Familiar API
42 -----------------------
43
44 Analysts often use tools like Pandas, Scikit-Learn, Numpy, and the rest of the
45 Python ecosystem to analyze data on their personal computer. They like these
46 tools because they are efficient, intuitive, and widely trusted. However, when
47 they choose to apply their analyses to larger datasets, they find that these
48 tools were not designed to scale beyond a single machine. And so, the analyst
49 rewrites their computation using a more scalable tool, often in another
50 language altogether. This rewrite process slows down discovery and causes
51 frustration.
52
53 Dask provides ways to scale Pandas, Scikit-Learn, and Numpy workflows more
54 natively, with minimal rewriting. It integrates well with these tools so that it copies
55 most of their API and uses their data structures internally. Moreover, Dask is
56 co-developed with these libraries to ensure that they evolve consistently,
57 minimizing friction when transitioning from a local laptop,
58 to a multi-core workstation, and then to a distributed cluster. Analysts
59 familiar with Pandas/Scikit-Learn/Numpy will be immediately familiar with their
60 Dask equivalents, and have much of their intuition carry over to a scalable
61 context.
62
63
64 Dask Scales out to Clusters
65 ---------------------------
66
67 As datasets and computations scale faster than CPUs and RAM, we need to find
68 ways to scale our computations across multiple machines. This introduces many
69 new concerns:
70
71 - How to have computers talk to each other over the network?
72 - How and when to move data between machines?
73 - How to recover from machine failures?
74 - How to deploy on an in-house cluster?
75 - How to deploy on the cloud?
76 - How to deploy on an HPC super-computer?
77 - How to provide an API to this system that users find intuitive?
78 - ...
79
80 While it is possible to build these systems in-house (and indeed, many exist),
81 many organizations increasingly depend on solutions developed within the
82 open source community. These tend to be more robust, secure, and fully
83 featured without being tended by in-house staff.
84
85 Dask solves the problems above. It figures out how to break up large
86 computations and route parts of them efficiently onto distributed hardware.
87 Dask is routinely run on thousand-machine clusters to process hundreds of
88 terabytes of data efficiently within secure environments.
89
90 Dask has utilities and documentation on how to deploy in-house, on
91 the cloud, or on HPC super-computers. It supports encryption and
92 authentication using TLS/SSL certificates. It is resilient and can handle the
93 failure of worker nodes gracefully and is elastic, and so can take advantage of
94 new nodes added on-the-fly. Dask includes several user APIs that are used and
95 smoothed over by thousands of researchers across the globe working in different
96 domains.
97
98
99 Dask Scales Down to Single Computers
100 ------------------------------------
101
102 *But a massive cluster is not always the right choice*
103
104 Today's laptops and workstations are surprisingly powerful and, if used
105 correctly, can handle datasets and computations for which we previously
106 depended on clusters. A modern laptop has a multi-core CPU, 32GB of RAM, and
107 flash-based hard drives that can stream through data several times faster than
108 HDDs or SSDs of even a year or two ago.
109
110 As a result, Dask can empower analysts to manipulate 100GB+ datasets on their
111 laptop or 1TB+ datasets on a workstation without bothering with the cluster at
112 all. This can be preferable for the following reasons:
113
114 1. They can use their local software environment, rather than being
115 constrained by what is available on the cluster or having to manage
116 Docker images.
117 2. They can more easily work while in transit, at a coffee shop, or at home
118 away from the corporate network
119 3. Debugging errors and analyzing performance is simpler and more pleasant on
120 a single machine
121 4. Their iteration cycles can be faster
122 5. Their computations may be more efficient because all of the data is local
123 and doesn't need to flow through the network or between separate processes
124
125 Dask can enable efficient parallel computations on single machines by
126 leveraging their multi-core CPUs and streaming data efficiently from disk.
127 It *can* run on a distributed cluster, but it doesn't *have* to. Dask allows
128 you to swap out the cluster for single-machine schedulers which are surprisingly
129 lightweight, require no setup, and can run entirely within the same process as
130 the user's session.
131
132 To avoid excess memory use, Dask is good at finding ways to evaluate
133 computations in a low-memory footprint when possible by pulling in chunks of
134 data from disk, doing the necessary processing, and throwing away intermediate
135 values as quickly as possible. This lets analysts perform computations on
136 moderately large datasets (100GB+) even on relatively low-power laptops.
137 This requires no configuration and no setup, meaning that adding Dask to a
138 single-machine computation adds very little cognitive overhead.
139
140 Dask is installed by default with `Anaconda <https://anaconda.com>`_
141 and so is already deployed on most data science machines.
142
143
144 Dask Integrates Natively with Python Code
145 -----------------------------------------
146
147 Python includes computational libraries like Numpy, Pandas, and Scikit-Learn,
148 and many others for data access, plotting, statistics, image and
149 signal processing, and more. These libraries work together seamlessly to
150 produce a cohesive *ecosystem* of packages that co-evolve to meet the needs of
151 analysts in most domains today.
152
153 This ecosystem is tied together by common standards and protocols to which
154 everyone adheres, which allows these packages to benefit each other in
155 surprising and delightful ways.
156
157 Dask evolved from within this ecosystem. It abides by these standards and
158 protocols and actively engages in community efforts to push forward new ones.
159 This enables the rest of the ecosystem to benefit from parallel and distributed
160 computing with minimal coordination. Dask does not seek to disrupt or displace
161 the existing ecosystem, but rather to complement and benefit it from within.
162
163 As a result, Dask development is pushed forward by developer communities
164 from Pandas, Numpy, Scikit-Learn, Scikit-Image, Jupyter, and others. This
165 engagement from the broader community growth helps users to trust the project
166 and helps to ensure that the Python ecosystem will continue to evolve in a
167 smooth and sustainable manner.
168
169
170 Dask Supports Complex Applications
171 ----------------------------------
172
173 Some parallel computations are simple and just apply the same routine onto many
174 inputs without any kind of coordination. These are simple to parallelize with
175 any system.
176
177 Somewhat more complex computations can be expressed with the
178 map-shuffle-reduce pattern popularized by Hadoop and Spark.
179 This is often sufficient to do most data cleaning tasks,
180 database-style queries, and some lightweight machine learning algorithms.
181
182 However, more complex parallel computations exist which do not fit into these
183 paradigms, and so are difficult to perform with traditional big-data
184 technologies. These include more advanced algorithms for statistics or machine
185 learning, time series or local operations, or bespoke parallelism often found
186 within the systems of large enterprises.
187
188 Many companies and institutions today have problems which are
189 clearly parallelizable, but not clearly transformable into a big DataFrame
190 computation. Today these companies tend to solve their problems either by
191 writing custom code with low-level systems like MPI, ZeroMQ, or sockets and
192 complex queuing systems, or by shoving their problem into a standard big-data
193 technology like MapReduce or Spark, and hoping for the best.
194
195 Dask helps to resolve these situations by exposing low-level APIs to its
196 internal task scheduler which is capable of executing very advanced
197 computations. This gives engineers within the institution the ability to build
198 their own parallel computing system using the same engine that powers Dask's
199 arrays, DataFrames, and machine learning algorithms, but now with the
200 institution's own custom logic. This allows engineers to keep complex
201 business logic in-house while still relying on Dask to handle network
202 communication, load balancing, resilience, diagnostics, etc..
203
204
205 Dask Delivers Responsive Feedback
206 ---------------------------------
207
208 Because everything happens remotely, interactive parallel computing can be
209 frustrating for users. They don't have a good sense of how computations are
210 progressing, what might be going wrong, or what parts of their code should they
211 focus on for performance. The added distance between a user and their
212 computation can drastically affect how quickly they are able to identify and
213 resolve bugs and performance problems, which can drastically increase their
214 time to solution.
215
216 Dask keeps users informed and content with a suite of helpful diagnostic and
217 investigative tools including the following:
218
219 1. A :doc:`real-time and responsive dashboard <understanding-performance>`
220 that shows current progress, communication costs, memory use, and more,
221 updated every 100ms
222 2. A statistical profiler installed on every worker that polls each thread
223 every 10ms to determine which lines in your code are taking up the most
224 time across your entire computation
225 3. An embedded IPython kernel in every worker and the scheduler, allowing
226 users to directly investigate the state of their computation with a pop-up
227 terminal
228 4. The ability to reraise errors locally, so that they can use the traditional
229 debugging tools to which they are accustomed, even when the error happens
230 remotely
231
232
233 Links and More Information
234 --------------------------
235
236 From here you may want to read about some of our more common introductory
237 content:
238
239 - :doc:`user-interfaces`
240 - :doc:`scheduling`
241 - :doc:`spark`
242 - `Slides <https://dask.org/slides.html>`_