Google Cloud Datastore latency

Viewed 857

I have an API deployed on Cloud Run where each request results in a read + write to Cloud Datastore. A non-trivial amount of the requests are first timers (read from Datastore will return null), so adding caching in front of it may not be too helpful.

Over the past month, the average wall time around calling Datastore and having the data (data = client.get(key, eventual=True)) is 48ms. The payloads are small (a list of dicts, with 10 elements on average, and each dict has two floats).

I'm not sure if I should say that latency is high, but my API has a budget of 100ms to do all that it needs to do and return. If just the data fetching takes ~50% of that time, I'm looking for ways to optimize things.

Questions:

  1. In general, how does 50ms sound for fairly small payloads, fetched by key, from within GCP?
  2. What should I expect (in terms of latency) from Memorystore within GCP?
1 Answers

Assuming you are using Cloud Run and Datastore on the same location, I would say that 50ms is around the expected latency you'd have for reading on datastore, the size of the payload does not matter as much for reads (10 - 1000 document reads do not make a big difference on time of processing/propagating).

Since you have such a small window for your API to operate, this could indeed be a problem if some unnexpected delays occur.

I have never used Memorystore so I can't say what you could expect of actual latency but it might be a better option given that every ms to your app counts.

Related