Reputation: 33
To my understanding the Google Cloud Datastore allows me to write new entries without any time limits but puts limits on how often I can update an entity. In addition indexes are not strongly consistent.
I am quickly writing new sensor data associated with a single weather station into the datastore. The entity also contains a timestamp. There is a index sorting sensor readings by weather station and timestamp.
The goal now is to always return the most recent value to the user requesting the current value for a specific weather station but as the index is only eventually consistent it can happen that the returned value is not the most recent one.
Any ideas how an architecture could look like on the Google App Engine which always returns the most recent value without the risk to hit the write limit on a single entity?
Upvotes: 3
Views: 1046
Reputation: 39834
An alternative to writing all data from one station in a single entity group and using ancestor queries would be to write sensor readings as separate new entities and re-write a (small) well-known entity which contains the key of the most recent readings entity.
To get the most recent measurement you just get its key from the well-known entity and then get the entity by key lookup - always consistent.
You'd still be limited to writing samples not faster than once per second (on average), but at least this approach:
If you really need to write more than 1 sensor reading per second you could try to either:
Upvotes: 3
Reputation: 249
Try reading:
Basically, use an ancestor query and then your queries will be strongly consistent -- you will be able to query the most recent update.
Google Cloud Datastore supports one write per second per entity group. So long as each individual weather station writes less than once per second to its entity group you will be fine.
Upvotes: 0