MongoDB: A New Genie in the LAMP (Stack) Kristina Chodorow - - PowerPoint PPT Presentation

mongodb a new genie in the lamp stack
SMART_READER_LITE
LIVE PREVIEW

MongoDB: A New Genie in the LAMP (Stack) Kristina Chodorow - - PowerPoint PPT Presentation

MongoDB: A New Genie in the LAMP (Stack) Kristina Chodorow kristina@mongodb.org a retrospective SQL invented now 1974 2010 SQL invented now 1974 2010 SQL invented now 1974 2010 1979 SQL invented now 1974 2010 1979 SQL


slide-1
SLIDE 1

Kristina Chodorow kristina@mongodb.org

MongoDB: A New Genie in the LAMP (Stack)

slide-2
SLIDE 2
slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5

a retrospective

slide-6
SLIDE 6

SQL invented 1974 now 2010

slide-7
SLIDE 7
slide-8
SLIDE 8

SQL invented 1974 now 2010

slide-9
SLIDE 9

SQL invented 1974 now 2010 1979

slide-10
SLIDE 10

SQL invented 1974 now 2010 1979

slide-11
SLIDE 11

SQL invented 1974 now 2010 1979 1982-1996

slide-12
SLIDE 12

SQL invented 1974 now 2010 1995 1979 1982-1996

slide-13
SLIDE 13

SQL invented 1974 now 2010 1995 1979 2010 1982-1996

slide-14
SLIDE 14

until 2009...

slide-15
SLIDE 15

until 2009...

slide-16
SLIDE 16

SQL invented 1974 now 2010 1995 1979 2010 1982-1996

slide-17
SLIDE 17
slide-18
SLIDE 18

databases

contain tables contain rows

server

slide-19
SLIDE 19

databases

contain tables contain rows

schema server

slide-20
SLIDE 20

databases

contain tables contain rows

joins schema server

slide-21
SLIDE 21

things have changed in the last 15 years

duh

slide-22
SLIDE 22
slide-23
SLIDE 23
slide-24
SLIDE 24
slide-25
SLIDE 25
slide-26
SLIDE 26

SQL invented 1974 now 2010 1995 1979 2010 1982-1996

slide-27
SLIDE 27

SQL invented 1974 now 2010 1995 1979 2010 1995 1982-1996

slide-28
SLIDE 28

SQL invented 1974 now 2010 1995 1979 2010 1995 2738 websites 1994 1982-1996

slide-29
SLIDE 29

SQL invented 1974 now 2010 1995 1979 2010 1995 2738 websites 1994 >10,000 websites 1995 1982-1996

slide-30
SLIDE 30

SQL invented 1974 now 2010 1995 1979 2010 1998 1995 2738 websites 1994 >10,000 websites 1995 1982-1996

slide-31
SLIDE 31

We should get a mainframe, old chap. Harumph.

slide-32
SLIDE 32

never leave me!

slide-33
SLIDE 33

downtime becomes important

slide-34
SLIDE 34
slide-35
SLIDE 35

hardware

  • k?
slide-36
SLIDE 36

hardware

  • k?

failover to slave no

slide-37
SLIDE 37

hardware

  • k?

failover to slave fsck worked? yes no

slide-38
SLIDE 38

hardware

  • k?

failover to slave fsck worked? yes no no

slide-39
SLIDE 39

hardware

  • k?

failover to slave fsck worked? transaction log yes yes no no

slide-40
SLIDE 40

hardware

  • k?

failover to slave fsck worked? transaction log yes yes no no no

slide-41
SLIDE 41

hardware

  • k?

failover to slave fsck worked? transaction log yay! yes yes yes no no no

slide-42
SLIDE 42

hardware

  • k?

failover to slave fsck worked? transaction log yay! yes yes yes no no no

slide-43
SLIDE 43

SQL invented 1974 now 2010 1995 1979 2010 1998 1995 2738 websites 1994 >10,000 websites 1995 1982-1996

slide-44
SLIDE 44

SQL invented 1974 now 2010 1995 1979 2010 2004 1998 1995 2738 websites 1994 >10,000 websites 1995 1982-1996

slide-45
SLIDE 45

SQL invented 1974 now 2010 1995 1979 2010 2004 1998 1995 BigTable 2004 2738 websites 1994 >10,000 websites 1995 1982-1996

slide-46
SLIDE 46

SQL invented 1974 now 2010 1995 1979 2010 MapReduce 2005 2004 1998 1995 BigTable 2004 2738 websites 1994 >10,000 websites 1995 1982-1996

slide-47
SLIDE 47
slide-48
SLIDE 48

you left me!

slide-49
SLIDE 49

eh, whatever.

slide-50
SLIDE 50
slide-51
SLIDE 51

prod1.example.co m prod2.example.co m

slide-52
SLIDE 52

prod1.example.co m prod2.example.co m

slide-53
SLIDE 53

prod1.example.co m prod2.example.co m

slide-54
SLIDE 54

prod1.example.co m prod2.example.co m

slide-55
SLIDE 55
slide-56
SLIDE 56

prod1.example.co m prod2.example.co m

slide-57
SLIDE 57

prod1.example.co m prod2.example.co m

slide-58
SLIDE 58

prod1.example.co m

?

prod2.example.co m

slide-59
SLIDE 59

prod2.example.co m prod1.example.co m

slide-60
SLIDE 60

prod2.example.co m prod1.example.co m

?

slide-61
SLIDE 61

prod2.example.co m prod1.example.co m

slide-62
SLIDE 62

prod2.example.co m prod1.example.co m

slide-63
SLIDE 63

primary secondary passive secondary

slide-64
SLIDE 64

secondary passive secondary

My priority is 2 My priority is 1

slide-65
SLIDE 65

primary passive secondary

slide-66
SLIDE 66

secondary passive secondary

I'm 3ms behind I'm 2ms behind

slide-67
SLIDE 67

secondary passive primary

slide-68
SLIDE 68

passive

I'll still take reads.

slide-69
SLIDE 69
slide-70
SLIDE 70
slide-71
SLIDE 71
slide-72
SLIDE 72
slide-73
SLIDE 73
  • kay
slide-74
SLIDE 74

?

slide-75
SLIDE 75

make sure two slaves have this

slide-76
SLIDE 76
slide-77
SLIDE 77
slide-78
SLIDE 78
slide-79
SLIDE 79

all set

slide-80
SLIDE 80
slide-81
SLIDE 81
slide-82
SLIDE 82

EXCEPTION

slide-83
SLIDE 83

EXCEPTION

slide-84
SLIDE 84

E

slide-85
SLIDE 85
slide-86
SLIDE 86

SQL invented 1974 now 2010 1995 1979 2010 MapReduce 2005 2004 1998 1995 BigTable 2004 2738 websites 1994 >10,000 websites 1995 1982-1996 2007

slide-87
SLIDE 87

Application PHP Linux Apache

slide-88
SLIDE 88

getting started

slide-89
SLIDE 89

www.mongodb.org

slide-90
SLIDE 90

$ mysqld

slide-91
SLIDE 91

$ mongod

slide-92
SLIDE 92

$ mysql

slide-93
SLIDE 93

$ mongo

slide-94
SLIDE 94

$ mongo MongoDB shell version 1.6.0 connecting to: test >

slide-95
SLIDE 95

$ mongo MongoDB shell version 1.6.0 connecting to: test > db

slide-96
SLIDE 96

$ mongo MongoDB shell version 1.6.0 connecting to: test > db test >

slide-97
SLIDE 97

$ mongo MongoDB shell version 1.6.0 connecting to: test > db test >

NO ADMINISTRATION

slide-98
SLIDE 98

$ mongo MongoDB shell version 1.6.0 connecting to: test > db test > table = db.foo

slide-99
SLIDE 99

server

slide-100
SLIDE 100

databases server

slide-101
SLIDE 101

databases

contain tables

server

slide-102
SLIDE 102

databases

contain tables

server

slide-103
SLIDE 103

databases

contain tables

server c

  • l

l e c t i

  • n

s

slide-104
SLIDE 104

databases

contain rows

server

contain tables

c

  • l

l e c t i

  • n

s

slide-105
SLIDE 105

databases

contain rows

server

contain tables

c

  • l

l e c t i

  • n

s

slide-106
SLIDE 106

databases

contain rows

server

contain tables

c

  • l

l e c t i

  • n

s documents

slide-107
SLIDE 107

databases

contain rows

server

contain tables

c

  • l

l e c t i

  • n

s documents schema

slide-108
SLIDE 108

databases

contain rows

server

contain tables

c

  • l

l e c t i

  • n

s documents schema joins

slide-109
SLIDE 109

databases

contain collections contain documents

server

slide-110
SLIDE 110

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test > collection = db.foo

slide-111
SLIDE 111

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test > collection = db.foo

NO ADMINISTRATION

slide-112
SLIDE 112

{ "name" : "kristina", "contact info" : { "twitter" : "@kchodorow", "email" : "kristina@10gen.com" }, "friends" : 400232, "pic" : BinData(...) "member since" : new Date() }

slide-113
SLIDE 113

> doc = { "name" : "kristina", "contact info" : { "twitter" : "@kchodorow", "email" : "kristina@10gen.com" }, "friends" : 400232, "pic" : BinData(...) "member since" : new Date() }

slide-114
SLIDE 114

> db.foo.insert(doc)

slide-115
SLIDE 115

> db.foo.findOne({"name" : "kristina"});

slide-116
SLIDE 116

> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"})

slide-117
SLIDE 117

> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"}) > db.foo.find({ ... "member since" : { ... "$gt" : yesterday, ... "$lt" : today ... }})

slide-118
SLIDE 118

> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"}) > db.foo.find({ ... "member since" : { ... "$gt" : yesterday, ... "$lt" : today ... }}).sort({friends : 1}).limit(10). ... skip(100)

slide-119
SLIDE 119

db.people.update( {name : "kristina"},

slide-120
SLIDE 120

db.people.update( {name : "kristina"}, {$set :

slide-121
SLIDE 121

db.people.update( {name : "kristina"}, {$set : {"contact.website" : "snailinaturtleneck.com" }});

slide-122
SLIDE 122

> db.pageviews.update( {url : "example.com"}, {$inc : {pageviews : 1}}, true)

slide-123
SLIDE 123
slide-124
SLIDE 124
slide-125
SLIDE 125

some features

slide-126
SLIDE 126

I suddenly have a deep love for stored procedures

slide-127
SLIDE 127

I suddenly have a deep love for stored procedures

now with stored procedures!

slide-128
SLIDE 128

> db.system.js.insert({ "_id" : "x", "value" : 3}); > db.system.js.insert({ "_id" : "y", "value" : 4}); > db.eval("return x+y")

slide-129
SLIDE 129

> db.system.js.insert({_id : "log", ... value : function(msg, level) { ... var date = "[" + new Date() + "] "; ... var lvl = level ? level+" " : ""; ... print(date + lvl + msg); ... }})

slide-130
SLIDE 130

> db.eval("log('all your base are belong to us', 'FATAL');");

slide-131
SLIDE 131

> db.eval("log('all your base are belong to us', 'FATAL');"); [Fri May 19 18:34:57] FATAL all your base are belong to us

slide-132
SLIDE 132
slide-133
SLIDE 133
slide-134
SLIDE 134

        

slide-135
SLIDE 135
slide-136
SLIDE 136

capped collections

slide-137
SLIDE 137

indexes

slide-138
SLIDE 138

geospatial indexes

slide-139
SLIDE 139
slide-140
SLIDE 140

MapReduce

slide-141
SLIDE 141

scaling

slide-142
SLIDE 142
slide-143
SLIDE 143

(rdbms)

slide-144
SLIDE 144
slide-145
SLIDE 145

silly putty

slide-146
SLIDE 146
slide-147
SLIDE 147
slide-148
SLIDE 148

U - Z K - O A - E F - J P - T

slide-149
SLIDE 149

U - Z K - O A - E F - J P - T

I want Mark through Sarah.

slide-150
SLIDE 150

U - Z K - O A - E F - J P - T

slide-151
SLIDE 151

U - Z K - O A - E F - J P - T

slide-152
SLIDE 152

U - Z K - O A - E F - J P - T

Insert Linus

slide-153
SLIDE 153

U - Z K - O A - E F - J P - T

Insert Linus

slide-154
SLIDE 154

U - Z K - O A - E F - J P - T

slide-155
SLIDE 155

$ mongo MongoDB shell version 1.6.0 connecting to: test >

slide-156
SLIDE 156

$ mongo MongoDB shell version 1.6.0 connecting to: test > db.foo.insert({x:1})

slide-157
SLIDE 157

thank you!

@kchodorow http://www.snailinaturtleneck.com