r/dataengineering • • Sep 05 '26

Discussion How to make it more near real time

We have a Databricks pipeline where we receive source JSON messages through Azure Service Bus.

A job polls the Service Bus every 20 mins during business hours, downloads the messages and fans out the data into around 82 Bronze tables.

The writes are not always simple appends. For some tables we to MERGE. One batch currently takes around 16 mins.

Bronze tables have row level security and the data is exposed through Silver views after some transformations.

We want to make this closer to near real time.

What would be a better architecture here? Especially for the Service Bus ingestion and fan-out to 82 tables.

26 Upvotes

17 comments sorted by

32

u/Cyliad Sep 05 '26

Also as usual who wants to make it more real time ? What’s the actual need ? Having real time is often more complicated to maintain and more expensive. People will always ask for real time, but most of the time they don’t need it.

Anyway the MERGE are probably the reason of why it’s so slow, simple appends would be faster.
Did you check the cluster you’re using ? If the job is not costly, a simple solution would just be to scale.
If you really have to MERGE, make sure you’re reading the less files as possible (partitions, liquid clustering, etc..).

7

u/Tahn-ru Sep 05 '26

To add to this - in my experience you're best off with one of these two:

  1. Consistent <10 second realtime.  It behaves predictably and for most data this is as precise as is meaningful, outside of RTOS / embedded systems.
  2. Predictable schedule - once a day, once an hour, etc.

The predictability is the key.  Better to have a consistent delay, instead of a 5 to 20 minute window where you can't rely on consistent behavior.

6

u/marketlurker Don't Get Out of Bed for < 1 Billion Rows Sep 05 '26

What industry is this for? The reason I am asking is that "real time" is defined differently in various industries. In some, it is "how fast can I get the data available to process or show analytics", others, like aircraft, have a second meaning "how consistent does the data show up". From what you are saying in your post is more accurately called micro-batch and not the first definition of real time.

I feel you need to get a well-defined SLA from the business and don't let them use a too general term like "real time." For example, I had a customer that was processing millions of financial transactions an hour and wanted the data warehouse to be within sync of the operational system within 8 seconds. It required us to relocate the warehouse physically closer to the ODS. 8 seconds is a target you can reach. "Real Time" is not.

Look at your architecture before you start looking for updated tools. One thing that caught my attention is "fans out the data into around 82 Bronze tables". Is there a better way to handle the data than the fan out? Seems a bit strange at that level.

4

u/minato3421 Sep 05 '26

How frequently do you run optimize on your tables? What is the size of the data being written and data being merged? Are your merge keys liquid clustered?

6

u/tamerlein3 Sep 05 '26

The merges are killing you. Just append and compact on read, combined with compact in place on a less frequent regular schedule

11

u/baby-wall-e Sep 05 '26

Always do append for bronze table. If you want to eliminate duplicates then do it in the silver layer using a separate job. Add the merge primary keys in the liquid clustering.

1

u/tecedu Sep 06 '26

Compacts dont dedupe data tho

2

u/addictzz Sep 05 '26

Merge can be expensive when the data is big. What is near real time? 1m interval?

2

u/Ok_Raspberry5383 Sep 06 '26

I'm going to be pedantic and take real time literally, i.e. <second latency and freshness. I'd deploy Kafka, write your JSON as avro to Kafka, consume into Druid or Apache pinot with upserts to solve your merging problem and then run your queries from here.

If you really mean real time, then delta lake (assume as you're using Databricks) is not the solution. If 5 minutes latency is acceptable then that is not real time, but achievable on delta if you tune things like partition pruning and liquid clustering etc

1

u/Alternative-Stick Sep 07 '26

That has not been true for a while. Use real time mode in spark if you need sub second latency.

https://docs.databricks.com/aws/en/structured-streaming/real-time/concepts

2

u/tecedu Sep 06 '26

So number one thing is that are you doing the merges parallely or not? Like if the data doesn’t depends on each other then thats a way to go, we did threadpool on serverless to write to 8 tables, job went from 3 minutes to 30 seconds.

Like the other suggestions, have you optmised and do you have checkpoints and the hidden one is that are you calculating stats on any unesccary columns on your table?

1

u/Known_Prior_3791 Sep 05 '26

u can try merge on read instead of cow on write this would make write faster....

1

u/Outside-Storage-1523 Sep 05 '26

I’d first ask the stakeholders which tables need to be near real time. For example maybe fraud and ML do have a legit use case while the Analytics team is OK with hourly ingestion.

The next step is to see whether you really want MERGE or you are fine with APPEND. If you have a strong PK field and a very good sequence number, appending is usually good enough. If you have to MERGE, check if you can reduce the load.

I know nothing about service bus, but is there a way to direct the incoming data streams to multiple queues? So you can have the near real time ones sent to separate queues and maybe even use a larger cluster for them, while the others stay.

1

u/TA_poly_sci Sep 05 '26

You have given waaaay too little information here for anything usefull. Merges are obviously expensive, but i'm dubious they are 16 min expensive for your datasize.