Databricks Clusters Explained: Memory, Cores, Nodes and Cost

When working with Databricks, it is essential to understand how Databricks uses cores and memory, along with its nodes, to process big data efficiently. Moreover, whether you are tuning your Spark jobs or trying to estimate the precise cluster size for a workload, understanding these components will help you optimize performance, control costs, and avoid bottlenecks.

In this article, we’ll explore:

  1. First, understanding the components of Databricks clusters
  2. Next, how memory, cores, and nodes are structured
  3. Then, how Spark partitions and processes a dataset
  4. Finally, a step-by-step example: processing 100 GB of input data

1. Databricks Cluster Basics: How Databricks Uses Cores and Memory

A Databricks cluster is a set of computation resources and configurations that Spark uses to execute your jobs. It has two main parts:

  • Driver node – Coordinates the execution of your Spark application, holds metadata, and manages the job DAG (Directed Acyclic Graph).
  • Worker nodes – Do the heavy lifting; they store partitions of data in memory/disk and run tasks in parallel.

Think of the driver as the orchestra conductor and the workers as musicians — the driver plans and coordinates, while workers execute.

2. Databricks Cores and Memory: The Building Blocks of a Cluster

Each worker node in Databricks has:

  • Cores (vCPUs) – Decide how many tasks the worker can run in parallel.
  • Memory (RAM) – Stores data partitions and intermediate results.
  • Local storage (SSD) – Used for shuffle spill or when memory is insufficient.

For example, a worker might have:

  • 8 cores
  • 64 GB RAM
  • 1 TB SSD

If your cluster has 4 worker nodes, you now have:

  • Total cores = 4 × 8 = 32 cores
  • Total memory = 4 × 64 GB = 256 GB

3. Spark Data Partitioning for Efficient Memory and Cores Usage

Apache Spark (the engine under Databricks) processes data in partitions.

  • A partition is the smallest unit of data that Spark operates on.
  • Each partition is processed by one task on one core.

By default:

  • Spark creates one partition per 128 MB of uncompressed data in Databricks runtime (this may vary based on configuration).
  • If your data is compressed, Spark will therefore estimate partition size after decompression.

Why partitions matter:

  • Too few partitions → cores idle, therefore processing becomes slower.
  • In contrast, too many partitions → task overhead and excessive shuffle.

4. The 100 GB Example: How Databricks Uses Cores and Memory

Let’s assume:

  • Input data = 100 GB (uncompressed)
  • Partition size target = 128 MB
  • Cluster has 4 workers, each with 8 cores and 64 GB RAM

Step 1: Partitioning the Data for Spark Memory and Cores

100 GB / 128 MB = 800 partitions
Because:
100 GB = 100 × 1024 MB = 102,400 MB
102,400 / 128 = 800
So if Spark uses a target split size of 128 MB (default for spark.sql.files.maxPartitionBytes), it will create ~800 input partitions.

So, Spark will create 800 partitions.

Step 2: Assigning Tasks to Cluster Cores and Memory

Each partition is processed by one core at a time; consequently, total parallelism depends on total cores.

  • Total cores in cluster = 4 workers × 8 cores = 32 cores
  • This means 32 partitions can be processed in parallel.

Step 3: Stages of Processing with Databricks Cores and Memory

Spark breaks your job into stages based on transformations:

  • Narrow transformations (like map, filter) → No shuffle between partitions.
  • Wide transformations (like groupBy, join) → Require shuffle, which can spill data to disk if memory is insufficient.

Step 4: Optimizing Spark Memory and Cores Usage

  • Each task needs memory for:
    • Data in partition
    • Intermediate shuffle data
    • Execution overhead (~10–15% of total memory)

If each worker has 64 GB RAM:

  • Some RAM is reserved for Spark overhead.
  • Therefore, let’s say ~50 GB is available for actual data.
  • At any given time, the worker runs 8 tasks in parallel (one per core), so each task has ~6–6.5 GB RAM available.

If a partition’s data + shuffle data > available RAM, Spark will spill to SSD; as a result, performance usually slows down.

Step 5: Execution Flow Using Databricks Cores and Memory

  1. Read Phase
    • Spark reads 800 partitions from the source (S3, ADLS, etc.).
    • Meanwhile, 32 partitions are processed in parallel → it takes ~25 waves to complete (800 / 32).
  2. Transformation Phase
    • Each partition is then transformed in memory.
    • If the transformation is wide (e.g., join), shuffle happens across nodes.
  3. Shuffle Phase
    • Data is redistributed between workers.
    • Consequently, memory pressure during shuffle can cause spilling.
  4. Write Phase
    • Finally, output data is written back in partitions (it can be re-partitioned before writing).

5. How to Optimize Processing for Databricks Cores and Memory

a) Right-size partitions

  • Too big → memory issues.
  • Too small → overhead.
  • Use spark.sql.files.maxPartitionBytes to control.

b) Use caching wisely

  • Cache only if data is reused multiple times; otherwise, it can waste memory.

c) Monitor shuffle

  • Optimize joins using broadcast() for small tables; similarly, avoid unnecessary wide shuffles.

d) Choose cluster size wisely

  • More cores = more parallelism.
  • More RAM = fewer spills.

6. Summary Table: 100 GB Dataset Processing with Databricks Cores and Memory

ItemValue
Dataset Size100 GB
Partition Size128 MB
Total Partitions800
Workers4
Cores per Worker8
Total Cores32
Parallel Tasks32
Processing Waves25 (800 ÷ 32)
Memory per Worker64 GB
Memory per Task~6.25 GB

Final Thoughts on How Databricks Uses Cores and Memory

In Databricks, the performance of your workload depends heavily on how partitions map to cores and how memory is managed. For a 100 GB dataset:

  • Spark will split the data into 800 partitions.
  • With 4 workers (8 cores each), you get 32 tasks running in parallel.
  • The data will therefore be processed in waves, with memory and shuffle behavior impacting performance.

Understanding this flow lets you fine-tune:

  • Cluster size for speed vs. cost.
  • Partition size for balanced execution.
  • Memory usage to reduce spilling.

If you get these basics right, you’ll unlock the true parallel power of Databricks and Spark for your big data workloads.

Discover more from Srinimf

Subscribe now to keep reading and get access to the full archive.

Continue reading