Improve cold start of Cloud Datastore for Cloud Functions #9
Closed
Description
Copied from original issue: googleapis/google-cloud-node#2374
@richardowright
June 10, 2017 1:12 PM
Environment details
- OS: Google Cloud Functions
- Region: US Central
- google-cloud-node version: 1.0.2
Steps to reproduce
I experience high latency (~1 to 2 seconds) with pretty much every action.
Simple example (runs through bable prior to deploy) -
static async addPerson() {
try {
const datastore = Datastore({
projectId: projectId
});
const key = datastore.key('person');
const person = {
key: key,
data:
[
{ name: 'last_name', value: 'Wright' },
{ name: 'last_name_UPPER', value: 'WRIGHT' },
{ name: 'first_name', value: 'Richard' },
{ name: 'first_name_UPPER', value: 'RICHARD' },
{ name: 'email', value: 'mygmail@gmail.com' },
{ name: 'address_street', value: 'My Place', excludeFromIndexes: true },
{ name: 'address_city', value: 'City' },
{ name: 'address_state', value: 'State' },
{ name: 'address_zip', value: '12345' },
{ name: 'phone', value: '123.456.7890' },
{ name: 'date_of_birth', value: new Date(1901, 02, 03)},
{ name: 'create_time', value: new Date(Date.now()), excludeFromIndexes: true }
]
};
let saveResponse = await datastore.save(person);
let person_id=saveResponse[0].mutationResults[0].key.path[0].id;
return person_id;
} catch (err) {
console.log(err);
return;
}
}