
Horizon 1.0: a realtime, open-source JavaScript back end from RethinkDB - coffeemug
http://horizon.io/#1.0-release
======
coffeemug
Hey guys, Slava @ Rethink here. The team is really excited to launch Horizon
-- it's based on a lot of feedback from users of very different backgrounds,
and we think it will make web development dramatically easier.

I've been up for about twenty-four hours, but I'll be around to answer any
questions for the rest of the day.

~~~
android521
Hi, Slava, I was a web developer and now I am a mobile developer. Nobody is
developing web applications anymore (at least in developing countries). We are
all mobile first. How does android or ios developers take advantage of Horizon
? Can you give a few examples? How does horizon make mobile (native)
developers life easier ? web development is slowing down and mobile
development is on the rise. Mobile developers don't want to deal with backend
development. But it seems like web development is your main focus and mobile
is a second thought. Please make it the focus of your work. Meteor is useless
to us because it is optimized for web client. I hope Horizon won't fall for
this trap. Your bigger audience and potential users are android or IOS
developers. Please optimize for them and provide lots of examples to show them
how their life can be easier. Thanks.

~~~
pablasso
I'm from a developing country too and that is such an exaggeration. Maybe your
career has been focused on mobile, but no way there's overall more native
development than web.

------
kcorbitt
> Horizon is distributed as a standalone server for browser-based JavaScript
> apps. When you're ready to write custom backend code, you can load the
> Horizon modules directly in Node.js

This is key. Firebase seems great for quick prototypes, but I never built
against it because it was unclear (to me at least) how to deal with cases
where you want to leave the sandbox and add custom backend functionality that
they haven't built out for you. Horizon seems ideal -- it gives you the ease
of use of a turnkey system starting out, with the flexibility to customize
backend logic/validation later when you need to. That, plus the fact that it's
put together by the awesome RethinkDB team, makes it very interesting to me!

~~~
rapind
I've setup background workers that connect to a firebase DB to perform
business logic / backendy type stuff. It works rather well and they even have
a queue collection specifically for this type of thing. You _could_ even setup
a daemon on a VPS / EC2 that would in turn fire up AWS lambda procs (node or
w/e) to perform w/ your firebase data.

Regardless, I'm very excited to play around w/ Horizon as well.

------
lewisl9029
For apps that don't necessarily have the realtime requirement, Kinto [1] is
another really cool open-source backend solution that focuses on the offline-
first scenario. It's built by the Firefox Sync team and used in production at
Mozilla.

That said, at first glance there doesn't seem to be anything stopping anyone
from building a caching layer _on top_ of Horizon to enable offline-first
functionality. Definitely going to be keeping an eye on this as well!

EDIT: It looks like they are in fact considering offline-first support already
[2]!

[1]
[http://kinto.readthedocs.io/en/latest/overview.html](http://kinto.readthedocs.io/en/latest/overview.html)

[2]
[https://github.com/rethinkdb/horizon/issues/58](https://github.com/rethinkdb/horizon/issues/58)

~~~
cjblomqvist
Offline is much harder than one initially think. More specifically, the big
issue us that you almost certainly need a solid algorithm to solve conflicts
in order for it to work, otherwise it's quite likely you'll update your data
in a matter that is unexpected from a user perspective (assuming that two
users edit the same data). The only systems i know of which seem to handle
this gracefully is Derby/ShareJS (using operational transformation but still
lacking offline support) and Amelisa (using CRDTs and in a very early phase
development wise). If this is not built in from the ground up, I fear it's
going to be very complicated to build in.

------
avital
(Former Meteor core dev here) This is cool!

Does Horizon also solve "optimistic updates"? If so I'd love to learn more
details. For comparison, Meteor keeps a local datastore that updates
immediately when data is mutated and then reconciled with the real database.

~~~
coffeemug
The current version of Horizon doesn't do optimistic updates, but it's on the
roadmap. Check out
[https://github.com/rethinkdb/horizon/issues/23](https://github.com/rethinkdb/horizon/issues/23).
This is relatively easy because RethinkDB itself has support for notifying the
client via a feed when a particular update has landed (i.e. the RethinkDB
client can correlate the write with a feed message). It just didn't make it
into v1, but will happen soon.

------
mattste
I'm continuously impressed by Rethink. When I first used it, I ran into a few
issues with changefeeds. Since they work in the open, I could quickly look at
the Github issues and see that the fixes/features were already slated for
future release milestones. To me, that's a huge win.

------
nodesocket
Slava, Horizon looks cool, and I'm a huge fanboy of RethinkDB. However, in the
demo video you write queries client side. How do you protect against users
modifying front-end JavaScript and thus the queries?

    
    
        // ex
        this.props.horizon.order('datetime', 'descending').limit(8).watch()

~~~
jitl
This is the question I always get stuck on with these "front-end only"
frameworks. How do you prevent DoS attacks or scrapers downloading your whole
database? What is the information security model?

~~~
gkilmain
Out of the box Meteor does publish the to the browser. But I believe if you
remove the insecure package you then control what is published to the browser
e.g. usually only a subset of the db.

~~~
extrapickles
On the Meteor App I'm currently working on, we limit the data the client sees
to what they need, so while it makes a scrapers job slightly easier as they
can query the DB, they don't get anymore data than any other approach. If data
is displayed to the user they can scrape it.

Security is the same as the clients DB writes are rejected if they are
modifying fields in ways that are not permitted (eg: changing a trouble ticket
from "submitted" to "approved"). This can make some of the security easier to
audit as most of the business logic security is in one place rather than
scattered about in dozens of API calls.

While the exact technical details for these real-time DB based front ends are
different, the basic thinking is the same of never trust the client and its
costly to transmit info to the client.

The nice thing about having the DB directly on the client is that it makes
CRUD apps much easier to make as you have to build less bespoke framework to
get data to/from the client and verifying things conform to business logic. If
you are not building a CRUD app you will want to evaluate other methods for a
better fit.

------
andrewsomething
If you're looking for a way to check out Horizon and don't already have
RethinkDB up and running locally, we've put a One-Click app together over on
DigitalOcean: [https://www.digitalocean.com/community/tutorials/how-to-
use-...](https://www.digitalocean.com/community/tutorials/how-to-use-the-
horizon-one-click-install-image)

------
spdustin
From their blog post:

> _Horizon isn’t prescriptive or particularly opinionated–it’s designed to
> work well with the JavaScript frameworks that you already know and love._

It is seriously a breath of fresh air to read something like that. Bravo,
Horizon/RethinkDB team.

------
inglor
I think it's amazing that it's working with real RxJS streams for changes now
- given how Redux store now returns an observable thing, Cycle is Rx based and
Angular 2.0 uses a lot of Rx.

This guarantees that things will interop nicely with eachother and we'll be
able to use Rx all around.

~~~
coffeemug
You might want to check out lovli.js
([https://github.com/flipace/lovli.js](https://github.com/flipace/lovli.js))
-- a Horizon+Redux integration. It's _really_ cool and demonstrates how well
Horizon can interop with modern web technologies.

~~~
ginkgotree
Oh, this is exactly what I want to do with Horizon! So cool.

------
sandstrom
Although this is about horizon, if you haven't looked at RethinkdB you should
definitely check it out.

It's an awesome database for a variety of use-cases.

Personally, I think their query language + support for joins makes it much
more useable than MongoDB (which I've used quite a bit).

~~~
mercer
Agreed! I had tons of fun building my own CMS on top of RethinkDB (as well as
a logging/journal app for personal use). The only reason I ended up with a
wordpress/MySQL solution for the CMS was that building the CMS interface is a
bitch and migrating from SQL to SQL was a bit easier.

But man was I sad to leave RethinkDB for that!

------
bluecmd
Sorry, but coming from an embedded world the use of Real-time here seems
borderline offensive to me. Anyone care to explain what it means in this
context? From the dawn of computer science it has been about strict time
guarantees - and I highly doubt this is what's being referred to here.

~~~
hathym
Real-time in the web world means you don't need to hit the F5 or refresh
button.

~~~
bluecmd
Thanks!

------
manigandham
> Horizon is built on RethinkDB, a massively scalable, open-source database
> capable of millions of realtime updates per second.

Have there been any performance benchmarks or reviews of RethinkDB yet?
Especially at this scale?

~~~
dalanmiller
Hey manigandham, Dalan (dalanmiller) from RethinkDB here,

We have a performance benchmark report we did a couple months ago basically
locked and loaded to publish with accompanying scripts and data for
transparent review of our methodology. We just have been so busy with Horizon,
we had put this on the back burner. Expect to see something within the next
couple weeks when we can put some serious attention to it to ensure we do
everything just right.

In the meantime, you should check out the whitepaper by BigchainDB which uses
RethinkDB for the purposes of consistency and automatic change notifications
[1].

\- [1]
[https://www.bigchaindb.com/whitepaper/](https://www.bigchaindb.com/whitepaper/)

~~~
deepanchor
This is awesome, really looking forward to it. Rethinkdb is my goto database
for everything nowadays, and I tell everyone I meet about it.

Also: kudos to whoever is handling the artwork/marketing side of things. Love
the vector art and website designs.

~~~
TheMissingPiece
Christina from RethinkDB here (I work on all things community)... I'll pass
the kind words along to our co-founder Mike G. who worked countless hours on
the website, plus Annie Ruygt who does the artwork! It's wonderful to hear
positive feedback since we do most of our design in-house :D

~~~
mercer
I'll second deepanchor. It might seem like such a minor detail, but at least
for some people, including myself, it does matter. It signifies something.

------
lming
Hey Slava. Promising stuff! One question:

A websocket connection between client and server is great for real-time apps,
but for non real-time app, the unnecessary websocket connections create more
work for devops -- specifically DNS and load balancer. Does/will Horizon
support that clients only use the Collections API to get/set data without
websocket (for real-time sync)?

------
fuzionmonkey
Launch blog post: [http://horizon.io/blog/horizon-
launch/](http://horizon.io/blog/horizon-launch/)

------
zenlikethat
Saw a demo of this at a realtime meetup in Palo Alto and was pretty impressed.
Like everything RethinkDB does I anticipate it will be a fantastic one-two
punch of sound engineering and smooth user experience.

~~~
TheMissingPiece
Awesome! Was it Mike Seid's demo? Will have video up soon. Thanks for stopping
by our meetup :D

~~~
mercer
Could you post it here when it's up? I'd like to see it.

------
jkarneges
At last, an open source alternative to Firebase.

------
cdata
How does Horizon handle offline network conditions? Are there network + app
states (e.g., cold boot, refresh) under which users might not have access to
data?

------
kevinSuttle
I'm wondering how this works (or if it does) with GraphQL subscriptions.
[https://github.com/rethinkdb/rethinkdb/issues/3711](https://github.com/rethinkdb/rethinkdb/issues/3711)

~~~
coffeemug
There's currently no GraphQL support in Horizon, but it's on the roadmap. See
[https://github.com/rethinkdb/horizon/issues/125](https://github.com/rethinkdb/horizon/issues/125).

~~~
kevinSuttle
Thanks!

------
stemuk
Looks really promising to me, relatively similar to www.deepstream.io .
However, will there be additional clients /are they already in development by
the community? So far I only found support for vue.js and React. Polymer
elements would be pretty dope... ;)

------
jakegarelick
Congrats! I remember seeing someone from your team doing a demo at an SF
JavaScript meetup. Looks very interesting.

------
gjmveloso
Great move, RethinkDB folks!

I'm looking forward start prototyping some apps using Horizon. On a first look
seems very promising.

Congrats!

------
jmakeig
This looks really cool, but I still don’t understand how Rethink plans to cash
out their VCs, though—~$12M, according to Angel List. Cloud hosting is
trending toward zero and support/consulting only scales with people. I’m not
to trying to be (intentionally) critical; I’m genuinely curious and hoping
there is some business model innovation going on here too.

------
sqlcook
Excellent work Slava! Have been planning to migrate to RethinkDB for one of
the existing projects, great timing with Horizon :D

~~~
coffeemug
Slava @ Rethink here. Just wanted to point out that only a tiny amount of
credit for Horizon belongs to me, as most of it has been a product of tireless
work of many people (hey Marc, Dalan, Josh, Daniel, Michael, Annie, Christina,
Ryan, Mlucy, Chris, Marshall, and all the awesome beta contributors!)

This isn't false humility either -- I've been super busy with some other
aspects of RethinkDB over the past few months, so while I did have a hand in
designing and shipping Horizon, maybe less than 5% of it was my doing.

------
robotnoises
I love Firebase, but this is very exciting. Congrats on 1.0!

------
code_coyote
How well does this play with Electron
([http://electron.atom.io/](http://electron.atom.io/) ) as a front-end? I
didn't find that many references to it (mostly questions about putting them
together).

------
sgdesign
Congrats on the launch! As a long-time user of Meteor I'm always excited to
see other approaches to similar issues.

One thing that I always found a bit lacking with Meteor was pagination. The
problem in a nutshell is that the client doesn't know how much data is
potentially available on the server unless it requests it, making things like
showing "page 1 of 12" type result counts tricky (I talk more about it here:
[https://www.discovermeteor.com/blog/pagination-problems-
mete...](https://www.discovermeteor.com/blog/pagination-problems-meteor/) )

I'd be curious to know how Horizon deals with that problem?

~~~
btown
[https://github.com/aldeed/meteor-tabular](https://github.com/aldeed/meteor-
tabular) handles this with custom subscriptions, and it stays up to date by
continuously polling the collection without a limit. If you want to get more
real-time or more scalable, the problem is that if the total-count
subscriptions can't fit in Meteor's memory, every subscription would need to
re-request its count from Mongo on every incoming oplog entry, no matter
whether it ends up mattering.

Sadly, Horizon doesn't seem to support aggregate queries yet, reactive or not,
without loading the records with findAll. Theoretically, Rethink could be even
more scalable at this than Mongo, since it could use its index to only "wake
up" relevant count subscribers. But this is still on the roadmap:

[https://github.com/rethinkdb/rethinkdb/issues/3735](https://github.com/rethinkdb/rethinkdb/issues/3735)
[https://github.com/rethinkdb/rethinkdb/issues/1118](https://github.com/rethinkdb/rethinkdb/issues/1118)

Generally, it seems Horizon is very limited compared to Meteor, but it's a
great fresh start, with a much more well-thought-out and scalable
architecture, and I'm looking forward to seeing where it goes.

------
sidcool
How does this differ from Meteor?

~~~
GordyMD
See the FAQ [http://horizon.io/faq/](http://horizon.io/faq/)

For convenience, this is the section taken from it that addresses this exact
question! (I imagine other people may be thinking this)

How is Horizon different from Meteor?

Horizon has philosophical and technical differences with Meteor that will
result in vastly different developer experiences.

Horizon is a small layer on top of RethinkDB with a narrow, purpose-built API
designed to make it very easy to get started building realtime apps without
backend code. Horizon isn’t prescriptive – you can use any front-end framework
without any magic/customizations, and once your app outgrows the Horizon API
you can use any backend technology (e.g. Node.js, Python, Ruby) and any
backend framework (e.g. Rails, Express, Koa, etc.)

By contrast, Meteor is a much more prescriptive framework. Horizon is a
reasonably small component that has a very clean separation with the database
and the frontend, while Meteor is a much more monolithic experience.

Another major difference is architectural – Meteor uses a LiveQuery component
built by tailing MongoDB’s oplog. This approach is fundamentally limited –
it’s impossible to do many operations efficiently, and even the basic
functionality is extremely difficult to scale.

Horizon is built on RethinkDB, so the LiveQuery functionality is in the
database. This allows for much more sophisticated streaming operations, and
scalability is dramatically simpler because the database has all the necessary
information to allow for a scalable feeds implementation.

------
yesimahuman
Congrats on the launch, this looks like an amazing product that made immediate
sense to me. I have a feeling the Ionic community is going to be quite drawn
to this over time.

Are there any dockerized versions of this yet?

------
caleblloyd
This looks really great! Does Horizon support pluggable transport? I would
like to use Ajax paired with EventSource/SSE over HTTP/2 for bidirectional
communication instead of Web Sockets.

~~~
coffeemug
There is currently no EventSource/SSE support, but this came up a couple of
times. It should be pretty easy to add, and is currently on the roadmap
(though for now still unscheduled).

~~~
caleblloyd
Would it be a change in Horizon or in Engine.io?

------
amelius
How does access control work? For example, if I have a database containing a
table "users", and a table "files", and the files table contains a column
"owner" (pointing to the users table), then how do I prevent the client-side
database engine from accessing the files which do not belong to the user that
is currently logged in?

~~~
coffeemug
Check out the docs on security and permissions --
[http://horizon.io/docs/permissions/](http://horizon.io/docs/permissions/).
Horizon ships with a full security model that allows you to protect your data
and specify exactly what each user can and cannot access and which queries
they can run.

------
brianbi
This is super exciting. I have been playing around with it in closed beta and
I'm really impressed. Open Source FTW.

------
kevincox
The Horizon blog could really use a feed that I can subscribe too. I would
love to head about all of your future news.

~~~
mglukhovsky
Good idea! We forgot to push a RSS feed. Here it is:
[http://horizon.io/feed.xml](http://horizon.io/feed.xml)

~~~
kevincox
Thanks! I'm now subscribed :)

It would be even awesomer if you could include the articles in the feed so I
don't have to leave my cozy RSS reader :)

~~~
mglukhovsky
I agree! I'll take a look at updating our RSS feed in a bit to include the
full articles.

------
kinkdr
Congrats guys. As usual, amazing work!

------
d0m
Great thinking from the RethinkDB side. One answer I couldn't find on their
website is about the offline and optimistic update. It's _really_ tricky to
get right. Having a feed of changes is just a small part of having a robust
solution.

~~~
habitue
This is on our list :
[https://github.com/rethinkdb/horizon/issues/23](https://github.com/rethinkdb/horizon/issues/23)

The big piece remaining that will help is write timestamps in the database,
which we're going to try to land in RethinkDB 2.4. If we were controlling a
traditional MVC frontend model and had control over the objects themselves, it
would be easier to do optimistic updates. Since we're aiming to be compatible
with a lot of frontend frameworks where immutability of the model is
important, we have to carefully consider how to do it.

That being said, it's super important, so it's near the top of our priorities

------
velohx
This looks great. I wrote my first complicated Firebase app a couple weeks
ago, and looking forward to rewriting a version of it with Horizon to compare
the two.

I couldn't find it in the docs, but what is the equivalent to
Firebase.ServerValue.TIMESTAMP?

~~~
reimertz
Have you ever looked at Meteor?

~~~
velohx
I have, they're not really the same thing: [https://www.quora.com/What-is-the-
difference-between-Firebas...](https://www.quora.com/What-is-the-difference-
between-Firebase-and-Meteor)

------
absurd
@slava - how would you compare a pouchdb <-> couchdb setup vs horizon?

------
hoodoof
I'm intrigued but after reading a couple of pages it's not really clear to me
what benefits I get or really exactly what this is....

Why should I use it over my current approach ? Why is this compelling?

~~~
nileshtrivedi
Think of it as an open-source Firebase. Not only you can host your own data,
you can also do complex queries because it uses RethinkDB underneath.

------
z3t4
It would be cool to have a object oriented database with prototype support,
rather then table oriented. I think Rethink is a step in the right direction.

------
csmajorfive
This looks cool. Congrats on the launch! Is it a project or a business? Do you
intend to make money from hosting? Or something else?

~~~
coffeemug
Horizon is an open-source project. Horizon Cloud (currently in development) is
a business -- [http://horizon.io/cloud/](http://horizon.io/cloud/)

------
tacone
Looks very interesting!

You may want to make your homepage clearer, before navigating to the FAQ I did
not have a clue of what Horizon really does.

------
rvdm
I'm really excited to see a framework make security and authentication part of
it's foundation.

Amazing work Horizon team!

------
nileshtrivedi
Anyone got the chat example working?

~~~
dalanmiller
Hey @nileshtrivedi,

We pushed a hotfix a few minutes after launch that resolved this issue [1]
which you may be experiencing. You should try doing `npm update -g` if you're
still on `horizon 1.0.0`. You can check with `hz version`.

If this doesn't fix it for you, please open up an issue [2] and I will help
you out.

\- [1]
[https://github.com/rethinkdb/horizon/issues/392](https://github.com/rethinkdb/horizon/issues/392)

\- [2]
[https://github.com/rethinkdb/horizon/issues/new](https://github.com/rethinkdb/horizon/issues/new)

------
sandGorgon
so .. can one write a spreadsheet app that is able to show results reactively
in the front-end and will still reflect that same logic in some kind of
backend api ?

Kind of being able to have the same logic in my spreadsheet as well as my api
?

This could be huge!

------
ilaksh
Does Horizon handle using npm packages, requires or imports on the front end?

------
hohohoho
Do you have a timeline on when will GraphQL be supported in horizon?

------
placeybordeaux
The faq is really pretty strong.

Looks cool!

------
tacone
What's the gzipped size of the client lib?

~~~
tacone
Gzipping by hand the horizon.js served by the development server I got a 42kb
file.

