my life with mongodb
Post on 16-Jul-2015
357 Views
Preview:
TRANSCRIPT
Your MongoDB Fu?
Happy to show you how WiredTiger can be optimized
I got multiple apps in production with it
Currently using it in active development/projects
Hey I downloaded it at least, might even install it
Got donuts?
Recovering Joomla! founder
Starting companies since 1995
Big on PHP, Node, Go, cloud tools, virtualization, containers
Big on developer workflow
Coach youth sports
Proud husband, dad
Don’t even THINK about touching my BBQ
We needed to store data
Data needed to be kept clean
Disk space was at a premium
Same for CPU and RAM
Efficiency was the most important factor
Number of concurrent users grew
Amount of data grew
Programming languages proliferated
Applications accessing our data proliferated
We all switched to Oracle or DB2
Concurrent users jumped from 2 to 2,000,000
1,200 daily accesses turned into 20MM daily views
Throughput became the only critical element for your apps, and therefore your data
That smoking crater in the datacenter? Yeah, that was your DATABASE SERVER.
Programming languages
Perl, Python, Ruby, Java, PHP, and more
All used objects to represent structures
All were connected to relational databases
Which required…
Models represented “things”
Each model could be linked to other models
Has many, belongs to, is a member of…
Fixes for super mega whack-daddy growth
Sharding
Clustering
Multi-master
Read-only slaves
Replication
Flux Capacitors
Dilithium Crystals
Main MongoDB goodness
Stores data as JSON documents
Sharding is built in
Clustering is built in
Slaves/replication is built in
Atomic writes, supports verified commits to disk
No JOINs
User table, relational style
first_name: varchar(128)
last_name: varchar(128)
email: varchar(128)
password: varchar(128)
Not done yet.
address_id: int (refers to address.id)
gender_id: int (refers to gender.id)
account_type_id: int (refers to account types)
create_user(user)
Ok first insert the users table
No wait, first insert the address and get address.id
create_user(user)
Ok first insert the users table
No wait, first insert the address and get address.id
No, insert users record first, then the address, then update the users.address_id with the last_insert_id
EXAMPLE: User document
{ _id: “35b3d656-4e4b-41c0-85ab-23a9867a3e00”, first_name: “Mitch”, last_name: “Pirtle”, addresses: [ address_1: “123 Tondup Glacier”, address_2: “Second Yurt On The Left”, region: “Lhasa”, country: “Tibet” ]}
Stumbling into MongoDB
Leave your 3NF data model behind
Atomicity is at the DOCUMENT LEVEL
There are different ways of doing things (e.g. findAndReplace)
Thanks!
@mitchitized
http://about.me/mitchitized
http://www.slideshare.net/spacemonkeylabs
https://www.github.com/spacemonkey
top related