我在物联网环境中的生产环境中拥有一个解析服务器,该服务器每秒处理约100个请求。所有这些都非常适合CPU大约30%和25ms的响应时间。解析服务器群集在两个C5.Large实例的AWS上。
我将LiveQuery添加为单独的C5.Large服务器。 Parse服务器和LiveQuery都在使用Redis传达更改,并且可以正常工作。
我看到的问题是仅连接一个客户端的LiveQuery服务器的CPU使用率在20-35%之间。连接了两个客户端,这一比例上升到40%左右。超过三个客户端已连接,服务器在几分钟之内崩溃。
我正在寻找一些建议,以试图找出导致CPU使用率过高进而导致服务器崩溃的原因。需要明确的是,所有订阅工作都从Parse Server到LiveQuery,再到客户端。
更多信息:
以下是配置Live Query服务器的方式:
let parseApi = new ParseServer({
databaseURI: `mongodb://${config.get('/mongo/userName')}:${config.get('/mongo/password')}@${config.get('/mongo/uri')}`, // Connection string for your MongoDB database
appId: config.get('/parse/appId'),
masterKey: config.get('/parse/masterKey'), // Keep this key secret!
serverURL: `http://127.0.0.1:${config.get('/port/webapp')}/parse`,
logLevel: "ERROR",
sessionLength: ONE_DAY, // in seconds. Set to 24 hours.
schemaCacheTTL: ONE_MONTH_MS, //"The TTL for caching the schema for optimizing read/write operations. You should put a long TTL when your DB is in production. default to 5000; set 0 to disable."
cacheTTL: ONE_DAY_MS, //"Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds)"
cacheMaxSize: 1000000, //"Sets the maximum size for the in memory cache, defaults to 10000"
enableSingleSchemaCache: true //"Use a single schema cache shared across requests. Reduces number of queries made to _SCHEMA. Defaults to false, i.e. unique schema cache per request."
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', parseApi);
let port = config.get('/port/webapp');
let server = app.listen(port);
// Initialize a LiveQuery server instance, app is the express app of your Parse Server
if (config.get('/parseAppServerIsLocal')) {
debug(`Starting Live Query Server on port ${config.get('/port/parseLiveQuery')}`);
let httpServer = require('http').createServer(app);
httpServer.listen(config.get('/port/parseLiveQuery'));
let liveQueryParams = {
redisURL: config.get('/server/redis')
};
let parseLiveQueryServer = ParseServer.createLiveQueryServer(httpServer,liveQueryParams);
}