Performance issue while replicating huge dataset to and from Cloudant to PouchDB
I am working on a project which includes replicating the localDB to cloudant. I have some issues with it:
1.As I am using websql as adapter and the nodejs on the backend of an android app , I need to use prefix to navigate the database to the data directory to be able to open the db file. Because of that when I am trying to replicate to cloudant or to any other remote pocuhDB compatible database it is not working unless I use the pouchdb,replication(local,remote,opts); This way the replication is possible but is there any way to make the replication possible from the fauxton rather than hardcoding?
Sample
let opts = {live:true,retry:true},
Promise = require('bluebird'),
fs = require('fs'),
path = require('path'),
express = require('express'),
app = express(),
PouchDB = require('pouchdb-core'),
replicationStream = require('pouchdb-replication-stream'),
memoryStream = require('memorystream'),
log = path.join(cordova.app.datadir(),"log.txt"),
backup = path.join(cordova.app.datadir(),"backup.txt"),
prefix = path.join(cordova.app.datadir(),"db"),
pouchdb = PouchDB.plugin(require('pouchdb-adapter-node-websql')).plugin(require('pouchdb-
adapter-http')).plugin(require('pouchdb-mapreduce')).plugin(require('pouchdb- replication')).plugin(replicationStream.plugin);
pouchDB = pouchdb.defaults({prefix:prefix});
let pouchHandle = require('express-pouchdb')(pouchDB,{logPath:log});
PouchDB.adapter('writableStream',replicationStream.adapters.writableStream);
let stream = new memoryStream();
let config = pouchHandle.couchConfig;
app.use(cors(config));
console.log("Config file set");
app.use('/',pouchHandle);
server = app.listen(port).on('error',console.log);
let db = new pouchDB('posdemo',{adapter:'websql'});
db.changes({live: true, since:'now'}).on('change',console.log);
pouchdb.replicate(remote,db,opts);
pouchdb.replicate(db,remote,opts);
2.The initial replication is very slow for 100k(no attachments size of 100mb) docs it takes around 1hr 45mins to sync(through replication API of pouchDB). I went through the issues and tried to implement pouchDB replicaton stream and used memory stream replication (dump/load). It took around 45 mins by changing the batch_limit and batch_size . Is there a way to make the initial replication faster and effective. As the doc count can go way higher.
3.When I am using the db.dump(stream).Let say the doc count is 35000 it only dumps 2800 docs.This is my code for dumping:
var backup = path.join(cordova.app.datadir(),"backup.txt");
var ws = fs.createWriteStream(backup);
db.dump(ws,{since:0}).then(function(res){
console.log(res);
}).catch(function(err){
console.log(err)
});
Can anyone suggest me an efficient way for this?
Any help or suggestion will be appreciated
javascript node.js couchdb pouchdb cloudant
add a comment |
I am working on a project which includes replicating the localDB to cloudant. I have some issues with it:
1.As I am using websql as adapter and the nodejs on the backend of an android app , I need to use prefix to navigate the database to the data directory to be able to open the db file. Because of that when I am trying to replicate to cloudant or to any other remote pocuhDB compatible database it is not working unless I use the pouchdb,replication(local,remote,opts); This way the replication is possible but is there any way to make the replication possible from the fauxton rather than hardcoding?
Sample
let opts = {live:true,retry:true},
Promise = require('bluebird'),
fs = require('fs'),
path = require('path'),
express = require('express'),
app = express(),
PouchDB = require('pouchdb-core'),
replicationStream = require('pouchdb-replication-stream'),
memoryStream = require('memorystream'),
log = path.join(cordova.app.datadir(),"log.txt"),
backup = path.join(cordova.app.datadir(),"backup.txt"),
prefix = path.join(cordova.app.datadir(),"db"),
pouchdb = PouchDB.plugin(require('pouchdb-adapter-node-websql')).plugin(require('pouchdb-
adapter-http')).plugin(require('pouchdb-mapreduce')).plugin(require('pouchdb- replication')).plugin(replicationStream.plugin);
pouchDB = pouchdb.defaults({prefix:prefix});
let pouchHandle = require('express-pouchdb')(pouchDB,{logPath:log});
PouchDB.adapter('writableStream',replicationStream.adapters.writableStream);
let stream = new memoryStream();
let config = pouchHandle.couchConfig;
app.use(cors(config));
console.log("Config file set");
app.use('/',pouchHandle);
server = app.listen(port).on('error',console.log);
let db = new pouchDB('posdemo',{adapter:'websql'});
db.changes({live: true, since:'now'}).on('change',console.log);
pouchdb.replicate(remote,db,opts);
pouchdb.replicate(db,remote,opts);
2.The initial replication is very slow for 100k(no attachments size of 100mb) docs it takes around 1hr 45mins to sync(through replication API of pouchDB). I went through the issues and tried to implement pouchDB replicaton stream and used memory stream replication (dump/load). It took around 45 mins by changing the batch_limit and batch_size . Is there a way to make the initial replication faster and effective. As the doc count can go way higher.
3.When I am using the db.dump(stream).Let say the doc count is 35000 it only dumps 2800 docs.This is my code for dumping:
var backup = path.join(cordova.app.datadir(),"backup.txt");
var ws = fs.createWriteStream(backup);
db.dump(ws,{since:0}).then(function(res){
console.log(res);
}).catch(function(err){
console.log(err)
});
Can anyone suggest me an efficient way for this?
Any help or suggestion will be appreciated
javascript node.js couchdb pouchdb cloudant
add a comment |
I am working on a project which includes replicating the localDB to cloudant. I have some issues with it:
1.As I am using websql as adapter and the nodejs on the backend of an android app , I need to use prefix to navigate the database to the data directory to be able to open the db file. Because of that when I am trying to replicate to cloudant or to any other remote pocuhDB compatible database it is not working unless I use the pouchdb,replication(local,remote,opts); This way the replication is possible but is there any way to make the replication possible from the fauxton rather than hardcoding?
Sample
let opts = {live:true,retry:true},
Promise = require('bluebird'),
fs = require('fs'),
path = require('path'),
express = require('express'),
app = express(),
PouchDB = require('pouchdb-core'),
replicationStream = require('pouchdb-replication-stream'),
memoryStream = require('memorystream'),
log = path.join(cordova.app.datadir(),"log.txt"),
backup = path.join(cordova.app.datadir(),"backup.txt"),
prefix = path.join(cordova.app.datadir(),"db"),
pouchdb = PouchDB.plugin(require('pouchdb-adapter-node-websql')).plugin(require('pouchdb-
adapter-http')).plugin(require('pouchdb-mapreduce')).plugin(require('pouchdb- replication')).plugin(replicationStream.plugin);
pouchDB = pouchdb.defaults({prefix:prefix});
let pouchHandle = require('express-pouchdb')(pouchDB,{logPath:log});
PouchDB.adapter('writableStream',replicationStream.adapters.writableStream);
let stream = new memoryStream();
let config = pouchHandle.couchConfig;
app.use(cors(config));
console.log("Config file set");
app.use('/',pouchHandle);
server = app.listen(port).on('error',console.log);
let db = new pouchDB('posdemo',{adapter:'websql'});
db.changes({live: true, since:'now'}).on('change',console.log);
pouchdb.replicate(remote,db,opts);
pouchdb.replicate(db,remote,opts);
2.The initial replication is very slow for 100k(no attachments size of 100mb) docs it takes around 1hr 45mins to sync(through replication API of pouchDB). I went through the issues and tried to implement pouchDB replicaton stream and used memory stream replication (dump/load). It took around 45 mins by changing the batch_limit and batch_size . Is there a way to make the initial replication faster and effective. As the doc count can go way higher.
3.When I am using the db.dump(stream).Let say the doc count is 35000 it only dumps 2800 docs.This is my code for dumping:
var backup = path.join(cordova.app.datadir(),"backup.txt");
var ws = fs.createWriteStream(backup);
db.dump(ws,{since:0}).then(function(res){
console.log(res);
}).catch(function(err){
console.log(err)
});
Can anyone suggest me an efficient way for this?
Any help or suggestion will be appreciated
javascript node.js couchdb pouchdb cloudant
I am working on a project which includes replicating the localDB to cloudant. I have some issues with it:
1.As I am using websql as adapter and the nodejs on the backend of an android app , I need to use prefix to navigate the database to the data directory to be able to open the db file. Because of that when I am trying to replicate to cloudant or to any other remote pocuhDB compatible database it is not working unless I use the pouchdb,replication(local,remote,opts); This way the replication is possible but is there any way to make the replication possible from the fauxton rather than hardcoding?
Sample
let opts = {live:true,retry:true},
Promise = require('bluebird'),
fs = require('fs'),
path = require('path'),
express = require('express'),
app = express(),
PouchDB = require('pouchdb-core'),
replicationStream = require('pouchdb-replication-stream'),
memoryStream = require('memorystream'),
log = path.join(cordova.app.datadir(),"log.txt"),
backup = path.join(cordova.app.datadir(),"backup.txt"),
prefix = path.join(cordova.app.datadir(),"db"),
pouchdb = PouchDB.plugin(require('pouchdb-adapter-node-websql')).plugin(require('pouchdb-
adapter-http')).plugin(require('pouchdb-mapreduce')).plugin(require('pouchdb- replication')).plugin(replicationStream.plugin);
pouchDB = pouchdb.defaults({prefix:prefix});
let pouchHandle = require('express-pouchdb')(pouchDB,{logPath:log});
PouchDB.adapter('writableStream',replicationStream.adapters.writableStream);
let stream = new memoryStream();
let config = pouchHandle.couchConfig;
app.use(cors(config));
console.log("Config file set");
app.use('/',pouchHandle);
server = app.listen(port).on('error',console.log);
let db = new pouchDB('posdemo',{adapter:'websql'});
db.changes({live: true, since:'now'}).on('change',console.log);
pouchdb.replicate(remote,db,opts);
pouchdb.replicate(db,remote,opts);
2.The initial replication is very slow for 100k(no attachments size of 100mb) docs it takes around 1hr 45mins to sync(through replication API of pouchDB). I went through the issues and tried to implement pouchDB replicaton stream and used memory stream replication (dump/load). It took around 45 mins by changing the batch_limit and batch_size . Is there a way to make the initial replication faster and effective. As the doc count can go way higher.
3.When I am using the db.dump(stream).Let say the doc count is 35000 it only dumps 2800 docs.This is my code for dumping:
var backup = path.join(cordova.app.datadir(),"backup.txt");
var ws = fs.createWriteStream(backup);
db.dump(ws,{since:0}).then(function(res){
console.log(res);
}).catch(function(err){
console.log(err)
});
Can anyone suggest me an efficient way for this?
Any help or suggestion will be appreciated
javascript node.js couchdb pouchdb cloudant
javascript node.js couchdb pouchdb cloudant
asked 3 hours ago
Bishal SahooBishal Sahoo
16
16
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54249747%2fperformance-issue-while-replicating-huge-dataset-to-and-from-cloudant-to-pouchdb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54249747%2fperformance-issue-while-replicating-huge-dataset-to-and-from-cloudant-to-pouchdb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown