Synchronization updates take a long time

Hi, I’m developing a mobile app for both iOS and Android and I started noticing the synchronization started to take longer and longer each time I run it. I have a sync gateway and a couchbase server instance running in an Ubuntu Virtualbox VM which I can restore to a known virtually empty state. My app performs a simple task of writing a document locally and waiting for it to replicate to the server where another process instantly updates the document. It then waits for synchronization to pull the update back to the device. There aren’t much more than a handful of documents on the server. When I first tested the app the synchronization seemed to happen within a few seconds but then on subsequent runs it would take longer and longer. It is now taking upwards of 5-10 minutes to sync. Are there any parameters or guidance around the timing of updates syncing back to the device? Where would I look to learn more?

It definitely shouldn’t be taking that long! Normal time should be a couple of seconds. Let’s figure out what’s happening.

One possibility is that your document updates, on one side or the other, are creating conflicts. Creating huge numbers of unresolved conflicting revisions in Sync Gateway is a known source of performance problems in current releases (and is never something you want to do anyway.) To check for this you can GET a document on the SG admin API using the ?open_revs=all param. The JSON response be an array listing all of the leaf revisions; if there’s more than one, you have a conflict.

If that’s not it, the next thing we’d want to see would be the Sync Gateway logs from the time period where a slow replication is going on. (They could be long, so it’s best to put them somewhere like gist or pastebin, then link to them here.)

@jens Thank you so much for your prompt reply! I ran my test again and there is only one revision in question. This time my iOS client did not update at all and it’s been over an hour. I ran the same test at the same time on Android and it did update. The Android logs don’t seem to tell the full story. I filter on “/sync” and get:

10-09 10:03:39.499 24478-25077/com.clifton.myapp.droid E/Sync: com.couchbase.lite.replicator.ReplicationInternal$4@2ec6921a checkSessionAtPath() response: {authentication_handlers=[default, cookie], ok=true, userCtx={channels={!=1, entity_user1=3}, name=user1}}
10-09 10:03:39.521 24478-25075/com.clifton.myapp.droid E/Sync: com.couchbase.lite.replicator.ReplicationInternal$4@84933c checkSessionAtPath() response: {authentication_handlers=[default, cookie], ok=true, userCtx={channels={!=1, entity_user1=3}, name=user1}}
10-09 10:04:15.548 24478-25054/com.clifton.myapp.droid W/Sync: com.couchbase.lite.replicator.PullerInternal@237bb159 no new remote revisions to fetch. add lastInboxSequence (70) to pendingSequences (

I’m wondering if the client side APIs are returning stale data somehow.

Actually let me start completely fresh from my VM restore state, uninstall the app on my emulator/simulator and try again. One moment while I get better logs.