Tinybird: Hey Steven! Welcome to Tinybird Dev Q&As. Why don’t you introduce yourself?
Steven: Hey Tinybird! My name is Steven Tey. Many of you probably know me as a developer advocate for Vercel, but I also love building things on my own like Dub and One Word Domains. You can check out most of my projects at steventey.com/projects. I live in San Francisco and am very active on Twitter @steventey.
Tinybird: Okay so tell us a little bit about Dub. What is it and why did you build it?
Steven: Sure thing! Dub is an open-source link management tool for modern marketing teams to create, share, and track short links. I started building it in September of 2021 and have been progressively scaling it up and adding features in the last year or so. I “officially” launched it in September of last year.
Dub is an open-source link management tool for modern marketing teams to create, share, and track short links.
I built Dub for a couple of reasons. The first is that being a developer advocate at Vercel, I’m always experimenting and showing off how you can use Vercel to do amazing things. For example, with Edge functions, you can run server-side logic like redirects at very close proximity to users. Link shorteners are really a great use case to demo that feature.
I also built Dub because modern marketing teams want to be able to analyze short-link performance. So from the start, I was focused on adding great link analytics so that marketers could easily track how many times those links were clicked and where those clicks originated.
And of course, I ended up using Tinybird to power those analytics.
Tinybird: Why Tinybird? What problem were you trying to solve that led you here?
Steven: The main issue before I switched Dub’s analytics to Tinybird was scale. Dub was starting to gain traction, and some Dub customers were creating links that were getting hundreds of thousands of clicks.
When I built the Dub MVP, I was using Redis Sorted Sets to store the data for all these clicks, but it wasn’t working for a couple of reasons:
- It wasn’t very flexible, so I couldn’t easily sort & filter by the various columns like location, referrer, etc.
- It was too slow! Queries were starting to take over 5 seconds, which just created a really bad UX.
I was using Redis Sorted Sets to store click data for Dub, but it was too inflexible and way too slow to query.
Tinybird: How did you hear about Tinybird?
I also collaborate a lot with chronark, another avid Tinybird user, and so between what I heard from him and what I was hearing at Vercel, Tinybird felt like a no-brainer.
Tinybird: Tell us how you’re using Tinybird to power Dub’s analytics.
Steven: For every short link you create in Dub, you can view analytics on how many clicks, when the clicks happened, and where the clicks happened (in terms of location, device, browser, OS, and referrer).
Every time somebody clicks a link hosted by Dub, it triggers an event that I send to Tinybird using the Events API. Then Tinybird stores those click events in a Data Source that is indexed by domain and short-link key. So, for example, the short link
dub.co/github is indexed by domain (
dub.co) and key (
Everytime somebody clicks a Dub shortlink, an event us sent to Tinybird using the Events API.
I then created Tinybird Pipes to create
GROUP BY queries for different columns: timestamps, country, city, device, browser, OS, referrer, etc. Those are just simple SQL queries.
Then Tinybird makes it super simple to instantly publish those queries as REST API endpoints (and add dynamic query parameters like filtered time ranges) that I can easily query from my Next.js API Route.
Tinybird makes it super simple to query clickstream data with SQL and publish those queries as low-latency, dynamic APIs that I can call from my Next.js API Route.
Tinybird: Why has Tinybird worked so well for Dub?
Steven: For one, it solved my scale problem. Since I switched from Redis to Tinybird, Dub’s analytics are about 100x faster and consume about 100x less bandwidth than with Redis.
And the pricing is great! I was on the free tier for quite a while, and even then the paid plans are very scalable and cost-effective.
To sum it up, Tinybird basically is the perfect way to quickly and inexpensively build a time-series analytics backend that I’m confident will scale.
Since I switched from Redis to Tinybird, Dub's analytics are 100x faster and consume about 100x less bandwidth.
Tinybird: What’s next for Dub?
Steven: Well, I’ve amassed quite a list of issues in the repo, and so I’m sort of just focused on churning through those. I also want to migrate Dub to Next.js App Router. Finally, I need to start marketing it more! I’ve mostly been focused on development, and it’s getting good traction so I want to get the word out!
Tinybird: How does Tinybird factor into those plans?
Steven: It’s all about scale. Tinybird is basically the entire backend for Dub. And so as I scale Dub, I’ll just keep leaning on Tinybird to scale with me. I have no concerns about that.
Tinybird: Anything you would share with would-be Tinybird users? Things to try? Things to avoid?
Steven: If you’re building any kind of SaaS or product that has an analytics feature then you should try Tinybird. I highly recommend their Screencasts to get started. Lots of great information there in some very consumable videos.
Also, check out their Starter Kits. The Web Analytics kit is a great place to start if you need to incorporate any kind of web clickstream events into your app.
Tinybird is powerful, the developer experience is amazing, and it’s super affordable.
Other than that, I just highly recommend it. Tinybird is powerful, the developer experience is amazing, and it’s super affordable. Go try it!