Exercise

Clusters and clients

Depending on your computer hardware and the calculation you are trying to complete, it may be faster to run it using a mixture of threads and processes. To do this, you need to set up a local cluster.

There are two ways to set up a local cluster that Dask will use. The first way is to create the local cluster and pass it to a client. This is very similar to how you would set up a client to run across a cluster of computers! The second way is to use the client directly and allow it to create the local cluster itself. This is a shortcut that works for local clusters, but not for the other types of cluster.

In this exercise, you will create clients using both methods.

Be careful when creating the cluster and clients. If you configure them incorrectly, your session may time out.

Instructions 1/2

undefined XP
  • 1
    • Import Client and LocalCluster from dask.distributed.
    • Create a LocalCluster which uses 4 threads and where each worker itself only has 1 thread.
    • Create a client which uses this cluster.
  • 2
    • Create an identical client which uses 4 threads, and where each worker itself only has 1 thread, without creating a cluster first.