| 1 |
Deploy Dask Clusters |
| 2 |
==================== |
| 3 |
|
| 4 |
.. grid:: 1 1 2 2 |
| 5 |
|
| 6 |
.. grid-item:: |
| 7 |
:columns: 12 12 5 5 |
| 8 |
|
| 9 |
Dask works well at many scales ranging from a single machine to clusters of |
| 10 |
many machines. This page describes the many ways to deploy and run Dask, including the following: |
| 11 |
|
| 12 |
- :doc:`deploying-python` |
| 13 |
- :doc:`deploying-cloud` |
| 14 |
- :doc:`deploying-hpc` |
| 15 |
- :doc:`deploying-kubernetes` |
| 16 |
|
| 17 |
.. toctree:: |
| 18 |
:maxdepth: 1 |
| 19 |
:hidden: |
| 20 |
|
| 21 |
deploying-python.rst |
| 22 |
deploying-cloud.rst |
| 23 |
deploying-hpc.rst |
| 24 |
deploying-kubernetes.rst |
| 25 |
deploying-cli.rst |
| 26 |
deploying-ssh.rst |
| 27 |
deploying-extra.rst |
| 28 |
|
| 29 |
.. grid-item:: |
| 30 |
:columns: 12 12 7 7 |
| 31 |
|
| 32 |
.. figure:: images/dask-cluster-manager.svg |
| 33 |
|
| 34 |
An overview of cluster management with Dask distributed. |
| 35 |
|
| 36 |
.. _deployment-single-machine: |
| 37 |
|
| 38 |
Local Machine |
| 39 |
------------- |
| 40 |
|
| 41 |
You can run Dask without any setup. Dask will use threads |
| 42 |
on your local machine by default. |
| 43 |
|
| 44 |
.. code-block:: python |
| 45 |
|
| 46 |
import dask.dataframe as dd |
| 47 |
df = dd.read_csv(...) |
| 48 |
df.x.sum().compute() # This uses threads on your local machine |
| 49 |
|
| 50 |
Alternatively, you can set up a fully-featured multi-process Dask cluster on |
| 51 |
your local machine. This gives you access to multi-process computation and |
| 52 |
diagnostic dashboards. |
| 53 |
|
| 54 |
.. code-block:: python |
| 55 |
|
| 56 |
from dask.distributed import LocalCluster |
| 57 |
cluster = LocalCluster() # Fully-featured local Dask cluster |
| 58 |
client = cluster.get_client() |
| 59 |
|
| 60 |
# Dask works as normal and leverages the infrastructure defined above |
| 61 |
df.x.sum().compute() |
| 62 |
|
| 63 |
The ``LocalCluster`` cluster manager defined above is easy to use and works |
| 64 |
well on a single machine. It follows the same interface as all other Dask |
| 65 |
cluster managers, and so it's easy to swap out when you're ready to scale up. |
| 66 |
|
| 67 |
.. code-block:: python |
| 68 |
|
| 69 |
# You can swap out LocalCluster for other cluster types |
| 70 |
|
| 71 |
from dask.distributed import LocalCluster |
| 72 |
from dask_kubernetes import KubeCluster |
| 73 |
|
| 74 |
# cluster = LocalCluster() |
| 75 |
cluster = KubeCluster() # example, you can swap out for Kubernetes |
| 76 |
|
| 77 |
client = cluster.get_client() |
| 78 |
|
| 79 |
.. _deployment-options: |
| 80 |
|
| 81 |
The following resources explain how to set up Dask on a variety of local and distributed hardware. |
| 82 |
|
| 83 |
.. _cloud-deployment-options: |
| 84 |
|
| 85 |
Cloud |
| 86 |
----- |
| 87 |
|
| 88 |
Deploying on commercial cloud like AWS, GCP, or Azure is convenient because you can quickly scale out to many machines for just a few minutes, but also challenging because you need to navigate awkward cloud APIs, manage remote software environments with Docker, send data access credentials, make sure that costly resources are cleaned up, etc. The following solutions help with this process. |
| 89 |
|
| 90 |
- |Coiled|_: this commercial SaaS product handles most of the deployment pain Dask users |
| 91 |
encounter, is easy to use, and quite robust. The free tier is large enough |
| 92 |
for most individual users, even for those who don't want to engage with a |
| 93 |
commercial company. The API looks like the following. |
| 94 |
|
| 95 |
.. code-block:: python |
| 96 |
|
| 97 |
import coiled |
| 98 |
cluster = coiled.Cluster( |
| 99 |
n_workers=100, |
| 100 |
region="us-east-2", |
| 101 |
worker_memory="16 GiB", |
| 102 |
spot_policy="spot_with_fallback", |
| 103 |
) |
| 104 |
client = cluster.get_client() |
| 105 |
|
| 106 |
- `Dask Cloud Provider <https://cloudprovider.dask.org/en/latest/>`_: a pure and simple OSS solution that sets up Dask workers on cloud VMs, supporting AWS, GCP, Azure, and also other commercial clouds like Hetzner and Digital Ocean. |
| 107 |
|
| 108 |
- `Dask-Yarn <https://yarn.dask.org>`_: deploys Dask on legacy YARN clusters, such as can be set up with AWS EMR or Google Cloud Dataproc. |
| 109 |
|
| 110 |
See :doc:`deploying-cloud` for more details. |
| 111 |
|
| 112 |
.. _Coiled: https://docs.coiled.io/user_guide/index.html?utm_source=dask-docs&utm_medium=deploying |
| 113 |
.. |Coiled| replace:: **Coiled (recommended)** |
| 114 |
|
| 115 |
|
| 116 |
High Performance Computing |
| 117 |
-------------------------- |
| 118 |
|
| 119 |
Dask runs on traditional HPC systems that use a resource manager like SLURM, |
| 120 |
PBS, SGE, LSF, or similar systems, and a network file system. This is an easy |
| 121 |
way to dual-purpose large-scale hardware for analytics use cases. Dask can |
| 122 |
deploy either directly through the resource manager or through |
| 123 |
``mpirun``/``mpiexec`` and tends to use the NFS to distribute data and |
| 124 |
software. |
| 125 |
|
| 126 |
- |Dask-Jobqueue|_: interfaces directly with the |
| 127 |
resource manager (SLURM, PBS, SGE, LSF, and others) to launch many Dask |
| 128 |
workers as batch jobs. It generates batch job scripts and submits them |
| 129 |
automatically to the user's queue. This approach operates entirely with user |
| 130 |
permissions (no IT support required) and enables interactive and adaptive use |
| 131 |
on large HPC systems. It looks a little like the following: |
| 132 |
|
| 133 |
.. code-block:: python |
| 134 |
|
| 135 |
from dask_jobqueue import PBSCluster |
| 136 |
cluster = PBSCluster( |
| 137 |
cores=24, |
| 138 |
memory="100GB", |
| 139 |
queue="regular", |
| 140 |
account="my-account", |
| 141 |
) |
| 142 |
cluster.scale(jobs=100) |
| 143 |
client = cluster.get_client() |
| 144 |
|
| 145 |
- `Dask-MPI <http://mpi.dask.org/en/latest/>`_: deploys Dask on top of any system that supports MPI using ``mpirun``. It is helpful for batch processing jobs where you want to ensure a fixed and stable number of workers. |
| 146 |
- `Dask Gateway for Jobqueue <https://gateway.dask.org/install-jobqueue.html>`_: Multi-tenant, secure clusters. Once configured, users can launch clusters without direct access to the underlying HPC backend. |
| 147 |
|
| 148 |
See :doc:`deploying-hpc` for more details. |
| 149 |
|
| 150 |
.. _Dask-Jobqueue: https://jobqueue.dask.org |
| 151 |
.. |Dask-Jobqueue| replace:: **Dask-Jobqueue (recommended)** |
| 152 |
|
| 153 |
Kubernetes |
| 154 |
---------- |
| 155 |
|
| 156 |
Dask runs natively on Kubernetes clusters. This is a convenient choice when a |
| 157 |
company already has dedicated Kubernetes infrastructure set up for running |
| 158 |
other services. When running Dask on Kubernetes users should also have a plan |
| 159 |
to distribute software environments (probably with Docker), user credentials, |
| 160 |
quota management, etc. In larger organizations with mature Kubernetes |
| 161 |
deployments this is often handled by other Kubernetes services. |
| 162 |
|
| 163 |
- |Dask-Kubernetes|_: The Dask Kubernetes |
| 164 |
Operator makes the most sense for fast moving or ephemeral deployments. It |
| 165 |
is the most Kubernetes-native solution, and should be comfortable for K8s |
| 166 |
enthusiasts. It looks a little like this: |
| 167 |
|
| 168 |
.. code-block:: python |
| 169 |
|
| 170 |
from dask_kubernetes.operator import KubeCluster |
| 171 |
cluster = KubeCluster( |
| 172 |
name="my-dask-cluster", |
| 173 |
image="ghcr.io/dask/dask:latest", |
| 174 |
resources={"requests": {"memory": "2Gi"}, "limits": {"memory": "64Gi"}}, |
| 175 |
) |
| 176 |
cluster.scale(10) |
| 177 |
client = cluster.get_client() |
| 178 |
|
| 179 |
- `Dask Gateway for Kubernetes <https://gateway.dask.org/install-kube.html>`_: Multi-tenant, secure clusters. Once configured, users can launch clusters without direct access to the underlying Kubernetes backend. |
| 180 |
- `Single Cluster Helm Chart <https://artifacthub.io/packages/helm/dask/dask>`_: Single Dask cluster and (optionally) Jupyter on deployed with Helm. |
| 181 |
|
| 182 |
See :doc:`deploying-kubernetes` for more details. |
| 183 |
|
| 184 |
.. _Dask-Kubernetes: https://kubernetes.dask.org/en/latest/operator.html |
| 185 |
.. |Dask-Kubernetes| replace:: **Dask Kubernetes Operator (recommended)** |
| 186 |
|
| 187 |
.. _managed-cluster-solutions: |
| 188 |
|
| 189 |
Manual deployments (not recommended) |
| 190 |
------------------------------------ |
| 191 |
|
| 192 |
You can set up Dask clusters by hand, or with tools like SSH. |
| 193 |
|
| 194 |
- :doc:`Manual Setup <deploying-cli>`: The command line interface to set up ``dask-scheduler`` and ``dask-worker`` processes. |
| 195 |
- :doc:`deploying-ssh`: Use SSH to set up Dask across an un-managed cluster. |
| 196 |
- :doc:`Python API (advanced) <deploying-python-advanced>`: Create ``Scheduler`` and ``Worker`` objects from Python as part of a distributed Tornado TCP application. |
| 197 |
|
| 198 |
However, we don't recommend this path. Instead, we recommend that you use |
| 199 |
some common resource manager to help you manage your machines, and then deploy |
| 200 |
Dask on that system. Those options are described above. |
| 201 |
|
| 202 |
Advanced Understanding |
| 203 |
---------------------- |
| 204 |
|
| 205 |
There are additional concepts to understand if you want to improve your |
| 206 |
deployment. :doc:`This guide <deployment-considerations>` covers the main topics to consider in addition to running Dask. |