I deployed a GCP HTTP triggered Cloud Function that queries an Entity from GCP Datastore by the key. Here is the code:
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));
});
};
According to the logs this function takes ~1.6 seconds to complete when invoked. Repeat invocations are not any faster.
Removing the query and responding to the HTTP request takes ~0.5 seconds to complete, so it seems the query takes ~1.1 seconds to complete. For me this is unusably slow and it seems unlikely that this is the intended performance of GCP Datastore.
I thought that perhaps the DB and the Function are running in different regions but I am unable to check, the instructions given in the documentation is incorrect (https://cloud.google.com/datastore/docs/locations#location-r). The region is not displayed on the page for me.
What might be the problem with my setup here? I was expecting ~50ms for simple queries rather than ~1100ms.