Book Image

Optimizing Databricks Workloads

By : Anirudh Kala, Anshul Bhatnagar, Sarthak Sarbahi
Book Image

Optimizing Databricks Workloads

By: Anirudh Kala, Anshul Bhatnagar, Sarthak Sarbahi

Overview of this book

Databricks is an industry-leading, cloud-based platform for data analytics, data science, and data engineering supporting thousands of organizations across the world in their data journey. It is a fast, easy, and collaborative Apache Spark-based big data analytics platform for data science and data engineering in the cloud. In Optimizing Databricks Workloads, you will get started with a brief introduction to Azure Databricks and quickly begin to understand the important optimization techniques. The book covers how to select the optimal Spark cluster configuration for running big data processing and workloads in Databricks, some very useful optimization techniques for Spark DataFrames, best practices for optimizing Delta Lake, and techniques to optimize Spark jobs through Spark core. It contains an opportunity to learn about some of the real-world scenarios where optimizing workloads in Databricks has helped organizations increase performance and save costs across various domains. By the end of this book, you will be prepared with the necessary toolkit to speed up your Spark jobs and process your data more efficiently.
Table of Contents (13 chapters)
1
Section 1: Introduction to Azure Databricks
5
Section 2: Optimization Techniques
10
Section 3: Real-World Scenarios

Working with batch processing

We will now begin learning the essential PySpark code to read, transform, and write data. Any ETL script begins with reading from a source, transforming the data, and then writing data to a sink. Let's begin with reading data from DBFS (Databricks File System) for a batch process.

Reading data

Run the following command in a new cell in a notebook:

%fs ls dbfs:/databricks-datasets/

This will display a list of sample datasets mounted by the Databricks team for learning and testing purposes. The dataset that we will be working with resides in the DBFS path, dbfs:/databricks-datasets/asa/airlines/. This dataset describes different airlines' on-time performance and consists of about 120 million records!

  1. Run the %fs ls dbfs:/databricks-datasets/asa/airlines/ command, and we can see that the path contains 22 CSV files. Their corresponding sizes are also mentioned in bytes. We will now read all the CSV files at once by specifying...