Databricks

Databricks Photon Engine Explained: Speedups, Supported Workloads, and Limits

2026-03-21
更新: 2026-03-27
NicheeLab Editorial Team

Photon is Databricks' native vectorized engine — a from-scratch reimplementation of Apache Spark's execution layer in C++. It maintains compatibility with the traditional JVM-based Spark engine while applying CPU-level optimizations (SIMD, columnar batch processing) to deliver significant speedups, especially for SQL queries, DataFrame operations, and Delta Lake I/O.

This article covers which workloads Photon supports and does not support, how automatic JVM fallback behaves, how to enable Photon, and a cost comparison across Classic, Photon, and Serverless.

Photon Architecture: Why It's Fast

Traditional Spark runs as Java bytecode on the JVM. Photon replaces that execution layer with C++ and adds the following optimizations:

  • Columnar batch processing: data is laid out in memory by column rather than by row, maximizing CPU cache efficiency
  • SIMD instructions: process multiple data points per instruction (Single Instruction, Multiple Data)
  • No runtime code generation: instead of JVM Whole-Stage Code Generation, pre-compiled C++ code is used
  • Optimized memory management: bypass JVM garbage collection and control memory allocation directly

Thanks to these optimizations, Photon can deliver roughly 2-8x speedups over the traditional Spark engine, especially for CPU-bound workloads (heavy JOINs, aggregations, sorts, and filtering).

Supported Workloads

Photon delivers speedups on the workloads below. Most Spark SQL and DataFrame API operations are covered by Photon.

WorkloadPhoton supportNotes
Spark SQL (SELECT/JOIN/WHERE/GROUP BY)SupportedThe area with the largest speedup
DataFrame API (filter/groupBy/join/agg)SupportedSame optimizations as SQL
Delta Lake reads (Scan)SupportedAccelerated Parquet decoding
Delta Lake writes (INSERT/MERGE/UPDATE/DELETE)SupportedWrite path also runs on Photon
Parquet file read/writeSupportedNative Parquet reader
JOIN (Hash Join / Sort Merge Join)SupportedSubstantial impact on large JOINs
Aggregations (SUM/COUNT/AVG/MIN/MAX)SupportedFast thanks to vectorization
Sort (ORDER BY)SupportedEffective for sorting large datasets
Window functionsSupportedROW_NUMBER, RANK, etc.
Structured Streaming (micro-batch)SupportedThe batch-processing portion is accelerated by Photon

Unsupported Workloads

The workloads below do not run on Photon and automatically fall back to the JVM-based Spark engine. Even on Photon-enabled clusters, this processing runs as classic Spark.

WorkloadPhoton supportReason / Notes
RDD APINot supportedLow-level APIs are outside Photon's optimization scope
Python UDFs (standard UDFs)Not supportedRuns in a Python process, outside the C++ engine
Scala/Java UDFNot supportedCustom code running on the JVM is outside Photon's scope
Pandas UDF (Arrow-optimized UDF)Not supportedExecutes in a Python process
Structured Streaming stateful ops (mapGroupsWithState, etc.)Not supportedCustom state management is handled on the JVM side
MLlib / SparkMLNot supportedML-specific code paths are outside Photon
GraphXNot supportedGraph processing runs on the JVM
CSV/JSON file reads (partial)Partial supportLess benefit than with Parquet or Delta

Fallback Behavior: Automatic Switching for Unsupported Ops

Running an unsupported operation on a Photon-enabled cluster does not raise an error. Only that operation falls back to the JVM-based Spark engine, while the remaining Photon-supported operations continue to run on Photon.

# 例:Photon対応クラスタでUDFを含むクエリを実行
from pyspark.sql.functions import udf
from pyspark.sql.types import StringType

# このUDFはJVMフォールバックで実行される
@udf(returnType=StringType())
def custom_transform(value):
    return value.upper() + "_PROCESSED"

# filterとgroupByはPhotonで実行、UDF部分のみJVMで実行
result = (
    spark.read.format("delta").load("/mnt/silver/orders")
    .filter("amount > 100")                    # Photon
    .withColumn("label", custom_transform("region"))  # JVM fallback
    .groupBy("label").sum("amount")            # Photon
)
result.display()

When you inspect the query plan in the Spark UI, operators that ran on Photon carry a 'Photon' prefix (PhotonScan, PhotonHashAggregate, etc.). Operators without that prefix have fallen back to the JVM.

How to Enable Photon

You can enable Photon in any of the following ways. Setting it at cluster creation time is the most common approach.

  • At cluster creation, choose a Photon-enabled Databricks Runtime (e.g., 15.4 LTS Photon)
  • Enforce photon_enabled: true via a Cluster Policy
  • Specify runtime_engine: PHOTON in the cluster config via the REST API or CLI
// Cluster Policy でPhotonを強制する例
{
  "runtime_engine": {
    "type": "fixed",
    "value": "PHOTON"
  },
  "spark_version": {
    "type": "regex",
    "pattern": "15\\.4\\.x-photon-scala.*",
    "defaultValue": "15.4.x-photon-scala2.12"
  }
}

On Serverless SQL Warehouse, Photon is enabled by default — you get Photon's speedups with no additional configuration.

Classic vs Photon vs Serverless: Pricing Comparison

Deciding whether to adopt Photon requires looking at both the DBU rate and the runtime. Here's an overview of the cost profile of each compute option (actual rates vary by cloud provider and region).

Compute typeDBU rateProcessing speedTotal cost tendencyBest-fit use cases
Classic Runtime (JVM)BaselineBaselineGets expensive when runtimes are longHeavy UDF usage, RDD processing, ML
Photon RuntimeHigher than Classic2-8x faster (supported workloads)Speedups can reduce total DBU consumptionSQL/DataFrame-centric ETL, large JOINs and aggregations
Serverless SQL WarehouseHighestPhoton + instant startZero idle cost, but the highest unit rateBI queries, dashboards, ad-hoc analytics

The most reliable way to evaluate Photon's ROI is to run the same workload on Classic and Photon and compare runtime and DBU consumption. For ETL jobs dominated by JOINs, aggregations, and sorts, the shorter runtime typically outweighs Photon's higher unit price.

Best Practices for Maximum Performance

  • Rewrite custom UDFs using Spark built-in functions (UDFs fall back to the JVM)
  • Migrate from the RDD API to the DataFrame API (RDDs are not supported by Photon)
  • Store data in Delta Lake format so the optimized Photon Parquet reader can be used
  • Combine with data skipping (Z-ORDER / Liquid Clustering) to reduce I/O
  • Compact small files (OPTIMIZE) to improve scan efficiency

Key Points for the Exam

  • Photon is a C++ vectorized engine (not JVM-based)
  • RDDs and custom UDFs are not supported by Photon
  • Unsupported operations fall back to the JVM rather than raising an error
  • The difference between Photon and Serverless (Serverless = Photon + managed compute + instant start)
  • DBU rates rank Classic < Photon < Serverless, but total cost depends on runtime

Check Your Understanding

Data Engineer Associate

問題 1

You run a Spark SQL query that includes a Python custom UDF on a cluster using a Photon-enabled Databricks Runtime. Which describes the correct behavior?

  1. The entire query runs on Photon and the UDF is also accelerated
  2. Because the UDF is unsupported by Photon, the entire query errors out
  3. The UDF portion falls back to the JVM engine while the other Photon-supported operations continue to run on Photon
  4. Photon is disabled and the entire query runs on the Classic JVM engine

正解: C

When Photon detects an unsupported operation (including custom UDFs), only that operation falls back to the JVM-based Spark engine. The query as a whole does not error, and other Photon-supported operations (filter, groupBy, JOIN, etc.) continue to run on Photon.

Frequently Asked Questions

Does Photon accelerate custom UDFs?

No. Photon is a vectorized engine implemented in C++, and custom UDFs written in Python or Scala do not run on Photon. UDF processing automatically falls back to the JVM-based Spark engine. To get Photon's benefits, rewrite UDF logic using Spark SQL built-in functions or the DataFrame API wherever possible.

Does enabling Photon increase costs?

Photon-enabled DBR (Databricks Runtime) has a higher per-DBU price than Classic. However, because Photon often shortens query runtime dramatically, total DBU consumption drops and the net result is usually a cost reduction. For workloads heavy in JOINs, aggregations, and sorts, the performance gains typically outweigh the higher unit price.

How can I tell which queries are not using Photon?

Check the query execution plan in the Spark UI and look for a 'Photon' prefix on each operator. Operators such as PhotonScan or PhotonGroupingAgg run on Photon. Operators without that prefix have fallen back to the JVM. You can also tune Photon's coverage with settings like spark.databricks.photon.allDataSources.enabled.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Databricks

Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)

Complete guide to all 7 Databricks certifications — Data Eng...

Databricks

Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)

Every Databricks certification ranked by difficulty, with st...

Databricks

Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)

How to pass Databricks certifications efficiently. Official ...

Databricks

Databricks Data Engineer Associate: Complete Guide (2026)

Domain-by-domain breakdown of the Databricks Certified Data ...

Databricks

Databricks Data Engineer Professional: Complete Guide (2026)

Tactics for the Databricks Certified Data Engineer Professio...

Browse all Databricks articles (110)
© 2026 NicheeLab All rights reserved.