MediumChoosing Cluster Configuration in Databricks — Day 81 of 100 Days of Data Engineering, AI and Azure Challenge | by Karthik | Medium
Sitemap

Choosing Cluster Configuration in Databricks — Day 81 of 100 Days of Data Engineering, AI and Azure Challenge

7 min readMar 1, 2025

--

In Databricks, a cluster is a collection of computation resources (CPU, memory, and storage) that are used to execute workloads such as data processing, machine learning, or analytics tasks. Clusters are highly configurable, allowing users to tailor them to the specific requirements of their jobs.

Key Components

Cluster Mode:

All-Purpose Clusters: These clusters can be shared by multiple users and are ideal for interactive workloads like notebooks.
Job Clusters: These clusters are created specifically for running automated jobs and are terminated after the job completes.

Cluster Type

Standard Clusters: General-purpose clusters suitable for most workloads.
High Concurrency Clusters: Optimized for multi-user environments with enhanced isolation and resource management.
Single Node Clusters: Used for lightweight workloads where only one node is required.

Node Type

The type of nodes determines the compute power (CPU cores, memory, and storage) available for the cluster. Node types vary based on cloud providers (AWS, Azure, GCP).

Driver and Worker Nodes:

Driver Node: Manages the cluster and executes the main application logic.
Worker Nodes: Perform the actual computation tasks. The number of worker nodes determines the scalability of the cluster.

Autoscaling:

Allows the cluster to dynamically adjust the number of worker nodes based on workload demands. This ensures cost efficiency and optimal performance.

Databricks Runtime (DBR)

The runtime engine that powers the cluster. It includes Apache Spark, pre-installed libraries, and optimizations for performance.

Instance Profiles and Permissions

Define access control and permissions for the cluster to interact with cloud resources like storage buckets or databases.

Cluster Policies

Predefined configurations that restrict or enforce certain settings for clusters, ensuring compliance and governance.

Databricks Runtime Engine

The Databricks Runtime (DBR) is a specialized version of Apache Spark optimized for performance, ease of use, and integration with Databricks’ ecosystem. It includes:

Apache Spark:
The core distributed computing framework that handles data processing and analytics.

Pre-installed Libraries:
Includes popular libraries for data science, machine learning, and analytics (e.g., TensorFlow, PyTorch, XGBoost, Pandas).

Performance Optimizations:
Enhanced query optimization, caching, and I/O performance improvements.

Delta Lake Integration:
Built-in support for Delta Lake, which provides ACID transactions, schema enforcement, and time travel capabilities.

MLflow Integration:
Simplifies experiment tracking, model management, and deployment for machine learning workflows.

Photon Engine:
A proprietary execution engine that accelerates Spark workloads by leveraging vectorized processing and modern CPU architectures.

Choosing a Cluster for a Job

When selecting a cluster configuration for a job, consider the following factors:

Workload Type:

Data Engineering: Choose clusters with balanced CPU and memory for ETL tasks.
Data Science/ML: Use clusters with GPUs or high-memory nodes for training models.
Interactive Analytics: Opt for high-concurrency clusters for multi-user environments.

Resource Requirements:

Estimate the CPU, memory, and storage needed based on the size of the dataset and complexity of the operations.

Cost Efficiency

Use autoscaling to minimize costs by scaling down during idle periods.
Choose spot instances for non-critical workloads to reduce costs.

Runtime Version:

Select a DBR version compatible with your libraries and frameworks.

Cluster Policies

Ensure compliance with organizational policies when configuring clusters.

Node Types

Memory-Optimized, Storage-Optimized, ML, etc.

Cloud providers offer various instance types optimized for specific workloads. Below are common categories:

1. Memory-Optimized Instances

Characteristics: High memory-to-CPU ratio.
Use Cases: Workloads requiring large in-memory datasets, such as Spark SQL queries, caching, or iterative algorithms.
AWS: r5 series (e.g., r5.2xlarge)
Azure: E series (e.g., E8s_v3)
GCP: n2-highmem series

2. Compute-Optimized Instances

Characteristics: High CPU-to-memory ratio.
Use Cases: CPU-intensive tasks like batch processing, simulations, or distributed computations.
AWS: c5 series (e.g., c5.4xlarge)
Azure: F series (e.g., F16s_v2)
GCP: n2-highcpu series

3. Storage-Optimized Instances

Characteristics: High disk throughput and large local storage.
Use Cases: Workloads involving large datasets stored locally, such as HDFS-based processing or log analysis.
AWS: i3 series (e.g., i3.8xlarge)
Azure: L series (e.g., L32s_v2)
GCP: m2-ultramem series

4. GPU-Optimized Instances

Characteristics: Equipped with powerful GPUs for parallel processing.
Use Cases: Machine learning training, deep learning, and scientific simulations.
AWS: p3 series (e.g., p3.2xlarge)
Azure: NC series (e.g., NC6s_v3)
GCP: a2-highgpu series

5. General-Purpose Instances

Characteristics: Balanced CPU, memory, and storage.
Use Cases: General-purpose workloads like small-scale ETL or exploratory data analysis.
AWS: m5 series (e.g., m5.xlarge)
Azure: D series (e.g., D4s_v3)
GCP: n2-standard series

Core and Infrastructure Details

Cores
The number of CPU cores determines the parallelism of the cluster. More cores allow for greater concurrency in task execution.
For example, an m5.4xlarge instance has 16 vCPUs, making it suitable for parallelizable workloads.

Memory
Memory size affects the ability to cache data and handle large datasets in memory.
Insufficient memory can lead to excessive spilling to disk, degrading performance.

Storage
Local storage is used for temporary files, shuffle data, and intermediate results.
Persistent storage (e.g., S3, ADLS, GCS) is used for long-term data storage.

Get Karthik’s stories in your inbox

Join Medium for free to get updates from this writer.

Networking
High-speed networking ensures efficient data transfer between nodes, especially for shuffle-heavy workloads.

Azure Virtual Machine (VM) Series Overview

Azure provides a variety of VM series tailored for specific workloads. Below is an in-depth explanation of the D , DS , and E series, along with their infrastructure details, core counts, memory sizes, and suitability for processing large datasets like a 1000 GB non-partitioned Parquet file.

1. D-Series: General-Purpose Compute

Characteristics

  • Balanced CPU-to-memory ratio.
  • Suitable for general-purpose workloads such as web servers, small databases, and development environments.
  • Ideal for tasks that do not require high memory or storage throughput.

Examples

  • D4s_v3 : 4 vCPUs, 16 GB RAM
  • D8s_v3 : 8 vCPUs, 32 GB RAM
  • D16s_v3 : 16 vCPUs, 64 GB RAM

Infrastructure Details

  • Cores : Up to 96 vCPUs (depending on the specific SKU).
  • Memory : 4 GB per vCPU.
  • Storage : Temporary SSD storage for caching and intermediate data.
  • Networking : Moderate network bandwidth.

Processing a 1000 GB File

  • The D-series is not ideal for processing a 1000 GB non-partitioned Parquet file because:
  • Limited memory per core makes it challenging to handle large datasets in memory.
  • Non-partitioned files require significant shuffle operations, which can overwhelm the available memory and disk I/O.

2. DS-Series: General-Purpose Compute with Premium Storage

Characteristics

  • Similar to the D-series but includes support for Premium SSDs .
  • Suitable for workloads requiring faster and more reliable storage, such as transactional databases or applications with frequent disk I/O.

Examples

  • DS4_v2 : 8 vCPUs, 28 GB RAM
  • DS12_v2 : 4 vCPUs, 28 GB RAM
  • DS15_v2 : 20 vCPUs, 140 GB RAM

Infrastructure Details

  • Cores : Same as D-series.
  • Memory : Slightly lower memory-to-CPU ratio compared to E-series.
  • Storage : Premium SSDs provide higher IOPS and throughput.
  • Networking : Enhanced networking capabilities.

Processing a 1000 GB File

  • The DS-series is slightly better than the D-series due to faster storage, but it still struggles with large datasets:
  • Limited memory may lead to excessive spilling to disk during shuffle operations.
  • Non-partitioned files exacerbate shuffle overhead, making this series less efficient.

3. E-Series: Memory-Optimized

Characteristics

  • High memory-to-CPU ratio.
  • Designed for memory-intensive workloads like large-scale analytics, in-memory databases, and real-time processing.

Examples

  • E8s_v3 : 8 vCPUs, 64 GB RAM
  • E16s_v3 : 16 vCPUs, 128 GB RAM
  • E32s_v3 : 32 vCPUs, 256 GB RAM

Infrastructure Details

  • Cores : Up to 128 vCPUs (depending on the SKU).
  • Memory : 8 GB per vCPU.
  • Storage : Temporary SSD storage for caching and intermediate data.
  • Networking : High network bandwidth to support data transfer between nodes.

Processing a 1000 GB File

  • The E-series is well-suited for processing a 1000 GB non-partitioned Parquet file because:
  • High memory allows for efficient caching of intermediate data, reducing shuffle overhead.
  • Faster processing of large datasets due to reduced reliance on disk I/O.
  • Suitable for Spark workloads where memory is critical for performance.

Choosing the Right VM Series for a 1000 GB Non-Partitioned Parquet File

Key Considerations

File Size and Partitioning :

  • A 1000 GB non-partitioned Parquet file requires significant shuffle operations during processing. This increases memory and disk I/O demands.

Cluster Configuration :

  • Use a cluster with sufficient memory to minimize shuffle spills to disk.
  • Enable autoscaling to dynamically adjust resources based on workload demands.

VM Series Recommendation :

  • E-Series (Memory-Optimized) : Best choice due to its high memory-to-CPU ratio, which reduces shuffle overhead and improves performance.
  • DS-Series (General-Purpose with Premium Storage) : Secondary option if cost is a constraint, but it may require additional tuning to handle shuffle operations efficiently.

Cluster Size :

  • For a 1000 GB file, consider using multiple worker nodes to distribute the workload:
  • Example: 4 x E16s_v3 (16 vCPUs, 128 GB RAM each) = 64 vCPUs, 512 GB total memory.
  • Ensure sufficient driver node memory to handle metadata and orchestration.

Runtime Optimizations :

  • Use Delta Lake to partition the data after the initial read, improving future query performance.
  • Leverage Photon Engine (if available) for accelerated query execution.

Example Cluster Configuration

Scenario : Processing a 1000 GB Non-Partitioned Parquet File

  • Driver Node : E8s_v3 (8 vCPUs, 64 GB RAM)
  • Worker Nodes : 4 x E16s_v3 (16 vCPUs, 128 GB RAM each)
  • Total Resources :
  • 72 vCPUs
  • 576 GB RAM
  • Autoscaling : Enabled to scale up to 8 worker nodes during peak load.
  • Storage : Azure Blob Storage or Azure Data Lake Storage (ADLS) for persistent storage.

Expected Performance

  • High memory ensures efficient caching of intermediate data.
  • Distributed processing across multiple nodes minimizes shuffle bottlenecks.
  • Autoscaling ensures cost efficiency by scaling down during idle periods.

For processing a 1000 GB non-partitioned Parquet file, the E-series (Memory-Optimized) is the most suitable choice due to its high memory capacity, which reduces shuffle overhead and improves performance. The DS-series can be considered as a secondary option if cost constraints are a priority, but additional tuning may be required. Always ensure proper cluster sizing and runtime optimizations to achieve optimal performance.

Conclusion

Choosing the right cluster configuration involves balancing workload requirements, cost, and performance. Memory-optimized instances are ideal for in-memory processing, while compute-optimized instances suit CPU-heavy tasks. Storage-optimized instances excel in scenarios requiring high disk throughput, and GPU-optimized instances are essential for machine learning workloads. By understanding the nuances of cluster configurations and infrastructure, you can design efficient and cost-effective solutions for your data workloads.

--

--

Karthik
Karthik

Written by Karthik⁠

| Empowering people and businesses to grow with the help of data and AI to secure cognizance that shapes the future 👨‍💻 | https://krthiak.com |