SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Downloaden Sie, um offline zu lesen
Querying Riak Just Got Easier
 Secondary Indices in Riak


         OSCON Data
 Portland, Oregon · July 2011


  Basho Technologies   rusty@basho.com
     Rusty Klophaus    twitter: rustyio
tl;dr:

Secondary Indices fundamentally
 change data modeling in Riak.

 Model one-to-one, one-to-many,
 or many-to-many relationships
     simply and efficiently.
               2
But first, a little bit
about tradeoffs and NoSQL.




            3
Which one would you choose?

It depends on their abilities.
It also depends on the quest.


                    Fools!




              5
Rule #1
  Your character will fare better
    in certain environments
depending on his (or her) abilities.




                 6
Rule #2
There are always tradeoffs




            7
Databases are like
    RPG character classes.

They focus on certain abilities.




               8
Database Abilities (1/2)
Schema
 Flexible Schema ⟩ Pre-Defined Schema ⟩ Typed Fields ⟩ Untyped Fields ⟩ Blob

Operation Skew
 Mostly Writes ⟩ 50/50 ⟩ Mostly Reads

Disk Persistence
 Every Operation ⟩ Delayed Batch ⟩ Flush ⟩ Never

Transactions
 Global ⟩ Table ⟩ Object ⟩ None

Data Relations
 Ad-Hoc ⟩ Pre-Defined ⟩ None

Operation Order
 Random ⟩ Sequential



                                            9
Database Abilities (2/2)
Secondary Queries
 Ad-Hoc ⟩ Pre-Determined ⟩ None

Native Data Types
 Tables ⟩ XML ⟩ JSON ⟩ Text ⟩ Blob

Scalable
 Data Center ⟩ Cluster ⟩ Single Machine

Failure-Tolerance
 Data Center ⟩ Network ⟩ Machine ⟩ Disk ⟩ Sector ⟩ None

Stability
 Predictable Latency ⟩ Variable Latency

Performance
 Ops Per Second
And so on...
                                          10
For a long time, industry focused on just one
     manifestation of database abilities:


                  SELECT * FROM Quests




           «Relational Database»

                         11
The World Has Changed
Global Internet
 “Everyone is connected...”




                                                    ile
                                                           Soc
                                                 ob


                                                            ial
                                                M
Mobile Computing
                                                    Global
 “...all the time...”

Social Networking
 “...producing more data (in more varieties) than ever.”




                                  12
NoSQL is about alternatives.

     Focus on different
  abilities, environments,
        and tradeoffs.



             13
As a database consumer,
  you need to understand the
basic tradeoffs of each solution.

 In turn, database producers
     should strive to make
     those tradeoffs clear.


               14
There are always tradeoffs.

Databases that claim to do
everything well are lying.




            15
Where Does Riak Fit?




         16
17
Have you ever been burned by:

     hardware failure?
    overloaded servers?
    emergencies at 2am?



             17
Does your quest involve:

SLAs that mention uptime or latency?
  data that you can’t afford to lose?




                 18
If so, Riak’s tradeoffs will make sense.

          If not, they won’t.




                   19
Riak KV - Some Tradeoffs (1/3)
Amazon’s Dynamo Architecture
 ✔Distributed, scalable, no single point of failure.
 ✘ No transactions; trade strong consistency for eventual consistency.




                                  20
Riak KV - Some Tradeoffs (2/3)
Extremely Focused on Operations
 ✔Simple to install, manage, connect a cluster.
 ✔Has been called “plumbing”, ie: it just works.
 ✘ Historically, developer-facing features lagged behind.
   This is rapidly changing.


               # Scale out...
               riak-admin join nodename@hostname

               # Scale back in...
               riak-admin leave



                                   21
Riak KV - Some Tradeoffs (3/3)
Key/Value Model
 ✔Simple, straightforward, content-type agnostic.
 ✘ More difficult to discover your data. (Queryability.)




            Let’s dive deeper into “queryability.”




                                  22
Current Options for Querying Riak
MapReduce
 Provide set of starting keys, filter via map.
 MapReduce is meant for calculations/aggregations, not queries.

Riak Search
 Full-text search in Riak.
 Opinionated, assumes your document is prose.

Roll Your Own Indices
 Difficult to get right.
 More code to maintain.
 Often introduces SPOFs.

                                 23
New Feature: Secondary Indices




              24
What are Secondary Indices?




            25
What Are Secondary Indices?
Goals
 Provide *simple* indexing on Riak objects.
 Maintain Riak’s operational advantages.
 Make a developer’s life easier.

How Does It Work?
 At write time, tag your data with key/value metadata.
 Query the metadata, get matching objects.




                                 26
For example...

BUCKET KEY            VALUE           INDEX METADATA

loot     gauntlet24                   category: armor
                                      price: 400
                                      ...



                      “Gauntlets of
                        Shininess”


                          27
Index an Object

# Store an object with:
#   Bucket: loot
#   Key:     gauntlet24
#   Fields:
#      - category: armor
#      - price: 400
curl 
  -X PUT 
  -d "OPAQUE_VALUE" 
  -H "x-riak-index-category_bin: armor" 
  -H "x-riak-index-price_int: 400" 
  http://127.0.0.1:8098/riak/loot/gauntlet24



                               28
Query the Index

# Query for category_bin = "armor"
curl 
  http://127.0.0.1:8098/buckets/loot/index/category_bin/armor

{"keys":["gauntlet24"]}



# Query for price_int between 300 and 500
curl 
  http://127.0.0.1:8098/buckets/loot/index/price_int/300/500

{"keys":["gauntlet24"]}




                                29
Query Syntax
 /buckets/$BUCKET/index/$FIELDNAME/$VALUE
 /buckets/$BUCKET/index/$FIELDNAME/$START/$END

$BUCKET
 Bucket to query.
$FIELDNAME
 Must end with “_bin” for binaries, “_int” for integers.
 Special field $key for key range lookups.
$VALUE / $START / $END
 Equality or range queries.



                                   30
Data Modeling with
Secondary Indices




        31
Key/Value Lookups
     Retrieve a user’s session.
     Retrieve an object by key.



         sessions/                 {
         8b6cfaa                       foo: "bar",
                                       ...
                                   }




                              32
Key/Value Lookups                               Use Case
     Retrieve a user’s session.
     Retrieve an object by key.            Generic Case
                            Object

         sessions/                   {
         8b6cfaa                         foo: "bar",
                                         ...
                                     }


               Key                         Value




                              33
Alternate Keys / One-to-One Relationships
      Retrieve a user by username or by email address.
      An object has multiple names.

    users/                    {
    rusty                         username: "rusty",
                                  email: "rusty@basho.com",
                                  twitter: "rustyio",
                                  ...
                              }

    emails/                   "rusty"
    rusty@basho.com




                             34
Alternate Keys
                                                                Wit
     Retieve a user by username or by email address.         Seco h
                                                                  nda
                                                             Ind      ry
     An object has multiple names.                               ices
                                                                      !

    users/                   {
    rusty                        username: "rusty",
                                 email: "rusty@basho.com",
                                 twitter: "rustyio",
                                 ...
                             }
                             Indexes:
                               email_bin: rusty@basho.com
                               twitter_bin: rustyio




                            35
Ownership / One-to-Many Relationships
      A person has many cars.
      Parent has a *small* number of children.

    people/                    {
    frank                          cars: [
                                     {
                                       plate: "ET7-B928",
                                       color: "red",
                                       type: "corvette",
                                     }
                                     ...
                                   ]
                               }




                              36
Ownership / One-to-Many Relationships
                                                                Wit
      A person has many cars.                                Seco h
                                                                  nda
                                                             Ind      ry
      Parent has a *small* number of children.                   ices
                                                                      !

    people/                    {
    frank                          cars: [
                                     {
                                        plate: "ET7-B928",
                                        color: "red",
                                        type: "corvette",
                                     },
                                     ...
                                   ]
                               }
                               Indexes:
                                 cars_plate_bin: ET7-B928
                                 cars_plate_bin: BUB-7911
                                 ...
                              37
Ownership / One-to-Many Relationships
      A user has many status updates.
      Parent has a *large* number of children.
    users/                    {
    rustyio                       status_updates: [
                                    "18258713",
                                    "87187597",
                                    "71117389",
                                    ...
                                  ]
                              }

    statuses/                 {
    18258713                      author: "rustyio"
                                  reply_to: "barackobama"
                                  text: "Sorry, can't hang out
                                         now, I'm speaking at
                                         OSCON Data."
                              }38
Ownership / One-to-Many Relationships
                                                                Wit
      A user has many status updates.                        Seco h
                                                                  nda
                                                             Ind      ry
      Parent has a *large* number of children.                   ices
                                                                      !
   users/                     {
   rustyio                        ...
                              }

   statuses/                  {
   18258713                       author: "rustyio"
                                  reply_to: "barackobama"
                                  text: "Sorry, can't hang out
                                         now, I'm speaking at
                                         OSCON Data."
                              }
                              Indexes:
                                author_bin: rustyio
                                reply_to_bin: barackobama
                               39
Membership / Many-to-Many Relationships
      A user joins one or more clubs, a club has users.
      A group has many members.

   users/                    {
   rusty                         clubs: [
                                   "dc_larping_club",
                                   ...
                                 ]
                             }

   clubs/                    {
   dc_larpers                    users: [
                                   "rusty",
                                   "frank"
                                 ]
                             }

                              40
Membership / Many-to-Many Relationships
                                                              Wit
      A user joins one or more clubs, a club has users.    Seco h
                                                                nda
                                                           Ind      ry
      A group has many members.                                ices
                                                                    !

   users/                    {
   rusty                         clubs: [
                                   "dc_larping_club",
                                   "nascar_fans",
                                   ...
                                 ]
                             }
                             Indexes:
                               club_bin: dc_larping_club
                               club_bin: nascar_fans

   clubs/
                             ...
   dc_larpers
                              41
What Were The Challenges?




           42
Challenge: Ambitious Prototyping (1/5)
Why Difficult?
 Early prototypes contained support for:
 • A SQL-like query language (RQL), with compound queries
 • Sorting and pagination, with intelligent caching
 • Inline map/reduce
 • Extensible data types
 Arguably too clever.
 Allowed developers to shoot selves in foot.

How Solved?
 Ruthlessly cut features & simplify.

                                   43
Challenge: Data Types (2/5)
Why Difficult?
 What type is a given field? Naming convention, or global dictionary?
 What if the user wants to change the type?
 What if the user provides a value of the wrong type?

How Solved?
 Field type determined by suffix. (field1_bin, field2_int)
 Different type == different field name.
 Pre-commit hook to validate data types.




                                 44
Challenge: Disk Based Storage (3/5)
Why Difficult?
 Disk is slow. (http://highscalability.com/numbers-everyone-should-know)
 Need data structures that are both read and write efficient, for data
 of unpredictable sizes and shapes.

How Solved?
 Leverage merge_index (data engine from Riak Search).
 Investigate LevelDB (library from Google)




                                   45
Challenge: Atomicity (4/5)
Why Difficult?
 Need to keep the index synchronized with the object value.
 Account for eventual consistency, siblings, handoff, replication, etc.
 What happens during node failure / partial cluster situations?

How Solved?
 Make the KV object the authoritative data.
 Indexed data is discarded if the object moves.




                                    46
Challenge: System is Distributed (5/5)
Why Difficult?
 Index is split over many different partitions.
 *Don’t* need to query every partition.
 *Do* need to be smart about which partitions to query.

How Solved?
 Extend riak_core (distribution layer) with ability to broadcast
 command to covering set of partitions.
 (h/t to Kelly McLaughlin, @_klm)




                                  47
Indexing

                  Client
                   API                        User tags the object with metadata.



Cluster

            Write Coordinator
                                                Validate that metadata parses.
            riak_kv_put_fsm

                  PUT
                 Request
 Node

             VNode Coordinator
          riak_core_vnode_master


   VNode (Virtual Node)

                Core VNode
             riak_core_vnode




                 KV VNode
              riak_kv_vnode



                 Backend                           Stores object in bitcask,
          riak_kv_index_backend                index metadata in merge_index.
Querying

                  Client                         User issues a query
                   API                            against metadata.


Cluster
             Query Coordinator
           riak_index_query_fsm


              Coverage Logic
          riak_core_coverage_fsm

                  Query
                 Request
 Node

             VNode Coordinator
          riak_core_vnode_master


   VNode (Virtual Node)

                Core VNode
             riak_core_vnode



                 KV VNode
              riak_kv_vnode



                 Backend                      Runs query against index,
          riak_kv_index_backend                 replies with results.
Next Steps
Publish
 We are open source. Code is available now (for the foolhardy.)
 Beta version soon (for the adventurous.)
 Included in Riak version 1.0 (for the masses.)




                                 50
API design is like sex:
     Make one mistake and
support it for the rest of your life.
           - @joshbloch

(Everything is subject to change.)


                 51
About Basho Technologies
<plug type=“shameless”>
 • Distributed company: ~30 people
 • Cambridge, MA / San Francisco, CA / Reston, VA
 • “We hate downtime, we hate overtime.”
 • Riak KV (Open Source)
 • Riak Support, Services, and Enterprise Features ($)

</plug>




                                 52
Thanks! / Questions?
 Also at OSCON...


 Rusty Klophaus        Mark Phillups
rusty@basho.com        mark@basho.com
         @rustyio      @pharkmillups




    Ryan Zezeski        Tony Falco
rzezeski@basho.com      tony@basho.com
        @rzezeski       @antonyfalco
END

Weitere ähnliche Inhalte

Was ist angesagt?

NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
N hidden gems in hippo forge and experience plugins (dec17)
N hidden gems in hippo forge and experience plugins (dec17)N hidden gems in hippo forge and experience plugins (dec17)
N hidden gems in hippo forge and experience plugins (dec17)Woonsan Ko
 
N hidden gems in forge (as of may '17)
N hidden gems in forge (as of may '17)N hidden gems in forge (as of may '17)
N hidden gems in forge (as of may '17)Woonsan Ko
 

Was ist angesagt? (7)

OrientDB
OrientDBOrientDB
OrientDB
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
Search@airbnb
Search@airbnbSearch@airbnb
Search@airbnb
 
Couch db
Couch dbCouch db
Couch db
 
N hidden gems in hippo forge and experience plugins (dec17)
N hidden gems in hippo forge and experience plugins (dec17)N hidden gems in hippo forge and experience plugins (dec17)
N hidden gems in hippo forge and experience plugins (dec17)
 
N hidden gems in forge (as of may '17)
N hidden gems in forge (as of may '17)N hidden gems in forge (as of may '17)
N hidden gems in forge (as of may '17)
 
Lokijs
LokijsLokijs
Lokijs
 

Andere mochten auch

A little about Message Queues - Boston Riak Meetup
A little about Message Queues - Boston Riak MeetupA little about Message Queues - Boston Riak Meetup
A little about Message Queues - Boston Riak MeetupBasho Technologies
 
Humans & Machines Ethics Canvas
Humans & Machines Ethics CanvasHumans & Machines Ethics Canvas
Humans & Machines Ethics CanvasPiush Vaish
 
Subway in Lisbon
Subway in Lisbon Subway in Lisbon
Subway in Lisbon Lavennder M
 
Performance-Based Funding – A New Era in Accountability?
Performance-Based Funding – A New Era in Accountability?Performance-Based Funding – A New Era in Accountability?
Performance-Based Funding – A New Era in Accountability?Ludmila Adamovica
 
Social Media Strategies for Schools for OASBO Conference
Social Media Strategies for Schools for OASBO ConferenceSocial Media Strategies for Schools for OASBO Conference
Social Media Strategies for Schools for OASBO ConferenceShane Haggerty
 
Ux och design som konverterar del 3
Ux och design som konverterar del 3Ux och design som konverterar del 3
Ux och design som konverterar del 3Wipcore
 
The threat to small business retirement savings
The threat to small business retirement savingsThe threat to small business retirement savings
The threat to small business retirement savingsU.S. Chamber of Commerce
 
"Unë do t'ju tregoj të ardhmen 1"
"Unë do t'ju tregoj të ardhmen 1""Unë do t'ju tregoj të ardhmen 1"
"Unë do t'ju tregoj të ardhmen 1"guest121301
 
Linkedin Slideshare Driving Force Btec
Linkedin Slideshare   Driving Force BtecLinkedin Slideshare   Driving Force Btec
Linkedin Slideshare Driving Force BtecIan Littlefield
 
CP2 Newport Beach 2010
CP2 Newport Beach 2010CP2 Newport Beach 2010
CP2 Newport Beach 2010nb4less
 
Storytelling + Experiences: Ingredients of a Successful Redesign
Storytelling + Experiences: Ingredients of a Successful RedesignStorytelling + Experiences: Ingredients of a Successful Redesign
Storytelling + Experiences: Ingredients of a Successful RedesignmStoner, Inc.
 
Semantic Techniques for Enabling Knowledge Reuse in Conceptual Modelling
Semantic Techniques for Enabling Knowledge Reuse in Conceptual ModellingSemantic Techniques for Enabling Knowledge Reuse in Conceptual Modelling
Semantic Techniques for Enabling Knowledge Reuse in Conceptual ModellingOscar Corcho
 
Glassdoor Summit: Ana Recio
Glassdoor Summit: Ana RecioGlassdoor Summit: Ana Recio
Glassdoor Summit: Ana RecioGlassdoor
 

Andere mochten auch (14)

A little about Message Queues - Boston Riak Meetup
A little about Message Queues - Boston Riak MeetupA little about Message Queues - Boston Riak Meetup
A little about Message Queues - Boston Riak Meetup
 
Humans & Machines Ethics Canvas
Humans & Machines Ethics CanvasHumans & Machines Ethics Canvas
Humans & Machines Ethics Canvas
 
Subway in Lisbon
Subway in Lisbon Subway in Lisbon
Subway in Lisbon
 
Performance-Based Funding – A New Era in Accountability?
Performance-Based Funding – A New Era in Accountability?Performance-Based Funding – A New Era in Accountability?
Performance-Based Funding – A New Era in Accountability?
 
Social Media Strategies for Schools for OASBO Conference
Social Media Strategies for Schools for OASBO ConferenceSocial Media Strategies for Schools for OASBO Conference
Social Media Strategies for Schools for OASBO Conference
 
Ux och design som konverterar del 3
Ux och design som konverterar del 3Ux och design som konverterar del 3
Ux och design som konverterar del 3
 
The threat to small business retirement savings
The threat to small business retirement savingsThe threat to small business retirement savings
The threat to small business retirement savings
 
"Unë do t'ju tregoj të ardhmen 1"
"Unë do t'ju tregoj të ardhmen 1""Unë do t'ju tregoj të ardhmen 1"
"Unë do t'ju tregoj të ardhmen 1"
 
Linkedin Slideshare Driving Force Btec
Linkedin Slideshare   Driving Force BtecLinkedin Slideshare   Driving Force Btec
Linkedin Slideshare Driving Force Btec
 
CP2 Newport Beach 2010
CP2 Newport Beach 2010CP2 Newport Beach 2010
CP2 Newport Beach 2010
 
Презентация агентства PRCI.Storytellers
Презентация агентства PRCI.StorytellersПрезентация агентства PRCI.Storytellers
Презентация агентства PRCI.Storytellers
 
Storytelling + Experiences: Ingredients of a Successful Redesign
Storytelling + Experiences: Ingredients of a Successful RedesignStorytelling + Experiences: Ingredients of a Successful Redesign
Storytelling + Experiences: Ingredients of a Successful Redesign
 
Semantic Techniques for Enabling Knowledge Reuse in Conceptual Modelling
Semantic Techniques for Enabling Knowledge Reuse in Conceptual ModellingSemantic Techniques for Enabling Knowledge Reuse in Conceptual Modelling
Semantic Techniques for Enabling Knowledge Reuse in Conceptual Modelling
 
Glassdoor Summit: Ana Recio
Glassdoor Summit: Ana RecioGlassdoor Summit: Ana Recio
Glassdoor Summit: Ana Recio
 

Ähnlich wie Querying Riak Just Got Easier - Introducing Secondary Indices

Elastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approachElastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approachSymfonyMu
 
Freebase: Wikipedia Mining 20080416
Freebase: Wikipedia Mining 20080416Freebase: Wikipedia Mining 20080416
Freebase: Wikipedia Mining 20080416zenkat
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developersSergio Bossa
 
Slides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLSlides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLDATAVERSITY
 
Application development with Oracle NoSQL Database 3.0
Application development with Oracle NoSQL Database 3.0Application development with Oracle NoSQL Database 3.0
Application development with Oracle NoSQL Database 3.0Anuj Sahni
 
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...DECK36
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRailsMike Dirolf
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMike Dirolf
 
Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)
Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)
Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)Kyle Davis
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDBMongoDB
 
CouchDB Open Source Bridge
CouchDB Open Source BridgeCouchDB Open Source Bridge
CouchDB Open Source BridgeChris Anderson
 
Schema registries and Snowplow
Schema registries and SnowplowSchema registries and Snowplow
Schema registries and Snowplowmiiker
 
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...MongoDB
 
Neo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick assNeo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick assEmil Eifrem
 

Ähnlich wie Querying Riak Just Got Easier - Introducing Secondary Indices (20)

MongoDb and Windows Azure
MongoDb and Windows AzureMongoDb and Windows Azure
MongoDb and Windows Azure
 
Elastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approachElastic search and Symfony3 - A practical approach
Elastic search and Symfony3 - A practical approach
 
Freebase: Wikipedia Mining 20080416
Freebase: Wikipedia Mining 20080416Freebase: Wikipedia Mining 20080416
Freebase: Wikipedia Mining 20080416
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developers
 
Slides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLSlides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQL
 
No Sql
No SqlNo Sql
No Sql
 
Application development with Oracle NoSQL Database 3.0
Application development with Oracle NoSQL Database 3.0Application development with Oracle NoSQL Database 3.0
Application development with Oracle NoSQL Database 3.0
 
Couchdb Nosql
Couchdb NosqlCouchdb Nosql
Couchdb Nosql
 
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)
Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)
Probabilistic Data Structures (Edmonton Data Science Meetup, March 2018)
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
CouchDB Open Source Bridge
CouchDB Open Source BridgeCouchDB Open Source Bridge
CouchDB Open Source Bridge
 
Schema registries and Snowplow
Schema registries and SnowplowSchema registries and Snowplow
Schema registries and Snowplow
 
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...
 
MongoDB Meetup
MongoDB MeetupMongoDB Meetup
MongoDB Meetup
 
Bids talk 9.18
Bids talk 9.18Bids talk 9.18
Bids talk 9.18
 
Neo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick assNeo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick ass
 
Elastc Search
Elastc SearchElastc Search
Elastc Search
 

Mehr von Rusty Klophaus

Everybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with ErlangEverybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with ErlangRusty Klophaus
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleRusty Klophaus
 
Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010Rusty Klophaus
 
Riak - From Small to Large - StrangeLoop
Riak - From Small to Large - StrangeLoopRiak - From Small to Large - StrangeLoop
Riak - From Small to Large - StrangeLoopRusty Klophaus
 
Riak - From Small to Large
Riak - From Small to LargeRiak - From Small to Large
Riak - From Small to LargeRusty Klophaus
 
Riak Core: Building Distributed Applications Without Shared State
Riak Core: Building Distributed Applications Without Shared StateRiak Core: Building Distributed Applications Without Shared State
Riak Core: Building Distributed Applications Without Shared StateRusty Klophaus
 
Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010Rusty Klophaus
 
Riak Search - Berlin Buzzwords 2010
Riak Search - Berlin Buzzwords 2010Riak Search - Berlin Buzzwords 2010
Riak Search - Berlin Buzzwords 2010Rusty Klophaus
 
Getting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - BostonGetting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - BostonRusty Klophaus
 

Mehr von Rusty Klophaus (9)

Everybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with ErlangEverybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with Erlang
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test Cycle
 
Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010
 
Riak - From Small to Large - StrangeLoop
Riak - From Small to Large - StrangeLoopRiak - From Small to Large - StrangeLoop
Riak - From Small to Large - StrangeLoop
 
Riak - From Small to Large
Riak - From Small to LargeRiak - From Small to Large
Riak - From Small to Large
 
Riak Core: Building Distributed Applications Without Shared State
Riak Core: Building Distributed Applications Without Shared StateRiak Core: Building Distributed Applications Without Shared State
Riak Core: Building Distributed Applications Without Shared State
 
Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010
 
Riak Search - Berlin Buzzwords 2010
Riak Search - Berlin Buzzwords 2010Riak Search - Berlin Buzzwords 2010
Riak Search - Berlin Buzzwords 2010
 
Getting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - BostonGetting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - Boston
 

Kürzlich hochgeladen

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Kürzlich hochgeladen (20)

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

Querying Riak Just Got Easier - Introducing Secondary Indices

  • 1. Querying Riak Just Got Easier Secondary Indices in Riak OSCON Data Portland, Oregon · July 2011 Basho Technologies rusty@basho.com Rusty Klophaus twitter: rustyio
  • 2. tl;dr: Secondary Indices fundamentally change data modeling in Riak. Model one-to-one, one-to-many, or many-to-many relationships simply and efficiently. 2
  • 3. But first, a little bit about tradeoffs and NoSQL. 3
  • 4.
  • 5. Which one would you choose? It depends on their abilities. It also depends on the quest. Fools! 5
  • 6. Rule #1 Your character will fare better in certain environments depending on his (or her) abilities. 6
  • 7. Rule #2 There are always tradeoffs 7
  • 8. Databases are like RPG character classes. They focus on certain abilities. 8
  • 9. Database Abilities (1/2) Schema Flexible Schema ⟩ Pre-Defined Schema ⟩ Typed Fields ⟩ Untyped Fields ⟩ Blob Operation Skew Mostly Writes ⟩ 50/50 ⟩ Mostly Reads Disk Persistence Every Operation ⟩ Delayed Batch ⟩ Flush ⟩ Never Transactions Global ⟩ Table ⟩ Object ⟩ None Data Relations Ad-Hoc ⟩ Pre-Defined ⟩ None Operation Order Random ⟩ Sequential 9
  • 10. Database Abilities (2/2) Secondary Queries Ad-Hoc ⟩ Pre-Determined ⟩ None Native Data Types Tables ⟩ XML ⟩ JSON ⟩ Text ⟩ Blob Scalable Data Center ⟩ Cluster ⟩ Single Machine Failure-Tolerance Data Center ⟩ Network ⟩ Machine ⟩ Disk ⟩ Sector ⟩ None Stability Predictable Latency ⟩ Variable Latency Performance Ops Per Second And so on... 10
  • 11. For a long time, industry focused on just one manifestation of database abilities: SELECT * FROM Quests «Relational Database» 11
  • 12. The World Has Changed Global Internet “Everyone is connected...” ile Soc ob ial M Mobile Computing Global “...all the time...” Social Networking “...producing more data (in more varieties) than ever.” 12
  • 13. NoSQL is about alternatives. Focus on different abilities, environments, and tradeoffs. 13
  • 14. As a database consumer, you need to understand the basic tradeoffs of each solution. In turn, database producers should strive to make those tradeoffs clear. 14
  • 15. There are always tradeoffs. Databases that claim to do everything well are lying. 15
  • 16. Where Does Riak Fit? 16
  • 17. 17
  • 18. Have you ever been burned by: hardware failure? overloaded servers? emergencies at 2am? 17
  • 19. Does your quest involve: SLAs that mention uptime or latency? data that you can’t afford to lose? 18
  • 20. If so, Riak’s tradeoffs will make sense. If not, they won’t. 19
  • 21. Riak KV - Some Tradeoffs (1/3) Amazon’s Dynamo Architecture ✔Distributed, scalable, no single point of failure. ✘ No transactions; trade strong consistency for eventual consistency. 20
  • 22. Riak KV - Some Tradeoffs (2/3) Extremely Focused on Operations ✔Simple to install, manage, connect a cluster. ✔Has been called “plumbing”, ie: it just works. ✘ Historically, developer-facing features lagged behind. This is rapidly changing. # Scale out... riak-admin join nodename@hostname # Scale back in... riak-admin leave 21
  • 23. Riak KV - Some Tradeoffs (3/3) Key/Value Model ✔Simple, straightforward, content-type agnostic. ✘ More difficult to discover your data. (Queryability.) Let’s dive deeper into “queryability.” 22
  • 24. Current Options for Querying Riak MapReduce Provide set of starting keys, filter via map. MapReduce is meant for calculations/aggregations, not queries. Riak Search Full-text search in Riak. Opinionated, assumes your document is prose. Roll Your Own Indices Difficult to get right. More code to maintain. Often introduces SPOFs. 23
  • 26. What are Secondary Indices? 25
  • 27. What Are Secondary Indices? Goals Provide *simple* indexing on Riak objects. Maintain Riak’s operational advantages. Make a developer’s life easier. How Does It Work? At write time, tag your data with key/value metadata. Query the metadata, get matching objects. 26
  • 28. For example... BUCKET KEY VALUE INDEX METADATA loot gauntlet24 category: armor price: 400 ... “Gauntlets of Shininess” 27
  • 29. Index an Object # Store an object with: # Bucket: loot # Key: gauntlet24 # Fields: # - category: armor # - price: 400 curl -X PUT -d "OPAQUE_VALUE" -H "x-riak-index-category_bin: armor" -H "x-riak-index-price_int: 400" http://127.0.0.1:8098/riak/loot/gauntlet24 28
  • 30. Query the Index # Query for category_bin = "armor" curl http://127.0.0.1:8098/buckets/loot/index/category_bin/armor {"keys":["gauntlet24"]} # Query for price_int between 300 and 500 curl http://127.0.0.1:8098/buckets/loot/index/price_int/300/500 {"keys":["gauntlet24"]} 29
  • 31. Query Syntax /buckets/$BUCKET/index/$FIELDNAME/$VALUE /buckets/$BUCKET/index/$FIELDNAME/$START/$END $BUCKET Bucket to query. $FIELDNAME Must end with “_bin” for binaries, “_int” for integers. Special field $key for key range lookups. $VALUE / $START / $END Equality or range queries. 30
  • 33. Key/Value Lookups Retrieve a user’s session. Retrieve an object by key. sessions/ { 8b6cfaa foo: "bar", ... } 32
  • 34. Key/Value Lookups Use Case Retrieve a user’s session. Retrieve an object by key. Generic Case Object sessions/ { 8b6cfaa foo: "bar", ... } Key Value 33
  • 35. Alternate Keys / One-to-One Relationships Retrieve a user by username or by email address. An object has multiple names. users/ { rusty username: "rusty", email: "rusty@basho.com", twitter: "rustyio", ... } emails/ "rusty" rusty@basho.com 34
  • 36. Alternate Keys Wit Retieve a user by username or by email address. Seco h nda Ind ry An object has multiple names. ices ! users/ { rusty username: "rusty", email: "rusty@basho.com", twitter: "rustyio", ... } Indexes: email_bin: rusty@basho.com twitter_bin: rustyio 35
  • 37. Ownership / One-to-Many Relationships A person has many cars. Parent has a *small* number of children. people/ { frank cars: [ { plate: "ET7-B928", color: "red", type: "corvette", } ... ] } 36
  • 38. Ownership / One-to-Many Relationships Wit A person has many cars. Seco h nda Ind ry Parent has a *small* number of children. ices ! people/ { frank cars: [ { plate: "ET7-B928", color: "red", type: "corvette", }, ... ] } Indexes: cars_plate_bin: ET7-B928 cars_plate_bin: BUB-7911 ... 37
  • 39. Ownership / One-to-Many Relationships A user has many status updates. Parent has a *large* number of children. users/ { rustyio status_updates: [ "18258713", "87187597", "71117389", ... ] } statuses/ { 18258713 author: "rustyio" reply_to: "barackobama" text: "Sorry, can't hang out now, I'm speaking at OSCON Data." }38
  • 40. Ownership / One-to-Many Relationships Wit A user has many status updates. Seco h nda Ind ry Parent has a *large* number of children. ices ! users/ { rustyio ... } statuses/ { 18258713 author: "rustyio" reply_to: "barackobama" text: "Sorry, can't hang out now, I'm speaking at OSCON Data." } Indexes: author_bin: rustyio reply_to_bin: barackobama 39
  • 41. Membership / Many-to-Many Relationships A user joins one or more clubs, a club has users. A group has many members. users/ { rusty clubs: [ "dc_larping_club", ... ] } clubs/ { dc_larpers users: [ "rusty", "frank" ] } 40
  • 42. Membership / Many-to-Many Relationships Wit A user joins one or more clubs, a club has users. Seco h nda Ind ry A group has many members. ices ! users/ { rusty clubs: [ "dc_larping_club", "nascar_fans", ... ] } Indexes: club_bin: dc_larping_club club_bin: nascar_fans clubs/ ... dc_larpers 41
  • 43. What Were The Challenges? 42
  • 44. Challenge: Ambitious Prototyping (1/5) Why Difficult? Early prototypes contained support for: • A SQL-like query language (RQL), with compound queries • Sorting and pagination, with intelligent caching • Inline map/reduce • Extensible data types Arguably too clever. Allowed developers to shoot selves in foot. How Solved? Ruthlessly cut features & simplify. 43
  • 45. Challenge: Data Types (2/5) Why Difficult? What type is a given field? Naming convention, or global dictionary? What if the user wants to change the type? What if the user provides a value of the wrong type? How Solved? Field type determined by suffix. (field1_bin, field2_int) Different type == different field name. Pre-commit hook to validate data types. 44
  • 46. Challenge: Disk Based Storage (3/5) Why Difficult? Disk is slow. (http://highscalability.com/numbers-everyone-should-know) Need data structures that are both read and write efficient, for data of unpredictable sizes and shapes. How Solved? Leverage merge_index (data engine from Riak Search). Investigate LevelDB (library from Google) 45
  • 47. Challenge: Atomicity (4/5) Why Difficult? Need to keep the index synchronized with the object value. Account for eventual consistency, siblings, handoff, replication, etc. What happens during node failure / partial cluster situations? How Solved? Make the KV object the authoritative data. Indexed data is discarded if the object moves. 46
  • 48. Challenge: System is Distributed (5/5) Why Difficult? Index is split over many different partitions. *Don’t* need to query every partition. *Do* need to be smart about which partitions to query. How Solved? Extend riak_core (distribution layer) with ability to broadcast command to covering set of partitions. (h/t to Kelly McLaughlin, @_klm) 47
  • 49. Indexing Client API User tags the object with metadata. Cluster Write Coordinator Validate that metadata parses. riak_kv_put_fsm PUT Request Node VNode Coordinator riak_core_vnode_master VNode (Virtual Node) Core VNode riak_core_vnode KV VNode riak_kv_vnode Backend Stores object in bitcask, riak_kv_index_backend index metadata in merge_index.
  • 50. Querying Client User issues a query API against metadata. Cluster Query Coordinator riak_index_query_fsm Coverage Logic riak_core_coverage_fsm Query Request Node VNode Coordinator riak_core_vnode_master VNode (Virtual Node) Core VNode riak_core_vnode KV VNode riak_kv_vnode Backend Runs query against index, riak_kv_index_backend replies with results.
  • 51. Next Steps Publish We are open source. Code is available now (for the foolhardy.) Beta version soon (for the adventurous.) Included in Riak version 1.0 (for the masses.) 50
  • 52. API design is like sex: Make one mistake and support it for the rest of your life. - @joshbloch (Everything is subject to change.) 51
  • 53. About Basho Technologies <plug type=“shameless”> • Distributed company: ~30 people • Cambridge, MA / San Francisco, CA / Reston, VA • “We hate downtime, we hate overtime.” • Riak KV (Open Source) • Riak Support, Services, and Enterprise Features ($) </plug> 52
  • 54. Thanks! / Questions? Also at OSCON... Rusty Klophaus Mark Phillups rusty@basho.com mark@basho.com @rustyio @pharkmillups Ryan Zezeski Tony Falco rzezeski@basho.com tony@basho.com @rzezeski @antonyfalco
  • 55. END