Querying views cause 100% cpu for hours

Hi,

Sorry, this is duplicate (Querying views with this code causes 100% cpu and ram on data servers). I did not realize I posted it earlier. However, there is no comment in the thread.

We have 7 data servers with 39932388+ documents occupying 44gb in ram, 40gb in disk.

I have a very simple view as follow

 function (doc, meta) {
     if (doc && doc.form === 'user') {
          emit(meta.id, null);
     }
 }

I have the following node code.

var query = couchbase.ViewQuery.from('tmp', 'viewname');
bucket.query(query, function(err, results) {
    if (err) {
        throw err;
    }

    var total = results[0].value;
    var perPage = 2000;
    var totalPages = Math.ceil(total / perPage);

    console.log("Total Creatives: ", total);
    console.log("Pagination - per page", perPage);
    console.log("Pagination - total pages", totalPages);

    for(var i = 0; i<totalPages; i++) {


        var query = couchbase.ViewQuery.from('tmp', 'viewname')
            .reduce(false)
            .skip(skip)
            .limit(perPage);

        bucket.query(query, function(err, results) {
            if (err) {
                throw err;
            }

            results.forEach(function(result) {
            });

        });
    }

});

As you see, this code is nothing special. It simply paginate the view.

Whenever I run this code, CPU spikes and stay at 100% for hours.

I even used async module to limit node’s concurrency to 1 and I’m still getting the same issue.

This is really simple use case, but I have no idea how to fix it.

What am I doing wrong? How can I lower the CPU when it happens?

I’m on 4.1 EE.

can you see which process is consuming the CPU on the node that you see the 100% cpu utilization?
thanks
-cihan

it’s always the data servers. All of them.