-1

由于我们正在使用 node.js 和 MongoDB/Express 构建数据馈送 REST 服务,因此在查询结果很小的情况下它可以很好地工作。但是当客户端查询一个大数据集,比如1m行(已经使用gzip压缩)时,它会挂起服务器。这是node.js单线程设计造成的吗?  

我想咨询您有关处理此问题的任何想法。

欢迎任何意见:)

以下是有关服务的代码(使用 JayData OData 服务器模块)

app.use('/d.svc', $data.ODataServer({
    type: TYPE,
    CORS: true,
    database: 'odata',
    responseLimit: -1,
    checkPermission: function (access, user, entitySets, callback) {
        logger.info('Check Access Permission for User');// + JSON.stringify(user));
        if (access & $data.Access.Create) {
            if (user == 'admin') callback.success();
            else callback.error('Auth failed');
        } else callback.success();
    },
    provider: {
        name: 'mongoDB',
        databaseName: 'odata',
        address: settings.host,
        port: settings.port,
        username: USER,
        password: PASSWORD
    }
}));

非常感谢。

卢克。

4

1 回答 1

0

You should never transmit this amount of data in one query. Imagine that you have to keep the results in the memory on the client-side. No matter what technology you use, paged downdload is recommended. In case of JayData, you can implement it based on this blogpost - Synchronized Online/Offline data applications, part 2: Syncing large tables and tables with foreign relations

于 2013-09-30T05:25:50.540 回答