Skip to main content

How to Build a Real-Time Game Analytics Pipeline with Databricks Apps and Lakebase

Summary

  • Streaming events: ZeroBus captures player inputs as events for real-time analysis.
  • Low-latency writes: Spark Structured Streaming ingests into Lakebase, syncing to Delta for analytics.
  • Scale to zero: autoscaling enables apps to handle concurrent users with zero-cost idle time.

How to Build a Real-Time Game Analytics Pipeline with Databricks Apps and Lakebase

Watch: How to Build a Real-Time Game Analytics Pipeline with Databricks Apps and Lakebase
Talk by Andrew Sitz, Principal Solutions Architect, Aimpoint Digital; Scott Haines, Staff Developer Advocate and OSS Engineer, Databricks
To capture and analyze events from an interactive application in real time on Databricks, host the app with Databricks Apps, stream every interaction through ZeroBus and Spark Structured Streaming into Lakebase for low-latency writes, then sync to Delta for full analytics. This video builds exactly that with a retro Souls-like game called The Legend of Databricks, running as a Flask app deployed with Databricks Asset Bundles, and uses the resulting telemetry for leaderboards, player behavior analytics and reinforcement learning over gameplay.
Scott Haines and Andrew Sitz of Aimpoint Digital explain how the game runs as a Databricks App built with Flask and deployed with Databricks Asset Bundles. Every player input and state change is captured as streaming events, persisted in Lakebase with low latency, then synced to Delta for leaderboards and aggregate analysis of how players progress. They discuss game telemetry, using recorded gameplay for reinforcement learning, and why autoscaling and scale to zero let a live app handle many players. They also share how Genie Code and Claude helped build the game, and how the same approach applies to business apps.

Chapters

FAQs

How can I stream real-time events into Databricks?

Use ZeroBus to capture events from an interactive app, stream through Spark Structured Streaming into Lakebase for low-latency writes, then sync to Delta for full analytics and leaderboards.

Can I build interactive apps on Databricks?

Yes—Databricks Apps host Flask applications deployed with Databricks Asset Bundles. The Legend of Databricks game demo shows a retro Souls-like game running as a live Databricks App.

How do I analyze player behavior?

Stream every player input and state change as events into Lakebase with low latency, then sync to Delta for aggregate queries on player behavior, leaderboards and reinforcement learning.

Does scale to zero help with live apps?

Yes—autoscaling and scale to zero let a live Databricks App handle many concurrent players without incurring excessive costs when usage is low.

Full transcript

00:00 Introduction

. Well, thank you for coming. We are about to see a great session about real-time analytics with Databricks apps. Will, can you start? Awesome. Cool. Hopefully, everyone can hear us through the headphones as well. Just keep them on. If the headphones break for any reason during the session, It's going to also be like translating it as well onto the screen. So my name is Scott Haynes. I'm a developer relations engineer at Databricks.
And prior to being a developer relations engineer, I was an engineer for about 25 years, working in data and analytics. And now kind of over to Andrew. ANDREW SITZ, I'm a Databricks MVP, and also a principal solutions architect at a consulting firm that's Databricks Gold Partner called Aimpoint Digital, based out of Des Moines, Iowa. Not sure if we got anybody close to me, but sometimes I get lucky with that. Yeah, we'd really like to take this time to be inspirational in terms of art of the possible with what you can do in the business domains you serve, whether it be with internal or external stakeholders.
But first and foremost, we do have a live game and everyone is welcome. It's gonna be most optimal of an experience to play on a browser, but we have it at legendofdatabricks. com. So we just, with sessions winding down, people going through a lot of different, getting a lot of overload of content throughout the week, we thought we'd keep this lighthearted. And also there's a really cool catch that if you choose to enter your email on this game and then you visit Aimpoint over at booth 220, which is just on the other side here of the Databricks booth.
Sorry about the time out there. I'll just pull up that screen. Then if you do both of those and get scanned, you get entered in for a drawing for a Switch 2, if that's of interest. So if you missed out on some cool merch this week, you still got another shot. So why don't we even just start off? Hold on one sec. So if anybody, who here has played The Legend of Zelda? Awesome. Almost everybody, this is great. So the whole idea behind this project was to create something that brought some nostalgia and some kind of joy to our lives, which are technically pretty hectic nowadays with everything being run by agents and things like that as well.

02:36 Why build a retro game on Databricks

So while we're waiting for this to kind of go back online, I'm just going to talk to you, and then Andrew and I can kind of go back and forth about the genesis of this idea. So back in February, we were doing a Delta Lake webinar called Delta Hacks. And we're like, hacks are really neat. Being able to bring something new to table format is something super interesting. But what's more interesting than table formats is essentially what you can do with data.
And so the things that you can do with data, a lot of times, is gaming. It's not just things that are leading to AI. It's things that can also propel you forward in something that you really enjoy. So I worked in video games in a past life before coming into developer relations and working on analytics. I worked at Yahoo Games back in the day and helped build their multiplayer servers in C Sharp. For anybody who's ever played Yahoo Pool, for example, I worked on Yahoo Pool back in the day.
And so for me, video games have been a big part of my life. It's been a big part of Andrew's life as well. And so when we got together, we wanted to essentially just be able to talk more about the art of video games, but also the art of building something fun that exists kind of outside of the day-to-day and the monotony of the work that you do. And so with the screen back on, we're going to log in. And so right now we have a data engineer.
We've got a data engineer who's basically picking up prizes. Everybody who works, we work for some sort of reward. Whether that reward is something that is financial, whether it's the joy of actually releasing something and completing something, getting something online, sharing something with the open source community, it's all a journey. And so we thought about this and it's like, what are the things you need to do in life, right?
What are the obstacles you need to kind of get around to be able to get through your day to day? Does it feel like a video game? Is the path to promotion something that requires you getting through boss battles? And so the inspiration for a lot of this game came from those things that we did, right? Essentially, right now we have an ice troll. We ran into our first boss. A lot of times you'll feel like this if you're on call.
It's 3 o'clock in the morning. You feel like, well, I just lost, right? We're going to go start again. We died somewhere. It wasn't great. It's been a bad night. But you get to start over. You get to begin again. Who here plays like any kind of like Elden Ring or like Souls-like games? We got some people in the crowd that's awesome. There's a really interesting idea that comes along with a Souls-like game, which is the fact that you're going to basically die and you're going to repeat again.

05:10 Souls-like lessons for data engineering

You're going to start over and keep on doing something and hopefully do it better the next time. And so with this game, that was the idea as well. The Legend of Zelda wasn't as difficult. It wasn't one-hit kills. But if you think about a lot of the things that we do in life for engineering, sometimes it is a one-hit kill. You know, it's that one push to production that, you know, fails and breaks everything else as well.
So we keep going. We're making it past, right? We've made it through another hurdle. We've released something into production, but now we have more problems at hand as well. And so right now we're fighting an ice troll. He's a little bit harder than the other enemies we found before. But now we're getting a power up, right? We've just learned more about Delta Lake. You know, this is great. We're learning things as we go.
There's actually four different bosses in this game. if you play afterwards as well. And it's all essentially, you know, if you think about most of the kind of early games, you'd have like four big places in your map, right? Who here has played like A Link to the Past? That was for me like something that was like just so joyful as a kid. And there's also like Secret of Mana, all these things that are kind of bringing up like a lot of nostalgia, right?
Like kind of early JRPGs and things like that as well. And so Andrew and Aimpoint worked really, really hard to put a lot of this together. The only thing that I added to the whole entire project which was like bringing a PlayStation controller to the table and using like the GamePad API for HTML5. We didn't remember to bring the GamePad. It works. I posted a video of it yesterday showing that a GamePad does work with this.
And that's kind of a neat way of kind of getting through the game as well. If you're just using arrow keys, it's a lot harder to turn corners. But if you have a GamePad, turning corners is actually really cool, very flexible, and actually has a power-up for the game as well. And with that, I want to kind of bring the mic back to Andrew as well, since I've been kind of talking through our early technical difficulties.
But I want Andrew to tell more about the journey of the game as well. Yeah, absolutely. So we, yeah, I'll go back to, just go back to a couple slides here. And let me get into the presentation mode. Yeah, so everybody, in case you missed the link before, more than welcome to go to legendofdatabricks. com. So this is a Databricks app, but we have it hosted on this domain that we bought. Pretty cool that we were able to buy that kind of domain, honestly.

07:34 The Legend of Databricks: a game hosted as a Databricks App

So the, I guess the, yeah, we got some avatars. We didn't get to the point of putting sprites in the game, but you know, this can, the whole point of this conversation more so, and I don't want to do death by PowerPoint is to portray the elements, even available frameworks, capabilities you've even heard about this week like Genie Ontology, being able to surface unstructured data, all the type of context you need to even give experiences to people that help run the businesses you support.
In our case here we had some different components like DABS and No-Brainer for deployment. You chose to use an out-of-the-box framework like Flask for our app. There's a whole myriad, basically, of capabilities you can do with apps, with out-of-the-box frameworks, even if you're just doing simple form-type filling, Streamlit, other types of frameworks may work really well for that. But what's going on in this game, actually, and we can go into it a little bit more, is that we're actually generating all these events using ZeroBus with Databricks to live intercept absolutely every interaction of the game using components like Spark Structured Streaming to get this into Lake Base.

09:09 Spark Structured Streaming into Lakebase and sync back to Delta

And then we are actually doing a sync back to Delta, So we have the capability to run full-blown analytics, do things like even ranking who got the best score, like you saw on the initial screen. All those things are completely powered by Databricks components on the back end. And as you can see with this being portrayed as a map, you know what you know, and you don't know what you don't know. There might be other elements, even just in natural discussion that we have following the session, what the Data and AI Summit's all about, where you might come empowered with another approach that you could take to your business, say with this portal that you have with Databricks apps to virtually bind all these different capabilities that may not be there out of the box, to give the personalized experience, to even just not give information overload to the stakeholders that you have at hand.

10:14 Game telemetry and player behavior analytics

Yeah, I think the other thing too that's kind of interesting about that too, so if you think about telemetry, oh thank you, if you think about telemetry in general, whether it's a simple video game or it's a very complex video game like an online multiplayer game, the way that people get through the game is all kind of, you know, it's all handled now by like QA teams and also auto QA teams as well to be able to find like rough edges within a game.
And so being able to essentially have that all wrapped up under the same kind of umbrella simplifies your ability to go and actually make a game nowadays. Also with agents, anybody has the ability to make a game, unless you're making a AAA game, because then no one's going to buy it. But if you're essentially doing a presentation and you're putting a game together, all these frameworks are incredibly well documented, which means that you can throw tokens at the problem as well.
To be able to create a video game without a lot of video game capabilities, You don't have to know how the engines work. Back in the day, I wrote an engine when I was at Yahoo. It takes a long time to build an engine that's going to render correctly. There's a lot of interesting things, if anyone's familiar with double buffering, you'll essentially paint stuff off screen, overlay it into the GPU, and then be able to composite that so you have very quick frame rates.
Most of the stuff, if you think about procedural images from back in the day, you don't want to have a video game that feels slow. You want to have good frames per second. And so for a lot of that, too, a lot of times if you're running a game in dev mode, you care about the frames per second. You care about a boss with too many particles and how complicated that's going to be. And so being able to actually emit telemetry data as you're actually running through a game, or also as you're essentially doing a reinforcement learning over your game, and having essentially a remote controller playing your user, trying to actually figure out what's the best way through a game.

11:48 Using telemetry for reinforcement learning over gameplay

The other kind of analogy that I talked about too, like with gaming, and also gaming that becomes more open source as well, who here has watched Halt and Catch Fire. Holden, thank you so much. Come on, everybody. It's a fantastic show. Halt and Catch Fire has this whole entire scene where you're trying to find out who's the best engineer for a team. And one of the essential moments in the actual show is that it's one part where it's like, who got through this one level?
And people are like, we couldn't. It's like, well, who hacked through the level and found a way out? And the people who raised their hands kept their job. And so nowadays, it's really interesting to think more about the capabilities and the tools that we have to be able to propel you forward in your career as well. And all that is also on the path that you have in the same way as the hero's journey from a video game as well.
Yeah, absolutely. And even just to paint a picture of that with those frameworks, I'm not a software engineer. I'm not a game developer by trade. But if we're able to make an overkill experience like this where everyone can even be live playing it without issues, using auto scaling or scale to zero type capabilities, then it's more than capable of suiting needs that a business would throw at it. I would also just say Genie Code and Claude, even as a foundation model, you have both of those out of the box.

13:08 Autoscaling and scale to zero for live apps

Those were two of my best friends helping to make this game. Yeah, even just stepping back into kind of the thematics of the game, we just portrayed a few different obstacles that you may face. There's four different main areas if you want to max out the top score that you can get. don't really have a huge amount of other content other than that, other than we'd love to, if you want to register to get a switch to, if you want to stick around, converse about what you're thinking about doing with something like Lakebase and Databricks apps, let's have the conversation.
We're here to support. Yeah. So also, so we have about five minutes left. So if there's any questions, we can answer questions. If people want to geek out over gaming, those questions are also, you know, please ask those questions as well. But if you also want to bring this back to analytics, to AI agents, anything else like that, the floor is open. Otherwise, thank you so much for coming out. And, you know, congrats on making it through to the last day of Data Summit.
So. Awesome. any questions and also feel free to take headphones off. We can also talk up front as well. So thank you so much.

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.