Race to Real-Time: Low-Latency Streaming ETL With Next-Gen OLTP-DB
Summary
- Sub-2-second latency: Achieve real-time streaming ETL with sub-2-second end-to-end latency using Apache Spark Structured Streaming and Lakebase.
- Horse racing use case: Learn how a real-time betting application handles massive data floods from dynamic sources including positions, odds, and track conditions.
- Performance optimization: Discover advanced techniques that balance streaming ingestion, data merging, and query performance on the Databricks Data and AI platform.
Race to Real-Time: Low-Latency Streaming ETL With Next-Gen OLTP-DB

Talk by Irfan Elahi, Specialist Solutions Architect, Databricks
In today’s digital economy, real-time insights and rapid responsiveness are paramount to delivering exceptional user experiences and lowering TCO. In this video, discover a pioneering approach that leverages a low-latency streaming ETL pipeline built with Apache Spark™ Structured Streaming and a next-gen OLTP-DB solution. Validated in a live customer scenario, this architecture achieves sub-2 second end-to-end latency by seamlessly ingesting streaming data from Kinesis and merging it into OLTP-DB. This breakthrough not only enhances performance and scalability but also provides a replicable blueprint for transforming data pipelines across various verticals. Join us as we delve into the advanced optimization techniques and best practices that underpin this innovation, demonstrating how Databricks next-generation solutions can revolutionize real-time data processing and unlock a myriad of new use cases in data landscape.
Here’s more to explore:
Production ready data pipelines for analytics and AI: https://www.databricks.com/solutions/data-engineering
The Big Book of Data Engineering: https://www.databricks.com/resources/ebook/big-book-data-engineering-2nd-edition
See all the product announcements from Data + AI Summit: https://www.databricks.com/events/dataaisummit-2025-announcements
Chapters
0:00Introduction and agenda1:15Context and problem statement2:52Lakebase and architecture4:02Solution design overview6:05Performance optimization10:50Live demonstration16:13Integration patterns and wrap-up
FAQs
What is Lakebase and how does it enable low-latency streaming?
Lakebase is Databricks' managed PostgreSQL offering tailored for operational and GenAI use cases. This video demonstrates how Lakebase, combined with Apache Spark Structured Streaming, enables sub-2-second end-to-end latency by seamlessly ingesting streaming data and merging it into an OLTP database.
Why is sub-2-second latency important for real-time applications?
This video uses a horse racing betting application as an example, where positions, odds, and track conditions change rapidly. Fans, leaderboards, and betting applications need instantaneous updates. This video shows how the Databricks Data and AI platform delivers the real-time responsiveness required by modern applications.
What solutions enable real-time data processing?
The Databricks Data and AI platform combines Lakebase for transactional data with Apache Spark Structured Streaming for low-latency ETL. This architecture provides end-to-end sub-2-second latency from source to destination for real-time applications.
What is the best platform for end-to-end data flow design and observability?
The Databricks Data and AI platform provides unified data flow from operational systems through Lakebase, streaming processing via Spark, and analytics on the lakehouse. Built-in observability through lineage tracking and performance metrics enables efficient end-to-end pipeline management.
What are the best databases for building low-latency applications?
Lakebase on the Databricks Data and AI platform combines the consistency guarantees of PostgreSQL with cloud-native elasticity for low-latency operational workloads. This approach reduces total cost of ownership compared to maintaining separate operational and analytical databases.
Full transcript
0:00 Introduction and agenda
Hello everyone. Thanks for joining this lightning talk. I'm a specialist solutions architect in data bricks. I hope I'm audible. Quick sound check. Thumbs up. All good. Great. Today's session is all about race to real time. fancy name but basically we'll be talking about building low latency streaming ETL solutions including the latest and greatest from data bricks using OLTBDB aka lakebase. So if you've been kept keeping tabs on DIS announcements, you would probably know that Lakebase is our managed Postgress offering tailored for operational as well as Genai use cases.
But that's not all. We'll also unpack key performance optimization techniques to supercharge your solution end to end ultimately resulting in lower TCO and reduce time to value. Forward looking statement. It is for information purposes only. and be sure to complete the surveys at the end as well. So this is how we're going to spend the next 20 minutes. We'll first set the scene and the context. We'll try to understand why all of this matter, why what's this talk all about?
What's the problem that we are trying to solve? And then we'll do a deep dive into the solution design. And we'll also unpack the key performance optimization techniques to achieve sub 2C latency. And then we'll see everything in action in a live demo. and hope everything will go well. Okay, so this all started uh through a PC at a customer end who was in a raceh horsing industry. Now imagine someone like you are someone who is responsible for running these exhilarating horse races uh which you know by the way is pretty popular in Australia and we even have a public holiday dedicated to horse races which is personally is pretty cool.
1:15 Context and problem statement
Now what happens in these races is that massive amounts of data floods in in real time. For example horse positions they change in split seconds. There are jockeyies and the track conditions they change pretty dynamically. And then we have like odds like who is going to win and what not. They fluctuate pretty rapidly as well. On the consumer side we have fans, leaderboards and betting applications. All of them need instantaneous updates.
So the challenge basically is delivering real-time insights efficiently, cost- effectively and leveraging the best of data bricks. Now historically data bricks pioneered the lakehouse paradigm unifying data links, data warehouses, breaking down the silos, democring the data and AI which is great. But there was one untapped territory or gap that is an optimal data store for OLTP use cases and this year at we have addressed that gap via lakebase.
2:52 Lakebase and architecture
So we are going from unified analytics to real time operational use cases. So all of this makes sense but how does this all work? like how does a solution seamlessly integrate with all the different components of data bricks so you have structure streaming photon unity catalog delta and now lakebas is in the mixture as well how do you design a solution so that's one of the key considerations that we'll unpack and sure once a solution design is there how to make sure that what you design is optimized to hit those very aggressive latency targets in this case it was sub 2 seconds.
So let's dive into that. Firstly for this P the source of the data was in Kinesis which you know is an sub service from AWS. So in Kinesis they were publishing all the data about the race events in real time. Now we at data bricks natively connect to Kinesis to process the events or data in streaming form. So structured streaming fundamentally is uh microbatch based which you know by the way is changing with the upcoming real-time mode but still what happens is that in each microbatch chunk of raw events are extracted from in this case Kinesis and they are processed end to end okay which makes sense.
4:02 Solution design overview
Um but the other problem comes that we all know that the raw data that is rarely consumable and we almost always need to transform it uh change it or massage it to make it consumable downstream. So in this case this P required joining it with the existing big data big delta tables to perform lookups for enrichment and augmentation and also it involved column level transformations as well. Now when all the extraction and transformations are done uh the data is written out to leg basease and in this case it is written out in two steps.
Firstly data is written out to staging table and then we perform an std type one merge from the staging table to the target table orchestrated from data. We'll see how it all works and once the data is in lake base any downstream consumer can consume it. So in this case you can have a solution design where the databics apps which were launched at D today. Uh these databics apps can integrate with lakebased to perform those singledigit millisecond super low latency queries to serve your operational use cases.
So that's how it looks like from solution design point of view how all things stack together and integrate together. But okay that is a solution design but what about the optimization? uh what are the key considerations that we need to make sure that yeah the solution is optimized it's not costing you a lot you're able to hit those latency targets and ultimately your TCO is optimized all right it all starts at the source level first we need to ensure that the amount of data that we retrieve from kinesis uh which is basically the sizes of microbatch it is deterministic and it is controlled or constraint.
6:05 Performance optimization
Now this is where I see majority of the customers make running into some challenges because they don't use the related configs to control the size of your microbatch. So for example for Kinesis it's max records per fetch. Uh for Kafka it's max offsets per trigger and for delta or autoloader in general is max bytes per trigger. Now if you don't use these defaults sorry if you don't use these configs then the defaults are either too large or too undefined then your microbatches become super big and this have a cascading negative impact on the overall performance of your solution and then there are configs as well to make sure that you fetch the data as quickly as possible and you process the fetch data as quickly as possible as well.
Next, controlling the size of micro:batch has a direct impact on the performance of your joins. Now, if you are joining, if you're using photon, then your joins will already be blazing fast. So, that's great. But you can further ensure that photon chooses the right type of join in this context that is the broadcast join in which the small streaming microbatch is copied to each exector and the need to shuffle around the big table is eliminated.
So that's one performance consideration. Now these are all these all these things are chained together. Now with the broadcast join in place another key performance optimization technique kicks in which is dynamic file pruning. This results in massive pruning of your big tables who are which are being used in your joins. So if we take a step back broadcast join it is eliminating the need to shuffle the big tables during the join but with the dynamic file pruning you are only reading the files from your object storage which are which contain data relevant for you to join.
We all know reading from object storage is an expensive process. So if we can do as much pruning as possible from object storage whether it's S3 or ADLS bring in the minimum possible data in memory to perform the computations the performance gains they become enormous. Um when it comes to data skipping at the object storage level uh we use liquid clustering which is the recommended data layout technique in data bricks potentially replacing partitioning and zordering and liquid clustering when used correctly this makes this whole data skipping business super super effective.
We use we run these streaming jobs on a cluster which is disk caching enabled. As a result of that, your big big tables they get gradually cached as the microbatches are being processed reducing the round trips to the object stores like S3 again resulting in lower TC a lower latency. We make sure that the query plan the spot that Davix uses to process your joins are optimized courtesy of updated table stats. And if you are now using predictive optimization this is optimized this is automated as well.
Now when it comes to writing out lake lakebase as I mentioned before it's done in two steps. First the staging table is overwritten and this part is parallelized um so where each partition of your streaming micro frame or microbatch is written out to the lake base so you achieve some level of good throughput there and then we perform a native merge natively in postgres via postress native constructs like insert on conflict.
We'll see a demo of that. This is orchestrated from data bricks uh and it is a single threaded process. So like driver initiates that insert or conflict thing and then when the data has reached the target table you can hook your consumers to your lake base to perform the low level the single digit millisecond queries. Now, as a result of when you put all of these pieces of the puzzle together, what you achieved and what we proved in that PC was we achieved sub2cond latency, ETL latency, end to end and we were able to hit the SLA and expectations there.
All right, let's see everything in action. All right. So this is we are now in dataex workspace and as you can see here that we are using structured streaming. We are connecting to kinesis and these are some of the configs that I were specifying controlling the size of the data that we extract from Kinesis and making sure that we read the data as quickly as possible from Kinesis and process the fetch data as quickly as possible.
10:50 Live demonstration
And then we use the for each pair function to define our transformation logic. And this is where the crux of the logic lives. We specify our connection details to lake base and all that. And this is where the key thing is. So we're doing a join between source which in this case is representing the microbatch which is coming from Kinesis with a demo registry table. If you see it in the UC then it's around 211 GB. We'll see a snapshot of that in the spark UI.
So we're joining these two tables. We're doing some lookups. We're getting some additional information like jockey name, race location, horse weight, uh doing some column level transformations. So when that data frame is ready or then we write it out to lake base and that's how it's done and this is writing to the staging table and this operation is an overwrite operation and once the staging table has been overwritten as I showed in the diagram we we initiate a merge which is in the in the world of postress it looks like insert on conflict so we are reading from the staging table and trying and writing into the target table all all orchestrated within the high cycle of one microbatch.
Okay. Just cons. Okay. Thank you for that. Um, so again quick review of that. So we are doing a join here and that data is written out to lake base and this data is written out to staging table and then we're doing a merge from the staging table to the target table uh through insert and conflict. Let's run it. And I'm using a cluster which is pretty small. It's just a one worker cluster, not huge. And we can see here we can see some stats here.
For example, it's running end to end. It's we are seeing each batch is taking around 1. 6 seconds consistently processing around 14,000 records per second which was okay for this PC. You can toggle the configs to uh increase or decrease the throughputs as required. And in here this is the OLTP I am connected to OLTP DB through Psql. So we can do a record count of the number of records that are coming through in that table.
Hopefully it will I think it's connection is for the while that refreshes. Let me just show a couple of more things in this. So we can go to Spark UI. I wanted to highlight the key. We can close it for now because the performance has been good. Hopefully it will load. That's the joy of live demos. Yeah. So let's go to SQL data frame and we can see all these different which are which is representing the joins that are happening.
Let's see a couple one of these. So for example, this is the one. Let's see what's happening under the hood in the query plan. All right. So firstly we can see here that it's using the broadcast join which is the in this case the most optimal type of join it's using and this is a big table and this this is representing that microbatch that's coming in. So these two are being joined and if you expand this the key thing to look here is the file that it has pruned.
So it has pruned two 2,000 files and it only read three files in terms of size. If I zoom in a bit, it has read it has pruned 211 GB of data and it's only read 287 MB of the data. So massive massive massive pruning of the big table only reading couple of hundred MBs of data to perform that join and that's the reason that these joins are supervised getting completed in less in around 1 second. Uh switching back to the presentation mode.
So how do you know which job has done you probably Yep. Uh it will be good for you to take the questions at the end. Will that be okay? Okay. Okay. So um so but that's not the only integration pattern. There are other integration patterns as well. So for example, you can have a data pipeline writing to delta table and then you can have an automatic S configured from the delta table to the lakebase. So you can cover majority of the use cases.
16:13 Integration patterns and wrap-up
So for example, if the data is in the delta table, you can use it for the known use cases like ML or warehousing and rare and the lake base can be used for operational and other types of use cases. So that's one. It's pretty handsoff. You just configure it once and the syncing happens pretty seamlessly at the back end. But it could be other way around as well. So you can have data pipeline writing to lake base just like we did in this case.
But if you the same data is needed in your delta lake as well then you can configure that autosync and the same phenomena will happen and you can use the data in uh for the relevant use cases. So that brings me to the end of this demo. Basically the gist is that you can build pretty powerful low latency streaming ETL solutions using lakebase. And this solution design and this pattern basically represents how you can stitch all of these different components together.
And while building these solutions, what are the key consideration techniques with respect to performance optimization to make sure that you achieve your latency goals. So I hope your uh the demo and the whole talk has been insightful and yeah, happy to take any questions now.
Learn more about the Databricks Data and AI platform.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.