Hi everyone!
I’m using Couchbase sync gateway to receive data from 75 pouchdb clients. After that I process the data and send the processed data to mobile devices.
Every minute the client send an new document to the sync gateway. The sync gateway receives the data, processes alll the received data once every 5 mins and sends the new/updated docs to the mobile devices. So there are about 4500 docs added every hour. The total size of the database is rapidly expanding, so that’s why old docs get removed to reduce database size every 6 hours.
Currently I have allot of issues regarding the sync gateway being non responsive after several hours of usage. There’s clearly no weird stuff going on in the logs as far as I can see. I’m using NodeJS to create new docs based on the minute data I receive.
When an mobile device updates, it only has to see minute doc data from the last 24 hours.
There are currently 11 production views (~3 per design).
After several hours of usage the sync_gateway just becomes non-responsive. How can I investigate on what the cause of the problem is. Logs don’t say much, except the error i’m throwing regarding deletion of docs. And where to look at?
I’m using Couchbase 4.1.1 and Sync gateway 1.3.1
{
"interface":"0.0.0.0:4984",
"adminInterface":"0.0.0.0:4985",
"log":
[
]
,
"logFilePath":"/home/sync_gateway/sg_error.log",
"pretty":true,
"maxCouchbaseConnections":10,
"databases":{
"mobile":{
"server":"http://localhost:8091",
"bucket":"smart",
"username":"username",
"password":"password",
"users":{
"GUEST":{
"disabled":false,
"admin_channels":[
"*"
]
}
},
"sync":`
function (doc, oldDoc) {
if (doc._deleted) {
if(doc.type === 'minute' || doc.type === 'smart'){
channel("*");
}else {
requireRole("admin");
throw({forbidden : "CANNOT DELETE DOC"});
return;
}
}
if (doc.type) {
if (doc.type === 'minute') {
if (doc.timestamp > (Date.now() / 1000) - 86400) {
channel("channel-" + doc.uuid);
} else
channel("*");
} else if (doc.type === 'hour') {
if (doc.timestamp > (Date.now() / 1000) - 86400) {
channel("channel-" + doc.uuid);
}else
channel("*");
} else if (doc.type === 'day' ||
doc.type === 'Ebalance') {
channel("channel-" + doc.uuid);
} else if (doc.type === 'Etransfer') {
channel("channel-" + doc.sender);
channel("channel-" + doc.receiver);
} else if (doc.type === 'Erequest') {
channel("Erequest-" + doc.uuid);
} else if (doc.type === 'wijkminute'
|| doc.type === 'wijkday') {
if (doc.timestamp > (Date.now() / 1000) - 86400)
channel("wijk");
else
channel("*");
} else if (doc.type === 'forecast') {
channel('forecast');
} else if (doc.type === 'ads'){
if(!doc.trash)
channel('ads');
}
else {
channel("*");
}
}
};
`,
"shadow":{
"server":"http://localhost:8091",
"bucket":"app",
"username":"username",
"password":"password"
}
},
"smart":{
"server":"http://localhost:8091",
"bucket":"smart",
"username":"username",
"password":"password",
"maxCouchbaseOverflow":64,
"users":{
"GUEST":{
"disabled":false,
"admin_channels":["*"]
}
},
"sync":`
function(doc, oldDoc) {
if (oldDoc && doc._deleted) {
requireRole("admin");
throw({forbidden : "cannot delete"});
return;
}
channel(doc.channels);
}
`,
"shadow":{
"server":"http://localhost:8091",
"bucket":"app",
"username":"app",
"password":"password"
}
}
}
,"CORS": {
"Origin": ["http://localhost:8100"],
"LoginOrigin": ["http://localhost:8100"],
"Headers": ["Content-Type", "Accept", "Authorization", "Origin", "Referer","X-CSRF-Token"],
"MaxAge": 17280000
}
}