Skip to content

Shared Nothing Deployment

Chris Anderson edited this page May 1, 2013 · 1 revision

Problem

In order to scale Sync Gateway it is necessary to run it across more than one machine. In practical terms, this means we need to be intentional about what kinds of agreement we require between the distributed processes. Needs to work with Couchbase Server 2.0.

Readers and Writers

We can split up the system into Document Readers, Changes Readers, and Document Writers, and scale these independently.

Document Readers

In a sync session, the client makes a continuous connection to the Changes Reader, and then fetches individual documents or batches of documents from the Document Reader along parallel connections. To service the request, the document reader must load the user's permissions (stored in a Couchbase document) and the requested document. If the user has permission to read any of the channels the document belongs to, the read can continue.

It should scale independently of the other components, as it only depends on state in Couchbase Server's key value API.

Changes Readers

The changes readers can scale independently. They are dependent on view reads when a sync session begins, and a TAP or cluster-wide changes feed thereafter.

The device sessions may have to track state about which channels have been synced so far.

Challenges with using eventually consistent views for sequence numbering. Do we need to track the lowest uncommitted seq also?

Document Writers

These won't need to make view queries, just key value interactions. However they may occasionally update a handful of documents in a lock, when access-granting documents are modified.

Writers also handle validation and data routing. This is CPU intensive and results in view index updates.

They need to agree about sequence numbers. But sequence numbers don't have to be unique. 10 docs in a row can all get the same one, at the cost of some duplication of effort on sync client reconnect. So we could use "slow INCR" with fully persistent writes, without slowing down inserts. It would just make changes feed startkeys "chunkier."

Open Q. Should writers send event notifications to changes readers or let all that come from the TAP feed of Couchbase Server?

Clone this wiki locally