News for hackers. Stuff that matters.
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @01:42PM (#10042959)
Slava @ RethinkDB here.

I'll be around all day to answer questions about the release (along with a few other engineers on our team).

We're very excited about this release -- it makes the lives of RethinkDB users dramatically better because they won't have to wake up anymore in the middle of the night in case of most hardware failures :) It also took over a year to build and test, and has been one of the most challenging engineering problems we ever had to solve.

Re:RethinkDB 2.1 is out: high availability by balls187 on Tuesday August 11, 2015 @02:36PM (#10043372)
We're seeing serious memory leaks in 2.0.4~trusty.

http://glui.me/?i=uu1gqb3son0sbnn/2015-08-11_at_11.33_AM.png...

You can see where the memory sets itself during the rethink process restart, and then it slowly climbs back up to ~3gb, despite no new data being written to the system (all our RethinkDB data is generated during deploy time).

Any pointers? I'd be happy to provide any diagnostics.

Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @02:40PM (#10043401)
Thanks for reporting this!

The image doesn't seem to load for me. Would you mind opening a GitHub issue (https://github.com/rethinkdb/rethinkdb/issues/new) with as many details as possible? We need to know a bit more about the infrastructure/workload to replicate this; once we get the info we'll get to the bottom of it ASAP.

Also feel free to e-mail me at [email protected] if you need urgent/critical support.

Re:RethinkDB 2.1 is out: high availability by mglukhovsky on Tuesday August 11, 2015 @02:39PM (#10043392)
You should open an issue on GitHub, so we can track it down: https://github.com/rethinkdb/rethinkdb/issues

It helps if you include information on your setup in the issue (for a list of helpful details, read "How to submit a bug report" here: http://rethinkdb.com/docs/crashes/).

Re:RethinkDB 2.1 is out: high availability by _yy on Wednesday August 12, 2015 @04:19AM (#10046700)
Re:RethinkDB 2.1 is out: high availability by mikegioia on Tuesday August 11, 2015 @02:20PM (#10043263)
I'm evaluating a move from CouchDB to another system purely as an easily sharded/replicated KV document store. Do you recommend Rethink for that specific use-case or is it overkill? Your docs seem to convey that this isn't really in Rethink's wheelhouse (in that RDB is more suited for querying or real-time updating).
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @02:23PM (#10043279)
RethinkDB can definitely act as a distributed key-value store (and a pretty good one). But I think the choice is highly dependent on your use-case and requirements. Could you go into a little more depth wrt your workload? (e.g. number of records, average record size, read/write ratio, expected ops/second, etc.)
Re:RethinkDB 2.1 is out: high availability by mikegioia on Tuesday August 11, 2015 @02:31PM (#10043338)
Yea of course. We're basically talking about 10/90 write/read on JSON documents ~100kb in size with very low load, probably no more than 10-20 ops/second at peak. Records now are at 200,000 projected to grow 250k/year.
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @02:35PM (#10043371)
Thanks! I'd definitely give RethinkDB a try, I think you'd be pleasantly surprised at how nice it can be for this. You'll also find that you might want to run ad-hoc queries on JSON documents (e.g. for analytics/exploratory analysis, etc.) and having ReQL at your disposal will be great for that.

IMO picking a KV store makes the most sense if you have insane performance requirements (e.g. millions of ops/second) where you need to squeeze every last drop of performance and the query layer gets in the way.

(Also if you have any questions and don't want to share more info publicly, feel free to shoot me an email -- [email protected])

Re:RethinkDB 2.1 is out: high availability by mikegioia on Tuesday August 11, 2015 @03:19PM (#10043643)
Thanks, Slava I appreciate you taking the time here.
Re:RethinkDB 2.1 is out: high availability by tracker1 on Tuesday August 11, 2015 @07:23PM (#10045060)
RethinkDB could definitely handle your load.. the advantage over CouchDB being you can do a bit more than just your value, and get indexing on other fields in your data structures. At your data load and growth, I'd be surprised if a small cluster couldn't handle your load for 8-10 years without issue... Since you're using JSON structures being able to query your data beyond keys is really nice... A document database is probably a more flexible option than a straight kv store.

If you wanted to stay closer to key/value with nice clustering and scaling options, I might suggest cassandra. To be honest, that would be overkill as a relatively small RethinkDB cluster would likely handle your load for several years without issue.

Re:RethinkDB 2.1 is out: high availability by hendzen on Tuesday August 11, 2015 @10:27PM (#10045671)
For traffic that low, you could use basically anything.
Re:RethinkDB 2.1 is out: high availability by jchrisa on Tuesday August 11, 2015 @02:27PM (#10043315)
If you like the general style of CouchDB but want scale and availability that's been proven in mission critical user facing deployments for years, we just did a blog post about moving to Couchbase http://blog.couchbase.com/2015/august/moving-couch
Re:RethinkDB 2.1 is out: high availability by mikegioia on Tuesday August 11, 2015 @02:33PM (#10043353)
That's funny, I just installed that over the weekend and was testing it out. It's really good but what sort of through me off was the high $/node licensing fee if you want the Enterprise edition. It basically starts at $5k/year/node and that's just too oppressive.

Do you use the Community Edition and if so is it generally stable / suits your needs? I didn't read your article but I'll check it out tonight.

Re:RethinkDB 2.1 is out: high availability by jchrisa on Tuesday August 11, 2015 @03:19PM (#10043640)
I'm a cofounder of Couchbase. Almost all our code is Apache 2.0, and we make the Community builds available for everyone. Enterprise builds are free to use for a small test cluster.

Unless you are a business where $5k/node looks reasonable to pay for peace of mind, you are probably fine with the Community Edition. A lot of the customers paying for Enterprise Edition are moving to Couchbase from Oracle, so they are paying less per node and running fewer nodes than they used to.

Re:RethinkDB 2.1 is out: high availability by WaltPurvis on Tuesday August 11, 2015 @05:51PM (#10044645)
As far as I can tell the Community Edition lags far behind the Enterprise Edition in stability and improvements. The latest available Community Edition is v3.0.1, released in October 2014. Since then, there has been a v3.0.2 edition released in December 2014, and a v3.0.3 released in March 2015, both of which had "critical bug fixes" according to the release notes, plus a new version, 3.1.0, released in July 2015. None of these post-3.0.1 versions are available as a Community Edition, they're only available to Enterprise customers -- is that correct?

The Couchbase web site says: "Bug fixes and new features are eventually integrated with the Community Edition (CE), but this typically takes several weeks." But from what I can tell it's not "several weeks" -- it's at least 10 months.

Am I misunderstanding something?

Re:RethinkDB 2.1 is out: high availability by cihangirb on Wednesday August 12, 2015 @01:25AM (#10046169)
Hi, it seems we missed correcting this page. It takes months not weeks to release updates to CE. The releases after 3.0.1 (3.0.2 and others) are maintenance releases with bug fixes. 3.1 is a recent release and it does contain features. We would normally push a community edition version or 3.1 in several months after the release but we are close to pushing out 4.0 and that incorporates 3.1 enhancements and more. I am expecting that we will get a 4.0 community edition out that will supersede the 3.1 release and will deliver these features to you soon.
Re:RethinkDB 2.1 is out: high availability by jchrisa on Tuesday August 11, 2015 @11:19PM (#10045847)
If you want to use the latest features without waiting for a CE build, it's getting easier to build Couchbase Server all the time. This readme is where our new hires start: https://github.com/couchbase/manifest
Re:RethinkDB 2.1 is out: high availability by tracker1 on Tuesday August 11, 2015 @07:30PM (#10045078)
Thanks for pointing this out... I don't have any experience with CouchBase/CouchDB. But I do appreciate open-source database options, especially those where the open version closely matches the commercially supported options.
Re:RethinkDB 2.1 is out: high availability by ahachete on Wednesday August 12, 2015 @03:41AM (#10046595)
If bug fixes take weeks to get to the CE, as one post below quoted from Couchbase's website, how is it possible that you say that the CE is probably fine?

I'd rather say it's pretty useless. I wouldn't run anything where a bug fix (which could be a data corruption issue, a crash...) may take weeks to be fixed.

Unless I'm missing something, my opinion is: either use the commercial version or use a different product. Please correct me if I'm wrong.

Re:RethinkDB 2.1 is out: high availability by cihangirb on Monday August 17, 2015 @11:59AM (#10073872)
Hi, if you are experiencing corruption of data with the community edition, please let us know. We will take a look at that immediately.

The paid version of the software funds the community edition for Couchbase. I cannot say our system is perfect and I am certainly happy to hear feedback on how you'd like to see community vs enterprise edition configured. Posting here is fine or I am at - [email protected]. thanks -cihan

Re:RethinkDB 2.1 is out: high availability by mikegioia on Tuesday August 11, 2015 @04:04PM (#10043967)
Ah, I apologize 'oppressive' isn't the right word. I really meant 'outside of our budget', but I'll certainly be test-driving the CE this month. Thanks again.
Re:RethinkDB 2.1 is out: high availability by eloff on Tuesday August 11, 2015 @02:23PM (#10043281)
I'm curious about "We chose to only store cluster metadata in Raft due to performance limitations imposed by distributed consensus"

I would naively assume that since you need to replicate your database to the slave servers, you need to send the WAL or changes somehow anyway. Could you elaborate on what was the problem there? I'd be surprised if it is because of a fundamental limitation of Raft (but could easily be a limitation of a Raft library!)

Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @02:28PM (#10043319)
Suppose you configure RethinkDB to store three copies of the data. When you do a write, RethinkDB will replicate the data to three nodes; that operation is roughly a matter of sending three messages to the appropriate nodes, getting the acks, and sending the ack back to the client.

If we used Raft to replicate the document, in many cases it would be a lot more chatty. If you look at the Raft paper and track all the messages that would have to go back and forth, it would dramatically increase the latency for each write. This is inherent to Raft (and any distributed consensus protocol). Unfortunately distributed consensus isn't free; you have to pay pretty heavy latency costs which would be unacceptable in production, so we couldn't just uniformly apply that to every write.

Re:RethinkDB 2.1 is out: high availability by eloff on Tuesday August 11, 2015 @02:48PM (#10043451)
OK, so it's a latency concern, which makes perfect sense.

> If we used Raft to replicate the document, in many cases it would be a lot more chatty.

I'm out of my depth here. Leader needs to send AppendEntries and slave needs to apply to persistent storage and ACK. Leader needs to wait for majority of ACKS before responding to the client. That's the same as your three-node replication scenario, so what am I missing here? Does Rethink db relax consistency guarantees in some cases to achieve better latency?

It's not your job to educate me on Raft, I appreciate your being patient with me, but feel free to opt out of this conversation anytime you please.

Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @03:05PM (#10043558)
> Leader needs to send AppendEntries and slave needs to apply to persistent storage and ACK. Leader needs to wait for majority of ACKS before responding to the client. That's the same as your three-node replication scenario, so what am I missing here?

A couple of things -- the payload in Raft tends to be much higher (though it could probably be fixed with sufficient engineering effort), and in some scenarios this process would have to happen multiple times during netsplits (which may or may not be ok).

RethinkDB doesn't relax consistency guarantees; we implement them in a different way. Check out http://rethinkdb.com/docs/consistency/ for more details.

I'm a bit busy today, but this is a really interesting question. I'll see if we can do a technical blog post on this and go into all the details in depth.

Re:RethinkDB 2.1 is out: high availability by teraflop on Tuesday August 11, 2015 @05:20PM (#10044476)
The parent comment asked:

> Does Rethink db relax consistency guarantees in some cases to achieve better latency?

You responded:

> RethinkDB doesn't relax consistency guarantees; we implement them in a different way.

But the page you linked says:

> `single` returns values that are in memory (but not necessarily written to disk) on the primary replica. This is the default.

> `majority` will only return values that are safely committed on disk on a majority of replicas. This requires sending a message to every replica on each read, so it is the slowest but most consistent.

which seems to imply that the default settings sacrifice consistency for better latency. Can you (or someone else, if you're busy) clarify?

Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @05:56PM (#10044689)
Sorry, this is a bit nuanced and my comment was unclear.

We implement a variety of modes for reading and writing that allow the user to select different trade-offs for consistency and performance. By default: writes are always safe; reads are safe when the cluster is healthy, but can sometimes have anomalies in failure scenarios. You can also do `majority` reads which are completely safe even during failure scenarios, but are slower.

However note, that the default read mode isn't an "anything can happen" implementation. The guarantees are precisely defined, and 2.1 passes all tests in a large variety of failure scenarios with respect to these guarantees.

My comment about not relaxing consistency guarantees was meant in a slightly different context. The OP was talking write transactions (and implementing individual writes with Raft vs. using a different way), and I pointed out that we don't relax consistency guarantees for writes despite not using Raft.

I realize my comment was confusing -- sorry about that; I didn't mean to mislead.

Re:RethinkDB 2.1 is out: high availability by timmaxw on Tuesday August 11, 2015 @03:35PM (#10043746)
tim@rethinkdb here. coffeemug's earlier comment is not quite right. There were two reasons why we went for this hybrid approach where Raft handles metadata but not documents: because of how Raft interacts with the storage system, and because of sharding.

In the Raft protocol, the leader sends AppendEntries; the follower writes the log entries to persistent storage, but doesn't apply them to the state machine yet; the leader sends another AppendEntries with a higher commit index; and then the follower applies the changes to the state machine. In RethinkDB's case, the "state machine" is the B-tree we store on disk. One of the guarantees we provide is that if the server acknowledges a write to the client, then all future reads should see that write; and we perform reads by querying the B-tree. So we can't acknowledge writes until they've been actually written to the B-tree, and we can't start writing to the B-tree until after the write has been committed via Raft. So that's where the latency would come from if we were using Raft to manage individual documents. We considered a couple of ways to work around this. One would be to make reads check both the B-tree and the Raft log; but that makes the read logic much more complicated. Another would be to start writing to the B-tree as soon as we put the write in the Raft log. The problem is that Raft expects to be able to roll back parts of its log at any time, and our storage engine's MVCC capabilities aren't good enough for that. The hybrid approach allows us to have good latency without major rewrites of the existing storage engine.

The other reason is that RethinkDB allows tables to be split into shards, and the number of shards can be changed while the databases is running and accepting queries. We considered having one Raft instance per shard, but we would have needed to modify the Raft algorithm to allow splitting and merging Raft instances while they are running and accepting queries. (This is approximately what CockroachDB is doing [1].) But the Raft algorithm is really tricky to get right even when you're not trying to modify it, and we wanted to stick as closely as possible to the official algorithm to minimize bugs. The approach we ended up going with allows us to have the performance and convenience of live resharding without having to modify the Raft algorithm.

In response to your question about consistency guarantees: RethinkDB gives users several options for trading off consistency and latency. The default is to acknowledge writes only once they're safely on disk on a majority of replicas, but to perform reads only on the primary replica (leader). This doesn't give perfect consistency; if the leader fails over, reads that hit the database around the time of the failover might see outdated data, or they might read writes that were rolled back as part of the failover. Unfortunately, the only way to get stronger consistency guarantees is to wait for a majority of replicas to acknowledge the read, which makes performance much worse. We offer a safe-but-slow mode for reads, but it's not the default because the performance is so bad. We also offer fast-but-unsafe modes for writes, for users that want better latency and are OK with losing the last few writes in the event of a failover. See the documentation [2] for more information.

[1] http://www.cockroachlabs.com/blog/scaling-raft/

[2] http://rethinkdb.com/docs/consistency/

Re:RethinkDB 2.1 is out: high availability by eloff on Tuesday August 11, 2015 @04:19PM (#10044068)
Thank you for the detailed and fascinating response! I read and re-read it to make sure I didn't miss any details. I understand now why you chose to handle only metadata with Raft. I really appreciate the time you took to explain not only your reasoning, but your reasoning through the alternatives as well. Databases and distributed systems are both fascinating, and very challenging, problem domains. Combining them is even more challenging.
Re:RethinkDB 2.1 is out: high availability by otterley on Tuesday August 11, 2015 @02:33PM (#10043352)
Have you Jepsen-tested the new 2.1 release? If so, what were its results?
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @02:38PM (#10043384)
Yes. We did months of internal tests, and 2.1 passes Jepsen tests. We'd love for Kyle to do his own analysis once he gets some free time. In the meantime there is a bit more info on this in the blog post under "testing" headline.
Re:RethinkDB 2.1 is out: high availability by teraflop on Tuesday August 11, 2015 @05:11PM (#10044420)
Based on this pull request: https://github.com/aphyr/jepsen/pull/70

Am I correct in understanding that the tests only pass in the "safe-but-slow" configuration that timmaxw described (https://news.ycombinator.com/item?id=10043746) and not in the default "fast-but-unsafe" configuration?

Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @05:23PM (#10044498)
AFAIK the tests account for that and test different scenarios (i.e. not all unsafe modes are created equal; a product can still fail the relevant test cases in fast-but-unsafe mode). We pass the fast-but-unsafe tests (i.e. we fulfill the guarantees you'd expect in that mode), and also pass the stricter guarantees in the slow-but-safe mode.

However you're right that we don't pass stricter guarantees in fast-but-unsafe mode (but I'm not aware of any products in the space that do).

Re:RethinkDB 2.1 is out: high availability by teraflop on Tuesday August 11, 2015 @05:31PM (#10044552)
Good to know. The test code in that pull request only tests the case where read_mode="majority", so I'm looking forward to seeing the other scenarios when they become available.
Re:RethinkDB 2.1 is out: high availability by danielmewes on Tuesday August 11, 2015 @06:12PM (#10044755)
We only submitted the configuration that passed all scenarios, but tested some of the others internally. You generally don't get guaranteed linearizability of operations under network partitions in any of the faster configurations.
Re:RethinkDB 2.1 is out: high availability by kenko on Tuesday August 11, 2015 @03:35PM (#10043743)
Can one commission Jepsen analyses from Kyle? Or is it more a matter of hoping he'll do it on his own?
Re:RethinkDB 2.1 is out: high availability by hipsterrific on Tuesday August 11, 2015 @02:29PM (#10043325)
I'm excited to work with RethinkDB on my pet projects. Glad to hear you guys beefed up failovers, that's a big deal in a lot of places. ;)
Re:RethinkDB 2.1 is out: high availability by chucksmash on Tuesday August 11, 2015 @02:45PM (#10043433)
It's a joy to use for side projects! I'm using it as the datastore in a web app for learning that automatically generates quiz questions from user-provided data. Integrating with it using the Python API has thus far been dead simple.
Re:RethinkDB 2.1 is out: high availability by ukd1 on Tuesday August 11, 2015 @01:57PM (#10043081)
Awesome work guys. Could you give some details on what you're most proud of and what was most challenging?
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @02:07PM (#10043172)
There are two parts to this that are really challenging -- designing a robust system (since there are a million different edge cases that can happen in a distributed system), and designing an intuitive interface so that the database does the right thing out of the box, is configurable if users want that, and is actually easy to configure in practice.

Doing each thing independently is hard; doing both of them together in one system is really really hard. I'm particularly proud of how nicely everything clicks together, and how elegant the administration API is. It seems very simple and is extremely powerful; getting that right took many iterations over the course of a year.

Re:RethinkDB 2.1 is out: high availability by jaz46 on Tuesday August 11, 2015 @01:59PM (#10043101)
Are you interviewing the RethinkDB team here, Russell? ;)
Re:RethinkDB 2.1 is out: high availability by karlgrz on Tuesday August 11, 2015 @02:09PM (#10043186)
Fantastic news, this looks great! Just a quick question, can I update individual nodes one at a time in my running cluster, or do they all need to be on 2.1 at the same time?
Re:RethinkDB 2.1 is out: high availability by danielmewes on Tuesday August 11, 2015 @02:12PM (#10043213)
Unfortunately 2.0 nodes cannot connect to 2.1 nodes and vice versa, so depending on your table configuration you might need to update all of them at the same time.
Re:RethinkDB 2.1 is out: high availability by karlgrz on Tuesday August 11, 2015 @02:59PM (#10043524)
No problem, was just curious. Thanks!
Re:RethinkDB 2.1 is out: high availability by k__ on Tuesday August 11, 2015 @01:57PM (#10043085)
A bit off-topic, but can you recommend any RethinkDB SaaS providers?
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @01:59PM (#10043104)
Many of our users use compose.io, and it's pretty solid. I highly recommend them.
Re:RethinkDB 2.1 is out: high availability by fweespeech on Tuesday August 11, 2015 @05:45PM (#10044618)
How is the WAN replication performance for a cluster in 3 DCs with ~100-200ms RTT? Or is WAN replication performance on the todo list?
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @05:59PM (#10044702)
WAN replication works out of the box, and RethinkDB was designed with multidatacenter setups in mind. Feel free to email me at [email protected] if you need to discuss a specific use case.
Re:RethinkDB 2.1 is out: high availability by kevinbowman on Tuesday August 11, 2015 @06:44PM (#10044912)
Congrats on the release! Could you update the docker hub image? I'm impatient to try it...
Re:RethinkDB 2.1 is out: high availability by Scarbutt on Tuesday August 11, 2015 @07:48PM (#10045139)
Would RethinkDB be a good choice for an invoicing web application? where you can't afford loss of data.
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @08:24PM (#10045267)
Yes. RethinkDB has very strict durability guarantees (that are the same as traditional RDBMS). However, if you need transactions compliance across multiple documents, RethinkDB isn't a good choice.

See the faq for more details: http://rethinkdb.com/faq/

Re:RethinkDB 2.1 is out: high availability by lobster_johnson on Tuesday August 11, 2015 @08:41PM (#10045347)
Are there plans (heh) to write an optimizing planner that can automatically evaluate which indexes to use?
Re:RethinkDB 2.1 is out: high availability by coffeemug on Tuesday August 11, 2015 @08:54PM (#10045380)
Yes. There are a couple of proposals floating around -- check out https://github.com/rethinkdb/rethinkdb/issues/4150 for details.