SlideShare a Scribd company logo
FleetDB
A Schema-Free Database in Clojure

         Mark McGranaghan


           January 8, 2010
Motivation


Walkthrough


Implementation


QA
Motivation
Motivation



       optimize for agile development
Walkthrough



     Client Quickstart
     Basic Queries
     Concurrency Tools
Client Quickstart



  (use ’fleetdb.client)
  (def client (connect))

  (client ["ping"])
  => "pong"
Insert



  (client
    ["insert" "accounts"
      {"id" 1 "owner" "Eve" "credits" 100}])
Insert



  (client
    ["insert" "accounts"
      {"id" 1 "owner" "Eve" "credits" 100}])

  => 1
Select



  (client
    ["select" "accounts" {"where" ["=" "id" 1]}])
Select



  (client
    ["select" "accounts" {"where" ["=" "id" 1]}])

  => [{"id" 1 "owner" "Eve" "credits" 100}]
Select with Conditions



  (client
    ["select" "accounts"
      {"where" [">=" "credits" 150]}])
Select with Order and Limit



  (client
    ["select" "accounts"
      {"order" ["credits" "asc"] "limit" 2}])
Update



  (client
    ["update" "accounts" {"credits" 105}
      {"where" ["=" "owner" "Eve"]}])
Explain (I)


  (client
    ["explain" ["select" "accounts"
                 {"where" ["=" "owner" "Eve"]}]])
Explain (I)


  (client
    ["explain" ["select" "accounts"
                 {"where" ["=" "owner" "Eve"]}]])

  => ["filter" ["=" "owner" "Eve"]
       ["collection-scan" "accounts"]]
Create Index



  (client
    ["create-index" "accounts" "owner"])
Explain (II)



  (client
    ["explain" ["select" "accounts"
                 {"where" ["=" "owner" "Eve"]}]])

  => ["index-lookup" ["accounts" "owner" "Eve"]]]
Multi-Write
Multi-Write



  (client
    ["multi-write"
     [write-query-1 write-query-2 ...]])
Multi-Write



  (client
    ["multi-write"
     [write-query-1 write-query-2 ...]])

  => [result-1 result-2 ...]
Checked-Write
Checked-Write


  (client
    ["checked-write"
     read-query
     expected-read-result
     write-query])
Checked-Write


  (client
    ["checked-write"
     read-query
     expected-read-result
     write-query])

  => [true write-result]
Checked-Write


  (client
    ["checked-write"
     read-query
     expected-read-result
     write-query])

  => [true write-result]

  => [false actual-read-result]
Implementation



     Background
     Organization
     Key ideas
Background



    http://clojure.org/data_structures
    http://clojure.org/sequences
    http://clojure.org/state
Organization
Organization



     fleetdb.core: pure functions
Organization



     fleetdb.core: pure functions
     fleetdb.embedded: identity and durability
Organization



     fleetdb.core: pure functions
     fleetdb.embedded: identity and durability
     fleetdb.server: network interface
fleetdb.core



    Pure functions
fleetdb.core



    Pure functions
    Databases as Clojure data structures
fleetdb.core



    Pure functions
    Databases as Clojure data structures
    Read: db + query → result
fleetdb.core



    Pure functions
    Databases as Clojure data structures
    Read: db + query → result
    ‘Write’: db + query → result + new db
fleetdb.core Query Planner
fleetdb.core Query Planner

    Implements declarative queries
fleetdb.core Query Planner

    Implements declarative queries
    Database + query → plan
fleetdb.core Query Planner

      Implements declarative queries
      Database + query → plan

  ["select" "accounts"
    {"where" ["=" "owner" "Eve"]}]
fleetdb.core Query Planner

      Implements declarative queries
      Database + query → plan

  ["select" "accounts"
    {"where" ["=" "owner" "Eve"]}]

  ["filter" ["=" "owner" "Eve"]
    ["record-scan" "accounts"]]
fleetdb.core Query Planner

      Implements declarative queries
      Database + query → plan

  ["select" "accounts"
    {"where" ["=" "owner" "Eve"]}]

  ["filter" ["=" "owner" "Eve"]
    ["record-scan" "accounts"]]

  ["index-lookup" ["accounts" "owner" "Eve"]]
fleetdb.core Query Executor
fleetdb.core Query Executor


    Database + plan → result
fleetdb.core Query Executor


      Database + plan → result

  ["filter" ["=" "owner" "Eve"]
    ["record-scan" "accounts"]]
fleetdb.core Query Executor


      Database + plan → result

  ["filter" ["=" "owner" "Eve"]
    ["record-scan" "accounts"]]

  (filter (fn [r] (= (r "owner") "Eve"))
    (vals (:rmap (db "accounts"))))
fleetdb.embedded



    Wraps fleetdb.core
fleetdb.embedded



    Wraps fleetdb.core
    Adds identity and durability
fleetdb.embedded



    Wraps fleetdb.core
    Adds identity and durability
    Databases in atoms
fleetdb.embedded



    Wraps fleetdb.core
    Adds identity and durability
    Databases in atoms
    Append-only log
fleetdb.embedded Read Path
fleetdb.embedded Read Path



    Dereference database atom
fleetdb.embedded Read Path



    Dereference database atom
    Pass to fleetdb.core
fleetdb.embedded Read Path



    Dereference database atom
    Pass to fleetdb.core
    Return result
fleetdb.embedded Write Path
fleetdb.embedded Write Path


    Enter fair lock
fleetdb.embedded Write Path


    Enter fair lock
    Dereference database atom
fleetdb.embedded Write Path


    Enter fair lock
    Dereference database atom
    Pass to fleetdb.core
fleetdb.embedded Write Path


    Enter fair lock
    Dereference database atom
    Pass to fleetdb.core
    Append query to log
fleetdb.embedded Write Path


    Enter fair lock
    Dereference database atom
    Pass to fleetdb.core
    Append query to log
    Swap in new database value
fleetdb.embedded Write Path


    Enter fair lock
    Dereference database atom
    Pass to fleetdb.core
    Append query to log
    Swap in new database value
    Return result
fleetdb.server



    Wraps fleetdb.embedded
fleetdb.server



    Wraps fleetdb.embedded
    Adds JSON client API
Aside: Source Size
Aside: Source Size


                Lines of Code
              core         630
              embedded 130
              server       120
              lint         280
              utilities    140
              total       1300
Takeaways
Takeaways



     Clojure’s data structures are awesome
Takeaways



     Clojure’s data structures are awesome
     Clojure is viable for infrastructure software
Takeaways



     Clojure’s data structures are awesome
     Clojure is viable for infrastructure software
     Try FleetDB!
Thanks for listening!

    Questions?
http://FleetDB.org

http://github.com/mmcgrana

More Related Content

What's hot (20)

PDF
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB
 
PDF
Cache metadata
Joris Vercammen
 
PDF
Presto in Treasure Data
Mitsunori Komatsu
 
PDF
Google App Engine Developer - Day4
Simon Su
 
PPTX
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays
 
ODP
Aggregation Framework in MongoDB Overview Part-1
Anuj Jain
 
PDF
Aggregation Framework MongoDB Days Munich
Norberto Leite
 
PDF
The Ring programming language version 1.9 book - Part 49 of 210
Mahmoud Samir Fayed
 
PPTX
Slick: Bringing Scala’s Powerful Features to Your Database Access
Rebecca Grenier
 
PDF
MariaDB and Clickhouse Percona Live 2019 talk
Alexander Rubin
 
PDF
Utilizing Powerful Extensions for Analytics and Operations
Neo4j
 
PDF
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Cliff Seal
 
PDF
Android HttpClient - new slide!
Chalermchon Samana
 
PDF
Green dao
彥彬 洪
 
PDF
Green dao
Droidcon Berlin
 
PDF
Terraforming the Kubernetes Land
Radek Simko
 
PPTX
Getting started with Elasticsearch and .NET
Tomas Jansson
 
PDF
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB
 
ODP
MongoDB San Francisco DrupalCon 2010
Karoly Negyesi
 
PDF
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Mark Needham
 
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB
 
Cache metadata
Joris Vercammen
 
Presto in Treasure Data
Mitsunori Komatsu
 
Google App Engine Developer - Day4
Simon Su
 
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays
 
Aggregation Framework in MongoDB Overview Part-1
Anuj Jain
 
Aggregation Framework MongoDB Days Munich
Norberto Leite
 
The Ring programming language version 1.9 book - Part 49 of 210
Mahmoud Samir Fayed
 
Slick: Bringing Scala’s Powerful Features to Your Database Access
Rebecca Grenier
 
MariaDB and Clickhouse Percona Live 2019 talk
Alexander Rubin
 
Utilizing Powerful Extensions for Analytics and Operations
Neo4j
 
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Cliff Seal
 
Android HttpClient - new slide!
Chalermchon Samana
 
Green dao
彥彬 洪
 
Green dao
Droidcon Berlin
 
Terraforming the Kubernetes Land
Radek Simko
 
Getting started with Elasticsearch and .NET
Tomas Jansson
 
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB
 
MongoDB San Francisco DrupalCon 2010
Karoly Negyesi
 
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Mark Needham
 

Viewers also liked (11)

PDF
Clojure presentation
Jéferson Machado
 
PDF
FleetDB
Diego Pacheco
 
PDF
HBase Schema Design - HBase-Con 2012
Ian Varley
 
KEY
Schema Design with MongoDB
rogerbodamer
 
PDF
Freebase Schema
Jamie Taylor
 
DOCX
Báo cáo bài tập lớn môn Cơ sở dữ liệu - Học viện công nghệ bưu chính viễn thông
Huyen Pham
 
DOCX
Employee management system1
supriya
 
PPTX
service quality-models-ppt
subroto36
 
PPTX
Services Marketing - Service Quality GAPS Model
Himansu S Mahapatra
 
PPTX
Medical Store Management System Software Engineering Project
hani2253
 
PPSX
Employee Management System
vivek shah
 
Clojure presentation
Jéferson Machado
 
FleetDB
Diego Pacheco
 
HBase Schema Design - HBase-Con 2012
Ian Varley
 
Schema Design with MongoDB
rogerbodamer
 
Freebase Schema
Jamie Taylor
 
Báo cáo bài tập lớn môn Cơ sở dữ liệu - Học viện công nghệ bưu chính viễn thông
Huyen Pham
 
Employee management system1
supriya
 
service quality-models-ppt
subroto36
 
Services Marketing - Service Quality GAPS Model
Himansu S Mahapatra
 
Medical Store Management System Software Engineering Project
hani2253
 
Employee Management System
vivek shah
 
Ad

Similar to FleetDB A Schema-Free Database in Clojure (20)

PDF
Kief Morris - Infrastructure is terrible
Thoughtworks
 
PDF
Immutable Deployments with AWS CloudFormation and AWS Lambda
AOE
 
PDF
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY
Puppet
 
PDF
Type safe embedded domain-specific languages
Arthur Xavier
 
PDF
Infrastructure-as-code: bridging the gap between Devs and Ops
Mykyta Protsenko
 
PDF
Infrastructure as code terraformujeme cloud
ViliamPucik
 
PDF
SF Elixir Meetup - RethinkDB
Peter Hamilton
 
PDF
Learn Cloud-Native .NET: Core Configuration Fundamentals with Steeltoe
VMware Tanzu
 
PPTX
Google apps script database abstraction exposed version
Bruce McPherson
 
PDF
Amazon Web Services for PHP Developers
Jeremy Lindblom
 
PDF
Cutting through the fog of cloud
Kyle Rames
 
PDF
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
NETWAYS
 
PDF
Atmosphere Conference 2015: Taming the Modern Datacenter
PROIDEA
 
PPTX
MongoDB World 2018: Keynote
MongoDB
 
PDF
OSDC 2012 | Scaling with MongoDB by Ross Lawley
NETWAYS
 
PPTX
Capture, record, clip, embed and play, search: video from newbie to ninja
Vito Flavio Lorusso
 
KEY
Couchdb: No SQL? No driver? No problem
delagoya
 
PPT
Distributed Queries in IDS: New features.
Keshav Murthy
 
PDF
Cutting Edge Data Processing with PHP & XQuery
William Candillon
 
PDF
Building Web-API without Rails, Registration or SMS
Pivorak MeetUp
 
Kief Morris - Infrastructure is terrible
Thoughtworks
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
AOE
 
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY
Puppet
 
Type safe embedded domain-specific languages
Arthur Xavier
 
Infrastructure-as-code: bridging the gap between Devs and Ops
Mykyta Protsenko
 
Infrastructure as code terraformujeme cloud
ViliamPucik
 
SF Elixir Meetup - RethinkDB
Peter Hamilton
 
Learn Cloud-Native .NET: Core Configuration Fundamentals with Steeltoe
VMware Tanzu
 
Google apps script database abstraction exposed version
Bruce McPherson
 
Amazon Web Services for PHP Developers
Jeremy Lindblom
 
Cutting through the fog of cloud
Kyle Rames
 
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
NETWAYS
 
Atmosphere Conference 2015: Taming the Modern Datacenter
PROIDEA
 
MongoDB World 2018: Keynote
MongoDB
 
OSDC 2012 | Scaling with MongoDB by Ross Lawley
NETWAYS
 
Capture, record, clip, embed and play, search: video from newbie to ninja
Vito Flavio Lorusso
 
Couchdb: No SQL? No driver? No problem
delagoya
 
Distributed Queries in IDS: New features.
Keshav Murthy
 
Cutting Edge Data Processing with PHP & XQuery
William Candillon
 
Building Web-API without Rails, Registration or SMS
Pivorak MeetUp
 
Ad

More from elliando dias (20)

PDF
Clojurescript slides
elliando dias
 
PDF
Why you should be excited about ClojureScript
elliando dias
 
PDF
Functional Programming with Immutable Data Structures
elliando dias
 
PPT
Nomenclatura e peças de container
elliando dias
 
PDF
Geometria Projetiva
elliando dias
 
PDF
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
PDF
Javascript Libraries
elliando dias
 
PDF
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
PDF
Ragel talk
elliando dias
 
PDF
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
PDF
Introdução ao Arduino
elliando dias
 
PDF
Minicurso arduino
elliando dias
 
PDF
Incanter Data Sorcery
elliando dias
 
PDF
Rango
elliando dias
 
PDF
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
PDF
The Digital Revolution: Machines that makes
elliando dias
 
PDF
Hadoop + Clojure
elliando dias
 
PDF
Hadoop - Simple. Scalable.
elliando dias
 
PDF
Hadoop and Hive Development at Facebook
elliando dias
 
PDF
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 
Clojurescript slides
elliando dias
 
Why you should be excited about ClojureScript
elliando dias
 
Functional Programming with Immutable Data Structures
elliando dias
 
Nomenclatura e peças de container
elliando dias
 
Geometria Projetiva
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
Ragel talk
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
elliando dias
 
Minicurso arduino
elliando dias
 
Incanter Data Sorcery
elliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
The Digital Revolution: Machines that makes
elliando dias
 
Hadoop + Clojure
elliando dias
 
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 

Recently uploaded (20)

PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 

FleetDB A Schema-Free Database in Clojure