RethinkDB is Quietly Changing the Way We Think About Data
This past week I attended a meetup at Firebase headquarters in downtown San Francisco. No joke, there is photographic evidence.
It was a very intruiging event since the focus of the conversation was on building real-time apps, and what the future of that is going to look like. Essentially real-time apps are websites or native device applications where the interaction with other users is nearly instantaneous. For instance, if you’ve ever edited a Google Doc at the same time as someone else, you will recall that you could see changes that they made in real-time, and vice versa, and so on.
There were a lot of great speakers, including Sara Robinson from Firebase and Vincent Woo from CoderPad, but here I’m going to discuss a little about what RethinkDB demoed.
In case you’re not familiar, RethinkDB is a JSON data store similar in some ways to MongoDB. The comparison has been done to death so I won’t rehash as it’s easy to Google, I want to talk here about some new features that RethinkDB has been introducing which I find very innovative.
http as a query (HaaQ)
RethinkDB just introduced a new feature that allows users to query APIs directly from their “Data Explorer” view (which is amazingly cool by the way, you should check it out - I really wish there was a demo of it online for people to play with).
Expect to see more http-as-a-query (HaaQ) and similar features popping up in technologies the future.
Now this is really fascinating. You can set a query so that, when changes occur to it, your program gets notified.
Why is this useful? For starters, a given client can subscribe to be notified when a value changes with another user (their score increased, they got further along the map, they typed something in to the document, etc.).
feed = r.table('users').changes().run(conn) for change in feed: print change
I imagine doing this in a Goroutine or a similar type of lightweight thread.
And perhaps more interestingly, you can also subscribe to just a certain kind of event (e.g. the user’s gotten a new high score):
r.table('scores').changes().filter( lambda change: change['new_val']['score'] > change['old_val']['score'] )['new_val'].run(conn)
Nice! In the kind of industry sweep that we’re seeing towards applications which are reactive (I think of them as “springy” or “spongey”) vs. applications which are sluggish and imperative, this kind of feature will prove invaluable. I’m especially keen to see when they have it working with aggregate functions (if I recall correctly eventually it will work with any function parallelizable with Map/Reduce). Imagine getting notifications every time some kind of complex-to-calculate performance metric changed, or a real-time visualization of data that is constantly being re-crunched on the fly.
I was really impressed with Rethink’s new features and I think they represent a bold new direction for things. It would have been easy to play it safe and stick to existing features but instead Rethink is really trying to shake things up around how we think about data : storing it, querying it, and delivering it to the end user in real-time.
Until next time, stay sassy Internet.