Hi Couchbase team and Couchbase Experts,
We seek your expert advice.
We am using latest version of Couchbase Server 3.0.2 and Couchbase Sync Gateway 1.0.3 (64 bit) in ubuntu server 14
- There are only 3 buckets with 6 gb ram alloted to main buckets and its shadow, default has 1 gb ram
Issue : The default map functions installed by sync-gateway take a lot of time to index on avg 1 sec per document.
-avg doc size is not more then 1 kb
Other things that are happening
-beam.smp run by couchbase consumer more than 100% cpu
- plus i see several page faults
What i tried:
1 I removed all string manipulation from our sync-gateway code
2 i ensured no empty keys are being indexed
3 moved to SSD
but when i removed my code or when sync maps functions do not have to compute channels or access or principal it takes 1500 docs a sec on to show in the shadow bucket.
My sync function :
-----------------------------start--------------------------
if (doc.type){
if(doc.owner && typeof doc.owner !== ‘undefined’ )
{ access(doc.owner,‘ch-’+doc.owner); channel(‘ch-’+doc.owner); }
if(doc.type==‘hx’){ channel(‘hx’,doc.channels);}
if(doc.type==‘cx’ && doc.dx_s && typeof doc.dx_s !== ‘undefined’ ) {
if(doc.mx && typeof doc.mx !== 'undefined' && doc.owner typeof doc.owner !== 'undefined' )
{ access([doc.mx,doc.owner],'ch-'+doc.dx_s); channel('ch-'+doc.dx_s); }
else{ access(doc.owner,'ch-'+doc.dx_s); channel('ch-'+doc.dx_s);} }
if(doc.type=='qx' && doc.receivermx && typeof doc.receivermx !== 'undefined')
{ access(doc.receivermx,'ch-'+doc._id); channel('ch-'+doc._id); }
if(doc.type=='cxdx'&& doc.dxtype )
{ if( doc.dxtype!='Private' && doc.dxnumber && typeof doc.dxnumber !== 'undefined' )
{ if(doc.mx && && typeof doc.mx !== 'undefined'){ access([doc.mx,doc.owner],'ch-'+doc.dxnumber); }
else {access(doc.owner,'ch-'+doc.dxnumber);} channel('ch-'+doc.dxnumber); } }
if(doc.type=='dx'&& doc.dxtype && doc.mxarr && doc.dxtype!='Private'){
access([doc.owner,doc.mxarr],'ch-'+doc._id); channel('ch-'+doc._id);
}
} }
-----------------------------end--------------------------
Question
1 can sync gateway handle multiple if loops and check as i have added
2 should i transfer most if the code to mobile device and do minimum checks here
3 if there some mistake in our code.
Please help us.
Thanks in advance
Arjun