• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Nosql redis-mongo
 

Nosql redis-mongo

on

  • 4,524 views

These are some of my notes of my beginning, while learning Redis and Mongodb for a pet project. I made them for a tech talk at Maresme Developers Meetup #maresmedev....

These are some of my notes of my beginning, while learning Redis and Mongodb for a pet project. I made them for a tech talk at Maresme Developers Meetup #maresmedev.
Please email email me for notifying mistakes or suggestions.

Statistics

Views

Total Views
4,524
Views on SlideShare
2,494
Embed Views
2,030

Actions

Likes
3
Downloads
27
Comments
0

6 Embeds 2,030

http://ivanhq.net 2017
http://translate.googleusercontent.com 7
http://webcache.googleusercontent.com 2
http://www.ivanhq.net 2
http://wonder-tonic.com 1
http://131.253.14.66 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Nosql redis-mongo Nosql redis-mongo Presentation Transcript

  • NOSQLagile data storage
  • SQL: THE BEGINNING• Data structured on tables using columns• Data on one column is the key for making relationships with other tables• Normalization• RDBMS
  • SQL EXAMPLES
  • RDBMS BENEFITS• Normalization (a common standard format for accessing data)• Data consistency• Persistence• Consistency• Replication
  • RDBMS PROBLEMS
  • RDBMS PROBLEMS• Highcost on performing complex operations over a big database• High system load: scalability needs• Difficult failover recovery• Difficult denormalization
  • NOSQL TO THE RESCUE!
  • NOSQL IS...•A storage system for format free data• Web scale• Software darwinism• Different types of solutions depending on the needs: Key-value, Documents, Graphs, Objects...
  • REDIS• http://redis.io Redis is SEXY• Key-value store• In memory• Persistent (periodical asynchronous writes to disk)• All operations are atomic
  • REDISTypes of data Cool operations• Hashes • RPOPLPUSH• Sets (arrays) • Pub/Sub• Lists
  • REDISHSET myuser “email” “ivan@ivanhq.net”HSET myuser “web” “http://ibelmonte.com”HSET mysql “blog” “http://ivanh.net”HGET myuser “email”- ivan@ivanhq.net
  • REDISsadd myuser:books “jackass”sadd myuser:books “jackass2”sadd myuser:books “Dude, where’s my car?”sadd myuser:books “The hangover”smembers myuser:books1. jackass2. jackass23. Dude, where’s my car?4. The hangover
  • REDISrpush friends “John Doe”rpush friends “Foo”rpush friends “Bar”lrange friends 0 -11. John Doe2. Foo3. Bar
  • REDISrpush nonfriends “Peter Pan”rpush nonfriends “Batman”rpush nonfriends “Betty Boop”lrange nonfriends 0 -11. Peter Pan2. Batman3. Betty Boop
  • REDISrpoplpush nonfriends friendslrange friends 0 -11. John Doe2. Foo3. Bar4. Betty Booplrange nonfriends 0 -11. Peter Pan2. Batman
  • REDISPub/Sub.... a freaking AWESOME messaging queue
  • REDISPro’s:- Highly performant- Highly scalable- Interfaces available for many languages (Ruby: Ohm)Cons:- Eats your server’s memory- Manually sharding
  • MONGODB• http://mongodb.org• Document store• Writes to disk• Hight scalability• Easy sharding
  • MONGODB• Organizes data using collections• Stores documents in BSON format, a binary-encoded serialization of JSON
  • MONGODBuse usersu = { name: “ivan”, company: “Sysdivision”, age: “32” }users.insert(u)users.find();- { "_id" : ObjectId("4d5ea4e79faeda067681e214"),"name" : "ivan", company: “Sysdivision”, "age" : "32" }
  • MONGODBuse usersu = { name: “ivan”, company: “Sysdivision”, age: “32” }users.insert(u)db.users.find({name: “ivan”});- { "_id" : ObjectId("4d5ea4e79faeda067681e214"),"name" : "ivan", company: “Sysdivision”, "age" : "32" }db.users.find();db.users.find().skip(20).limit(10);
  • MONGOIDclass User include Mongoid::Document field :name field :birthday, :type => date field :money, :type => float, :default => 0.0 embeds_one :companyendclass Company field :name embedded_in :userend
  • MONGOIDuser = User.new( :name => ‘John Doe’, :birthday => ’12/7/1982’, : money => 0 )user.company.create(:name => ‘Sysdivision’)User.find(:name => ‘John Doe’)User.where(:name => /.*ohn.*/)
  • MONGOIDUser.any_of( { :name => ‘John Doe’ }, { :money.gt 10 } )User.any_in(:name => [‘John’, ‘Foo’, ‘Bar’])User.where(:name => ‘John Doe’).and(:money.gt 10)Post.all_in(:tags => [‘ruby’, ‘code’, ‘mongo’])
  • MONGODBPro’s:- Highly performant- Highly scalable- Easy sharding- Ultra powerful querying- Interfaces available for many languages (Ruby:mongo_mapper, mongoid)
  • NOSQL AWESOMENESS
  • QUESTIONS? Ivan Belmonte http://ibelmonte.com ivan@ivanhq.net