Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to Google Cloud Datastore - #GDGSV

Intro to Google Cloud Datastore - #GDGSV

Intro to Google Cloud Datastore.

Learn the basics of Google Cloud Datastore, a fully managed, NoSQL database that makes storing data in the cloud easy!

Presentation given at the Google Developer's Group of Silicon Valley on 5/6/2015.

http://www.meetup.com/gdg-silicon-valley/events/222174819/

https://github.com/thesandlord/samples/tree/master/google-cloud-datastore/cli-forum

365bbc53688d2cceb72e296acf7f65ee?s=128

Sandeep Dinesh

May 06, 2015
Tweet

More Decks by Sandeep Dinesh

Other Decks in Programming

Transcript

  1. Google Cloud Datastore Sandeep Dinesh, Developer Advocate @sandeepdinesh

  2. • Developer Advocate @ Google • Full-Stack Web • Founded

    an IoT Startup • First talk at Google! • @sandeepdinesh github.com/thesandlord sandeepdinesh@google.com About me
  3. Datastore, NoSQL, RDBMS, Graphs, ... What should I use? How

    are they different?
  4. How about SQL?

  5. • Relational Data • Complex Queries • Track Record The

    old guard RDBMS - Relational Databases Images from Wikipedia
  6. • Scale • Flexibility The old guard RDBMS - Relational

    Databases Images from Wikipedia
  7. The new kids on the block NoSQL

  8. The new kids on the block NoSQL NoSQL is a

    general term
  9. Document Store The new kids on the block NoSQL NoSQL

    is a general term
  10. Document Store Graph/Triplestore The new kids on the block NoSQL

    NoSQL is a general term
  11. Document Store Graph/Triplestore Key-Value The new kids on the block

    NoSQL NoSQL is a general term
  12. Document Store Graph/Triplestore Key-Value The “new” kids on the block

    NoSQL NoSQL is a general term Distributed
  13. What is Datastore? And why should I care...

  14. A little background...

  15. Google App Engine Google Datastore

  16. Scale Performance Availability Sharding Replication ???

  17. Fully Managed NoSQL ACID Built for Scale High Replication High

    Availability Google Cloud Datastore
  18. Fully Managed NoSQL ACID Built for Scale High Replication High

    Availability Google Cloud Datastore Google’s DBAs are your DBAs No software upgrades/patches No pager duty :)
  19. Fully Managed NoSQL ACID Built for Scale High Replication High

    Availability Google Cloud Datastore Semi-Structured Data Easy to Use Powerful Query Abilities
  20. Fully Managed NoSQL ACID Built for Scale High Replication High

    Availability Google Cloud Datastore Atomic Transactions (Eventual) Consistency Reliable
  21. Fully Managed NoSQL ACID Built for Scale High Replication High

    Availability Google Cloud Datastore Built for Google Scale Scalable Design, By Design
  22. Fully Managed NoSQL ACID Built for Scale High Replication High

    Availability Google Cloud Datastore Asteroid Proof 99.95% uptime
  23. Section Slide Template Option 2 Put your subtitle here. Feel

    free to pick from the handful of pretty Google colors available to you. Make the subtitle something clever. People will think it’s neat. Using Datastore Getting Started with Infinite Scale
  24. Datastore Introduction Terminology Datastore RDBMS Category of Object Kind Table

    One entry/object Entity Row Unique identifier of data entry Key Primary Key Individual piece of data inside entry/object Property Field
  25. Datastore Introduction Terminology Employees Employee Employees Employee Employee Employee Employee

    Employee ID: 123456 Name Address Title
  26. Datastore Introduction Terminology Eventual Consistency vs Strong Consistency

  27. Terminology Eventual Consistency Data Center 1 Data Center 2 User

    1 New Data User 2 User 3 Old Data New Data New Data
  28. Terminology Strong Consistency Data Center 1 Data Center 2 User

    1 New Data User 2 User 3 Locked Locked New Data New Data
  29. Terminology Strong Consistency Entity Groups & Ancestor Keys

  30. Terminology Eventual Consistency vs Strong Consistency Common Types of Queries:

    Global Queries Key Queries Ancestor Queries Eventually Consistent Strongly Consistent Strongly Consistent
  31. Code Yay!

  32. Code APIs JSON & Protobuf

  33. Code The gcloud library Idiomatic and Open Source

  34. Code Scenario Let’s build a message board Full Code w/

    ncurses UI: github.com/thesandlord/examples/datastore/ All code I am going to write is Copyright Google and Licensed under Apache v2
  35. Code Setup Terminal $ pip install --upgrade gcloud $ pip

    install --upgrade google-api-python-client
  36. Code Setup

  37. Code Architecture Comment ID, Text, StoryID User ID, Name Ancestor

    ID, Name, URL, Text Stories
  38. Code Oh no it broke :( Query with Multiple Filters

    need special Indexes! query = datastore.Query(kind='Comment', filters=[('storyid', '=', obj["id"])], order=['timestamp']) gcloud.exceptions.PreconditionFailed: 412 no matching index found.
  39. Code Create Some Indexes! We need to use the gcd

    tool https://cloud.google.com/datastore/docs/downloads#tools gcd.sh create ./temp mv temp/WEB-INF . rm -r temp/ #Create Index XML File (next slide) gcd.sh updateindexes --auth_mode=oauth2 . Follow the prompts
  40. Code datastore-indexes.xml XML <?xml version="1.0" encoding="utf-8"?> <datastore-indexes autoGenerate="true"> <datastore-index kind="Comment"

    ancestor="false"> <property name="storyid" direction="asc"/> <property name="timestamp" direction="asc"/> </datastore-index> </datastore-indexes>
  41. Code Index Created!

  42. Thank you! Thank you! twitter.com/sandeepdinesh github.com/thesandlord/examples/datastore/