Skip to main content
Login
      • Discover
        • For App Developers
          • For Executives
            • For Startups
              • Lakehouse Architecture
                • Databricks AI Research
                • Customers
                  • Customer Stories
                  • Partners
                    • Partner Overview
                      Explore the Databricks partner ecosystem
                      • Partner Spotlight
                        Featured partner announcements
                        • Partner Program
                          Explore benefits, tiers and how to become a partner
                          • Cloud Providers
                            Databricks on AWS, Azure and GCP
                            • Find a Partner
                              Discover Databricks partners for your needs
                              • Partner Solutions
                                Find custom industry and migration solutions
                              • Databricks Data + AI Platform
                                • Platform Overview
                                  A unified platform for data, analytics and AI
                                  • Data Engineering
                                    ETL and orchestration for batch and streaming data
                                    • AI Assistant
                                      Agentic coworker for business users
                                      • Data Warehousing
                                        Serverless data warehouse for SQL analytics
                                        • Application Development
                                          Quickly build secure data and AI apps
                                          • Database
                                            Postgres for data apps and AI agents
                                            • Artificial Intelligence
                                              Build and deploy ML and GenAI applications
                                              • Governance
                                                Unified governance for all data, analytics and AI assets
                                                • Business Intelligence
                                                  Intelligent analytics for real-world data
                                                  • Security
                                                    Open agentic SIEM built for the AI era
                                                    • Customer Data Platform
                                                      Agentic CDP embedded in Databricks
                                                      • Sharing
                                                        Open data sharing for data, analytics and AI
                                                      • Integrations and Data
                                                        • Marketplace
                                                          Open marketplace for data, analytics and AI
                                                          • IDE Integrations
                                                            Build on the Lakehouse in your favorite IDE
                                                            • Partner Connect
                                                              Discover and integrate with the Databricks ecosystem
                                                            • Pricing
                                                              • Databricks Pricing
                                                                Explore product pricing, DBUs and more
                                                                • Cost Calculator
                                                                  Estimate your compute costs on any cloud
                                                                • Open Source
                                                                  • Open Source Technologies
                                                                    Learn more about the innovations behind the platform
                                                                  • Databricks for Industries
                                                                    • Telecommunications
                                                                      • Media and Entertainment
                                                                        • Financial Services
                                                                          • Public Sector
                                                                            • Healthcare & Life Sciences
                                                                              • Retail
                                                                                • Manufacturing
                                                                                  • See All Industries
                                                                                  • Cross Industry Solutions
                                                                                    • AI Agents
                                                                                      • AI Governance
                                                                                        • Cybersecurity
                                                                                          • Marketing
                                                                                          • Migration & Deployment
                                                                                            • Data Migration
                                                                                              • Forward Deployed Engineering
                                                                                              • Solution Accelerators
                                                                                                • Explore Accelerators
                                                                                                  Move faster toward outcomes that matter
                                                                                                • Learning
                                                                                                  • Training
                                                                                                    Discover curriculum tailored to your needs
                                                                                                    • Databricks Academy
                                                                                                      Sign in to the Databricks learning platform
                                                                                                      • Certification
                                                                                                        Gain recognition and differentiation
                                                                                                        • Free Edition
                                                                                                          Learn professional Data and AI tools for free
                                                                                                          • University Alliance
                                                                                                            Want to teach Databricks? See how.
                                                                                                          • Events
                                                                                                            • Data + AI Summit
                                                                                                              • Data + AI World Tour
                                                                                                                • AI Days
                                                                                                                  • Event Calendar
                                                                                                                  • Blog and Podcasts
                                                                                                                    • Databricks Blog
                                                                                                                      Explore news, product announcements, and more
                                                                                                                      • AI Blog
                                                                                                                        Explore our AI research and engineering work
                                                                                                                        • Data Brew Podcast
                                                                                                                          Let’s talk data!
                                                                                                                        • Get Help
                                                                                                                          • Customer Support
                                                                                                                            • Documentation
                                                                                                                              • Community
                                                                                                                              • Dive Deep
                                                                                                                                • Resource Center
                                                                                                                                  • Demo Center
                                                                                                                                    • Architecture Center
                                                                                                                                    • Company
                                                                                                                                      • Who We Are
                                                                                                                                        • Our Team
                                                                                                                                          • Databricks Ventures
                                                                                                                                            • Contact Us
                                                                                                                                            • Careers
                                                                                                                                              • Working at Databricks
                                                                                                                                                • Open Jobs
                                                                                                                                                • Press
                                                                                                                                                  • Awards and Recognition
                                                                                                                                                    • Newsroom
                                                                                                                                                    • Security and Trust
                                                                                                                                                      • Security and Trust
                                                                                                                                                  • Ready to get started?
                                                                                                                                                  • Get a Demo
                                                                                                                                                  • Login
                                                                                                                                                  • Contact Us
                                                                                                                                                  • Try Databricks
                                                                                                                                                  1. All blogs
                                                                                                                                                  2. /
                                                                                                                                                    Data + AI Foundations
                                                                                                                                                  • What is the difference between Apache Spark and Apache Flink?
                                                                                                                                                  • How do Spark and Flink compare feature by feature?
                                                                                                                                                  • Is Spark faster than Flink for streaming?
                                                                                                                                                  • How do I get Flink-like latency in Spark?
                                                                                                                                                  • When should I choose Apache Flink over Spark?
                                                                                                                                                  • Why does running one engine matter?
                                                                                                                                                  • Running Spark streaming on Databricks
                                                                                                                                                  • FAQs
                                                                                                                                                  • What is the difference between Apache Spark and Apache Flink?
                                                                                                                                                  • How do Spark and Flink compare feature by feature?
                                                                                                                                                  • Is Spark faster than Flink for streaming?
                                                                                                                                                  • How do I get Flink-like latency in Spark?
                                                                                                                                                  • When should I choose Apache Flink over Spark?
                                                                                                                                                  • Why does running one engine matter?
                                                                                                                                                  • Running Spark streaming on Databricks
                                                                                                                                                  • FAQs
                                                                                                                                                  Data + AI Foundations

                                                                                                                                                  Apache Spark vs Apache Flink: which should you use?

                                                                                                                                                  How Spark Real-Time Mode changes the streaming decision, with latency benchmarks, a feature comparison and a guide to choosing an engine.

                                                                                                                                                  by Databricks Staff

                                                                                                                                                  • Apache Spark is the default choice for most teams: one engine runs batch, SQL, machine learning and streaming, now down to millisecond latency with Real-Time Mode.
                                                                                                                                                  • In a Databricks benchmark, Spark Real-Time Mode matched or beat Apache Flink on p99 latency for stateless, aggregation and join workloads.
                                                                                                                                                  • Flink remains a fit for specialized cases such as very large keyed state or complex event processing on an existing Flink platform.

                                                                                                                                                  For most teams, Apache Spark™ is the better choice. Spark runs batch ETL, SQL analytics, machine learning and streaming on one engine, and Real-Time Mode now brings Spark streaming to millisecond, end-to-end latency. Apache Flink is a stream-native engine that fits specialized event-processing workloads, but choosing it usually means running a second engine next to Spark.

                                                                                                                                                  The latency gap used to be the main reason teams added Flink. With Real-Time Mode, that reason has largely gone away, and the real question becomes how many engines you want to build, operate and govern.

                                                                                                                                                  What is the difference between Apache Spark and Apache Flink?

                                                                                                                                                  Spark is a unified engine for batch, streaming, SQL and AI, and Flink is a specialized stream processor. Both are open source Apache Software Foundation projects with exactly-once processing, stateful operators and SQL APIs. The difference is scope.

                                                                                                                                                  Spark started as a batch engine and added Structured Streaming, which treats a stream as a table that keeps growing. The same DataFrame and SQL code runs as a scheduled batch job, a micro-batch stream or a Real-Time Mode stream. Flink was designed for streaming first and treats batch as a bounded stream.

                                                                                                                                                  How do Spark and Flink compare feature by feature?

                                                                                                                                                  This table compares the two engines on the dimensions that usually decide the choice.

                                                                                                                                                  DimensionApache SparkApache Flink
                                                                                                                                                  Engine scopeUnified: batch, streaming, SQL, ML and AI data prepStream-first, with batch as a bounded stream
                                                                                                                                                  Streaming latencySeconds with micro-batch, milliseconds with Real-Time ModeMilliseconds
                                                                                                                                                  Batch and large-scale ETLIndustry default for petabyte-scale batchSupported, less common in practice
                                                                                                                                                  LanguagesPython, SQL, Scala, Java, plus Go, Rust and Swift clients via Spark ConnectJava, SQL, Python (PyFlink)
                                                                                                                                                  Stateful processingAggregation, deduplication, joins, transformWithState, RocksDB state storeKeyed state, timers, disaggregated state (ForSt) in Flink 2.x
                                                                                                                                                  Complex event processingCustom logic with transformWithStateBuilt-in CEP library and SQL MATCH_RECOGNIZE
                                                                                                                                                  Machine learning and AIMLlib, feature pipelines, vector search in SQL, LLM data prepLimited native ML, usually paired with another system
                                                                                                                                                  Lakehouse integrationNative Delta Lake and Apache Iceberg read and writeConnectors for Iceberg and other formats
                                                                                                                                                  Managed optionsDatabricks, AWS EMR and Glue, Google Cloud, Microsoft FabricAWS, Confluent, Ververica and others

                                                                                                                                                  Table 1. Apache Spark and Apache Flink compared. Sources: Apache Spark Real-Time Mode docs, Apache Flink 2.0 release and Flink CEP docs.

                                                                                                                                                  Is Spark faster than Flink for streaming?

                                                                                                                                                  In Databricks' published benchmark, Spark Real-Time Mode matched Flink on stateless work and had lower p99 latency on stateful aggregation and stream-static joins. The benchmark code is public, uses customer-derived feature-computation workloads and runs at 10,000 records per second for 30 minutes, measuring Kafka input-to-output latency. Databricks summarized the results as up to 92% faster than Flink.

                                                                                                                                                  Bar chart of p99 latency: stateless 3 ms for both engines, aggregation 14 ms for Spark versus 45 ms for Flink, and stream-static join 9 ms for Spark versus 95 ms for Flink.
                                                                                                                                                  Figure 2. p99 end-to-end latency at 10,000 records per second. Spark Real-Time Mode shows its worst run and Flink shows its best run.
                                                                                                                                                  WorkloadSpark Real-Time Mode p99Apache Flink p99
                                                                                                                                                  Stateless transformation3 ms3 ms
                                                                                                                                                  Stateful aggregation14 ms45 ms
                                                                                                                                                  Stream-static join9 ms95 ms

                                                                                                                                                  How to read these numbers: Databricks ran the benchmark. Spark ran on Databricks and Flink ran on AWS Managed Service for Apache Flink 1.18. The results compare Spark's worst run with Flink's best run. Treat them as evidence for these workload patterns, and test your own pipeline before deciding.

                                                                                                                                                  Production results tell the same story. MakeMyTrip considered Flink, chose Spark Real-Time Mode to avoid a second engine and cut P50 latency to 44 ms and P99 from more than a minute to about 500 ms. Coinbase and DraftKings also run Real-Time Mode in production. For how the engine achieves this, read Breaking the microbatch barrier.

                                                                                                                                                  How do I get Flink-like latency in Spark?

                                                                                                                                                  You change the trigger. Real-Time Mode is a trigger on an existing Structured Streaming query, so the same code moves between latency tiers without a rewrite.

                                                                                                                                                  Real-Time Mode needs update output mode and reads from and writes to Kafka or a row-level foreach sink. Stateful operators arrive in open source with Apache Spark 4.3 and are generally available on Databricks today. On Databricks, it runs on classic compute or in Lakeflow Spark Declarative Pipelines. See the Real-Time Mode reference for the full support matrix.

                                                                                                                                                  REPORT

                                                                                                                                                  The agentic AI playbook for the enterprise

                                                                                                                                                  Read now
                                                                                                                                                  ai

                                                                                                                                                  When should I choose Apache Flink over Spark?

                                                                                                                                                  Flink can be the better fit for a small set of specialized streaming workloads. Consider it when most of these are true:

                                                                                                                                                  • Very large keyed state. Flink 2.x disaggregated state is built for state far larger than local disk.
                                                                                                                                                  • Complex event processing. You need pattern matching across event sequences with Flink CEP or SQL MATCH_RECOGNIZE.
                                                                                                                                                  • Event-time timers on the low-latency path. Your logic depends heavily on event-time timers, which Spark Real-Time Mode does not yet support in transformWithState.
                                                                                                                                                  • An existing Flink platform. You already run Flink in production and the stream doesn't feed batch, SQL or ML.

                                                                                                                                                  If the stream also feeds analytics, ML features or lakehouse tables, Spark avoids duplicating logic, operations and governance across two engines.

                                                                                                                                                  Decision flowchart: if streaming data also feeds batch, SQL or ML, use Apache Spark. For standalone streams, use Spark micro-batch or Real-Time Mode, with Flink as a niche fit for very large state or complex event processing.
                                                                                                                                                  Figure 3. A decision guide for choosing between Apache Spark and Apache Flink.

                                                                                                                                                  Why does running one engine matter?

                                                                                                                                                  Every second engine adds a second codebase, a second skill set and a second set of governance rules. Teams that pair Spark for batch with Flink for streaming often rewrite the same business logic twice and debug drift between them.

                                                                                                                                                  • One codebase. The same DataFrame and SQL logic runs as batch, micro-batch or Real-Time Mode.
                                                                                                                                                  • One team. Python and SQL developers build real-time pipelines without learning a new runtime.
                                                                                                                                                  • One governance model. Streaming tables and batch tables share lineage and access control in Unity Catalog.
                                                                                                                                                  • One path to AI. The same pipelines build ML features for training and online inference, as DraftKings does with transformWithState.

                                                                                                                                                  Pipelines can also be declared instead of hand-wired. Spark Declarative Pipelines manage dependencies and incremental refresh for streaming tables.

                                                                                                                                                  Running Spark streaming on Databricks

                                                                                                                                                  Databricks was founded by the original creators of Apache Spark and runs Real-Time Mode as a generally available feature, including stateful operators and transformWithState. It adds Lakeflow Spark Declarative Pipelines, Unity Catalog governance and serverless pipelines. Code written for open source Spark runs on Databricks unchanged. To get started, follow the Apache Spark tutorial: Real-Time Mode.

                                                                                                                                                  FAQs

                                                                                                                                                  Is Apache Spark faster than Apache Flink?

                                                                                                                                                  In Databricks' published benchmark, Spark Real-Time Mode matched Flink on stateless workloads and had lower p99 latency on stateful aggregation and stream-static joins. Results depend on the workload, so benchmark your own pipeline.

                                                                                                                                                  Is Spark streaming still micro-batch?

                                                                                                                                                  Not only. Spark Structured Streaming defaults to micro-batch, and Real-Time Mode processes records continuously with millisecond latency. You choose per query by setting the trigger.

                                                                                                                                                  Do I need Flink if I already use Spark?

                                                                                                                                                  For most workloads, no. Real-Time Mode gives Spark millisecond latency on the same engine you use for batch, SQL and ML, so you run one system instead of two.

                                                                                                                                                  When is Flink the better choice?

                                                                                                                                                  Flink can fit specialized workloads such as very large keyed state, complex event processing or teams that already run a Flink platform for standalone streams.

                                                                                                                                                  Can I migrate a Flink job to Spark?

                                                                                                                                                  Yes. Most Flink SQL and DataStream logic maps to Spark SQL and DataFrames in Structured Streaming, and Real-Time Mode covers the low-latency path. Start with stateless and aggregation jobs, then move stateful logic to transformWithState.

                                                                                                                                                  Get started with Real-Time Mode on Databricks

                                                                                                                                                  Get the latest posts in your inbox

                                                                                                                                                  Subscribe to our blog and get the latest posts delivered to your inbox.

                                                                                                                                                  Sign up

                                                                                                                                                  View all blogs
                                                                                                                                                  databricks logo
                                                                                                                                                  Why Databricks
                                                                                                                                                  Discover
                                                                                                                                                  • For App Developers
                                                                                                                                                  • For Executives
                                                                                                                                                  • For Startups
                                                                                                                                                  • Lakehouse Architecture
                                                                                                                                                  • Databricks AI Research
                                                                                                                                                  Customers
                                                                                                                                                  • Customer Stories
                                                                                                                                                  Partners
                                                                                                                                                  • Partner Overview
                                                                                                                                                  • Partner Program
                                                                                                                                                  • Find a Partner
                                                                                                                                                  • Partner Spotlight
                                                                                                                                                  • Cloud Providers
                                                                                                                                                  • Partner Solutions
                                                                                                                                                  Discover
                                                                                                                                                  • For App Developers
                                                                                                                                                  • For Executives
                                                                                                                                                  • For Startups
                                                                                                                                                  • Lakehouse Architecture
                                                                                                                                                  • Databricks AI Research
                                                                                                                                                  Customers
                                                                                                                                                  • Customer Stories
                                                                                                                                                  Partners
                                                                                                                                                  • Partner Overview
                                                                                                                                                  • Partner Program
                                                                                                                                                  • Find a Partner
                                                                                                                                                  • Partner Spotlight
                                                                                                                                                  • Cloud Providers
                                                                                                                                                  • Partner Solutions
                                                                                                                                                  Product
                                                                                                                                                  Databricks Data + AI Platform
                                                                                                                                                  • Platform Overview
                                                                                                                                                  • AI Assistant
                                                                                                                                                  • Application Development
                                                                                                                                                  • Artificial Intelligence
                                                                                                                                                  • Business Intelligence
                                                                                                                                                  • Customer Data Platform
                                                                                                                                                  • Data Engineering
                                                                                                                                                  • Data Warehousing
                                                                                                                                                  • Database
                                                                                                                                                  • Governance
                                                                                                                                                  • Neon
                                                                                                                                                  • Security
                                                                                                                                                  • Sharing
                                                                                                                                                  Pricing
                                                                                                                                                  • Pricing Overview
                                                                                                                                                  • Pricing Calculator
                                                                                                                                                  Open Source
                                                                                                                                                  Integrations and Data
                                                                                                                                                  • Marketplace
                                                                                                                                                  • IDE Integrations
                                                                                                                                                  • Partner Connect
                                                                                                                                                  Databricks Data + AI Platform
                                                                                                                                                  • Platform Overview
                                                                                                                                                  • AI Assistant
                                                                                                                                                  • Application Development
                                                                                                                                                  • Artificial Intelligence
                                                                                                                                                  • Business Intelligence
                                                                                                                                                  • Customer Data Platform
                                                                                                                                                  • Data Engineering
                                                                                                                                                  • Data Warehousing
                                                                                                                                                  • Database
                                                                                                                                                  • Governance
                                                                                                                                                  • Neon
                                                                                                                                                  • Security
                                                                                                                                                  • Sharing
                                                                                                                                                  Pricing
                                                                                                                                                  • Pricing Overview
                                                                                                                                                  • Pricing Calculator
                                                                                                                                                  Integrations and Data
                                                                                                                                                  • Marketplace
                                                                                                                                                  • IDE Integrations
                                                                                                                                                  • Partner Connect
                                                                                                                                                  Solutions
                                                                                                                                                  Databricks For Industries
                                                                                                                                                  • Communications
                                                                                                                                                  • Financial Services
                                                                                                                                                  • Healthcare and Life Sciences
                                                                                                                                                  • Manufacturing
                                                                                                                                                  • Media and Entertainment
                                                                                                                                                  • Public Sector
                                                                                                                                                  • Retail
                                                                                                                                                  • View All
                                                                                                                                                  Cross Industry Solutions
                                                                                                                                                  • AI Agents
                                                                                                                                                  • AI Governance
                                                                                                                                                  • Cybersecurity
                                                                                                                                                  • Marketing
                                                                                                                                                  Data Migration
                                                                                                                                                  Forward Deployed Engineering
                                                                                                                                                  Solution Accelerators
                                                                                                                                                  Databricks For Industries
                                                                                                                                                  • Communications
                                                                                                                                                  • Financial Services
                                                                                                                                                  • Healthcare and Life Sciences
                                                                                                                                                  • Manufacturing
                                                                                                                                                  • Media and Entertainment
                                                                                                                                                  • Public Sector
                                                                                                                                                  • Retail
                                                                                                                                                  • View All
                                                                                                                                                  Cross Industry Solutions
                                                                                                                                                  • AI Agents
                                                                                                                                                  • AI Governance
                                                                                                                                                  • Cybersecurity
                                                                                                                                                  • Marketing
                                                                                                                                                  Resources
                                                                                                                                                  Documentation
                                                                                                                                                  Customer Support
                                                                                                                                                  Community
                                                                                                                                                  Learning
                                                                                                                                                  • Training
                                                                                                                                                  • Certification
                                                                                                                                                  • Free Edition
                                                                                                                                                  • University Alliance
                                                                                                                                                  • Databricks Academy Login
                                                                                                                                                  Events
                                                                                                                                                  • Data + AI Summit
                                                                                                                                                  • Data + AI World Tour
                                                                                                                                                  • AI Days
                                                                                                                                                  • Event Calendar
                                                                                                                                                  Blog and Podcasts
                                                                                                                                                  • Databricks Blog
                                                                                                                                                  • AI Blog
                                                                                                                                                  • Data Brew Podcast
                                                                                                                                                  Learning
                                                                                                                                                  • Training
                                                                                                                                                  • Certification
                                                                                                                                                  • Free Edition
                                                                                                                                                  • University Alliance
                                                                                                                                                  • Databricks Academy Login
                                                                                                                                                  Events
                                                                                                                                                  • Data + AI Summit
                                                                                                                                                  • Data + AI World Tour
                                                                                                                                                  • AI Days
                                                                                                                                                  • Event Calendar
                                                                                                                                                  Blog and Podcasts
                                                                                                                                                  • Databricks Blog
                                                                                                                                                  • AI Blog
                                                                                                                                                  • Data Brew Podcast
                                                                                                                                                  About
                                                                                                                                                  Company
                                                                                                                                                  • Who We Are
                                                                                                                                                  • Our Team
                                                                                                                                                  • Databricks Ventures
                                                                                                                                                  • Contact Us
                                                                                                                                                  Careers
                                                                                                                                                  • Open Jobs
                                                                                                                                                  • Working at Databricks
                                                                                                                                                  Press
                                                                                                                                                  • Awards and Recognition
                                                                                                                                                  • Newsroom
                                                                                                                                                  Security and Trust
                                                                                                                                                  Company
                                                                                                                                                  • Who We Are
                                                                                                                                                  • Our Team
                                                                                                                                                  • Databricks Ventures
                                                                                                                                                  • Contact Us
                                                                                                                                                  Careers
                                                                                                                                                  • Open Jobs
                                                                                                                                                  • Working at Databricks
                                                                                                                                                  Press
                                                                                                                                                  • Awards and Recognition
                                                                                                                                                  • Newsroom
                                                                                                                                                  databricks logo

                                                                                                                                                  Databricks Inc.
                                                                                                                                                  160 Spear Street, 15th Floor
                                                                                                                                                  San Francisco, CA 94105
                                                                                                                                                  1-866-330-0121

                                                                                                                                                  See Careers
                                                                                                                                                  at Databricks

                                                                                                                                                  © Databricks 2026. All rights reserved. Apache, Apache Spark, Spark, the Spark Logo, Apache Iceberg, Iceberg, and the Apache Iceberg logo are trademarks of the Apache Software Foundation.

                                                                                                                                                  • Privacy Notice
                                                                                                                                                  • |Terms of Use
                                                                                                                                                  • |Modern Slavery Statement
                                                                                                                                                  • |California Privacy
                                                                                                                                                  • |Your Privacy Choices