Ideas on how to optimize loading a lot of documents when user sign in/up.

40 views
Skip to first unread message

Herman Chan

unread,
Aug 28, 2014, 9:50:21 PM8/28/14
to mobile-c...@googlegroups.com
Hi there,

We are using the latest CBL ios/android in our mobile app which possibly syncs to multiple couchdb backend database.

We run into an issue when some user tries to reinstall or simply installing our app in a new device when they have quite a few documents in their couchdb(s) (i.e: more then 1000 docs).

The problems are:

1.  It takes quite awhile to replicate down all the docs (don't know if there is any way to optimize this).
2.  Since we have liveQuery attached to most of our UI, the UI jumps around a lot as document comes in.
3.  When a user hit the Home button before all the replication is done, it seems like replication stops which is fine for normal cases, but not when a user sign up and still have unknown amount of docs to replicate down.


Any thoughts is appreciated.

-- Herman

Jens Alfke

unread,
Aug 28, 2014, 11:49:43 PM8/28/14
to mobile-c...@googlegroups.com
On Aug 28, 2014, at 6:50 PM, Herman Chan <herm...@gmail.com> wrote:

1.  It takes quite awhile to replicate down all the docs (don't know if there is any way to optimize this).

1000 docs shouldn't take too long, but it depends on how big they are, and what kind of net bandwidth you're getting. Have you tried profiling?

2.  Since we have liveQuery attached to most of our UI, the UI jumps around a lot as document comes in.

If this is a problem, you could defer setting up the live queries till the initial replication finishes. (Also, we should add some customization to LiveQuery, like being able to set the update interval.)

3.  When a user hit the Home button before all the replication is done, it seems like replication stops which is fine for normal cases, but not when a user sign up and still have unknown amount of docs to replicate down.

On iOS the replication should keep running in the background for as long as the OS allows the app process to stay awake (usually around a minute). Android is more lenient, I hear.

—Jens

Igor Ievsiukov

unread,
Aug 29, 2014, 5:29:51 AM8/29/14
to mobile-c...@googlegroups.com
Hi Herman,

1. 1k docs isn't that big of a number, but replication time depends on many parameters, such as:
a) are you replicating from couchdb or sync_gateway? latter has _bulk_get which brings siginificant improvements in UI.
b) do you have large attachments?
c) what's the network latency between the user and a server? if user is in japan and server is in US then network latency really kills it.

2. i have the similar problem, 'though i use my own solution instead of CBLLiveQuery, you have two options:
a) put a fullscreen controller with loading bar then when replication finishes dismiss it and display main app ui
b) analaze your app and disable some live queries while replicating to avoid flickering.

3. CBL keeps replicating in background as long as iOS will allow app to keep run in background, no different from any other app.

- Igor
Reply all
Reply to author
Forward
0 new messages