【发布时间】:2017-10-16 21:22:10
【问题描述】:
我部署了一个 GCP HTTP 触发的云函数,它通过键从 GCP 数据存储中查询一个实体。代码如下:
const datastore = require('@google-cloud/datastore');
exports.helloWorld = function helloWorld(req, res) {
const client = datastore();
const key = client.key(['Person', 'harry']);
client.get(key, function(err, entity) {
res.status(200).send(JSON.stringify(entity));
});
};
根据日志,此函数在调用时需要约 1.6 秒才能完成。重复调用并没有更快。
删除查询并响应 HTTP 请求大约需要 0.5 秒才能完成,因此查询似乎需要大约 1.1 秒才能完成。对我来说,这速度慢得无法使用,而且这似乎不太可能是 GCP Datastore 的预期性能。
我认为数据库和函数可能在不同的区域运行,但我无法检查,文档中给出的说明不正确(https://cloud.google.com/datastore/docs/locations#location-r)。该地区没有显示在我的页面上。
我的设置可能有什么问题?我预计简单查询约为 50 毫秒,而不是 1100 毫秒。
【问题讨论】:
-
我不确定您在此处设置的问题,但我可以确认您应该能够在 Google App Engine 信息中心右上角的“您的-project-id.appspot.com”,你能再检查一下吗?
标签: google-cloud-datastore google-cloud-platform google-cloud-functions