What is a Cloud Datastore
- NoSQL
- Flexible structure/relationship
- No Ops
- No provisioning of instances
- Compute layer is abstracted away
- Scalable
- Multi-regions access
- Sharding/replication automatic
- We can have only 1 Datastore per project
When to use Datastore
- Applications need scale
- Product catalog - real time inventory
- User profiles - mobile apps
- Game save states
- ACID transactions, eg, transferring funds
When not use Datastore
- Analytics(full SQL semantics)
- Use Big Query/Cloud Spanner
- Extreme scale(10M+ read/writes per second)
- Use Bigtable
- Don’t need ACID
- Bigtable
- Lift and shift(existing MYSQL)
- Cloud SQL
- Near zero latency(< 10ms)
- Use in-memory database (Redis)
Relational Database vs Datastore
Entities can be hierarchical
Queries and Indexing
Query
- retrieve entity from datastore
- query methods
- programmatic
- web console
- GQL( google query language)
Indexing
- queries get results from indexes
- index type
- Built-in: Allows single property queries
- Composite: use index.yaml
Danger - Exploding Indexes !
- solutions:
- use index.yaml to narrow index scope
- do not index properties that don’t need indexing
Data Consistency
Performance vs Accuracy
- Strongly Consistent
- Parallel processes with orders guaranteed
- Use case: financial transaction
- Eventually Consistent
- Parallel processes not with orders guaranteed
- Use case: Census population, order not important