Resource and Replication expectations

49 views
Skip to first unread message

Daniel McGreal

unread,
May 26, 2014, 7:46:38 AM5/26/14
to mobile-c...@googlegroups.com
Hi Couchbase Mobile,
I'd like to thank the Couchbase developers and community - CBL will be an extraordinarily useful tool.

I have some questions about replication in various scenarios:

When is push replication triggered? Proximally to document updates or on its own schedule, e.g in bulk?
If replication is created at a time when sync gateway is unavailable e.g. access denied, timeout, connection refused, will it attempt to reconnect in the future?
Documents saved while replication is failing, e.g. out of wifi range, will it send documents when the connection can be restored? If so, is this state stored in memory (I.e. memory use while out of wifi range could be higher?)
Can I expect pushed documents to appear in the Couchbase server's console as soon as they're registered in sync gateway or is there another layer of caching there?

I have some questions about the resources a CBL application might be expected to consume:

Are documents cached in memory at any point in their life cycle?
How about view indexes?
When are views rebuilt in response to data changes, is it synchronous?
LiveQueries are triggered when a view key or value changes? Just key?
What are the big memory factors? Documents, views, replication?


Jens Alfke

unread,
May 27, 2014, 10:24:06 AM5/27/14
to mobile-c...@googlegroups.com
On May 26, 2014, at 4:46 AM, Daniel McGreal <d.j.m...@gmail.com> wrote:

When is push replication triggered? Proximally to document updates or on its own schedule, e.g in bulk?

A continuous push replication triggers any time documents are changed.
If you want custom scheduling, you can use a non-continuous replication and start it whenever you want.

If replication is created at a time when sync gateway is unavailable e.g. access denied, timeout, connection refused, will it attempt to reconnect in the future?

Yes.

Documents saved while replication is failing, e.g. out of wifi range, will it send documents when the connection can be restored?

Yes.

If so, is this state stored in memory (I.e. memory use while out of wifi range could be higher?)

No. Documents are always saved to the local database. And there’s a “checkpoint” stored in the local database that keeps track of what’s been synced with the server so far.

Can I expect pushed documents to appear in the Couchbase server's console as soon as they're registered in sync gateway or is there another layer of caching there?

It’s immediate.

Are documents cached in memory at any point in their life cycle? 

The latest 50 CBLDocuments accessed in a database are cached in memory. On iOS this cache will be automatically flushed if memory is running low.

How about view indexes?

No.

When are views rebuilt in response to data changes, is it synchronous?

View indexes are updated incrementally on demand, i.e. the next time the view is queried after the database has changed.

LiveQueries are triggered when a view key or value changes? Just key?

A LiveQuery updates its view index after any database change, then re-runs the query. It notifies its observers if any of the query keys or values change.

What are the big memory factors? Documents, views, replication?

Depends on the app. For example, LiveQueries are very convenient but they cause the query results to stay in memory, so if you have a query with a ton of rows or with really big values, that could consume a lot of memory. In a case like that you’d want to use a custom query and probably use pagination so not all of the rows get generated at once.

—Jens
Reply all
Reply to author
Forward
0 new messages