歓喜に寄せて
»    MongoDB is our only data store    (technically, S3 is our other store)       January 2011
»   How do you plan to query your data?
»     N-Gram Search      https://github.com/artsy/mongoid_fulltext    class Artist     include Mongoid::Document     inclu...
MongoDB: A Sparse Hash{    Contemporary : 100,    Computer Art : 20,    Plays With Scale: 80,    Humor : 70,    Nostalgia ...
MongoDB: Inheritance in the Database{                         {    _type : SoloArtist,       _type : ArtCollective    birt...
MongoDB: Cartesian Product{    id : BSON::ObjectId(…)    color : red,    medium : works-on-paper,    size : small,    pric...
MongoDB: from LSH to K-Most Similar Graph{    artwork_id : BSON::ObjectId(…)    neighbors : [[ BSON::ObjectId(…), score ],...
class User    include Mongoid::Document      field :account_created, default: false      has_many :authentications      de...
Shard?
iPad                        CMS                                                    Web                      REST API      ...
»   Mongoid Collection Snapshot    https://github.com/aaw/mongoid_collection_snapshot                                     ...
Denormalize?https://github.com/logandk/mongoid_denormalize           https://github.com/dzello/mongoid_alize
»   Mongoid Cached JSON    https://github.com/dblock/mongoid-cached-json                                                  ...
Throw Birds?
rpm_contrib 2.1.9newrelic_rpm 3.3.3https://github.com/newrelic/rpm_contrib/pull/16
class User                                  include Mongoid::Document                                 end                 ...
•   mongoid-history•   carrierwave-mongoid•   mongoid_fulltext•   mongoid_slug•   delayed_job_mongoid•   mongoid_collectio...
Local MongoDBsudo rm /var/lib/mongodb/mongod.lock            Heroku MongoDB small            Heroku MongoDB shared replica...
MongoHQ                                                                   mongodump                                       ...
»   $15 - $49 per developer / month»   149$ / month for a Small Replica Set»   $1345 / month for a Large Replica Set    --...
art.sy:    http://art.sytwitter:   @dblockdotorgblog:    http://code.dblock.orgemail:     dblock@dblock.orgslides on slide...
From Zero to Mongo, Art.sy Experience w/ MongoDB
From Zero to Mongo, Art.sy Experience w/ MongoDB
Upcoming SlideShare
Loading in …5
×

From Zero to Mongo, Art.sy Experience w/ MongoDB

2,248 views

Published on

Talk given at MongoNYC 2012.

Published in: Technology, Design
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total views
2,248
On SlideShare
0
From Embeds
0
Number of Embeds
28
Actions
Shares
0
Downloads
14
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

From Zero to Mongo, Art.sy Experience w/ MongoDB

  1. 1. 歓喜に寄せて
  2. 2. » MongoDB is our only data store (technically, S3 is our other store) January 2011
  3. 3. » How do you plan to query your data?
  4. 4. » N-Gram Search https://github.com/artsy/mongoid_fulltext class Artist include Mongoid::Document include Mongoid::FullTextSearch field :first_name field :last_name def name [first_name, last_name].join( ) end fulltext_search_in :name end
  5. 5. MongoDB: A Sparse Hash{ Contemporary : 100, Computer Art : 20, Plays With Scale: 80, Humor : 70, Nostalgia : 0, Hairy or Fluffy : 0} ~ 50 of 850 genes
  6. 6. MongoDB: Inheritance in the Database{ { _type : SoloArtist, _type : ArtCollective birthday : 1929, founded : 1929 deathday : 1972 }}
  7. 7. MongoDB: Cartesian Product{ id : BSON::ObjectId(…) color : red, medium : works-on-paper, size : small, price : [0, 12, 48],}
  8. 8. MongoDB: from LSH to K-Most Similar Graph{ artwork_id : BSON::ObjectId(…) neighbors : [[ BSON::ObjectId(…), score ], … ]} http://www.mit.edu/~andoni/LSH/ http://www.cs.princeton.edu/cass/papers/www11.pdf
  9. 9. class User include Mongoid::Document field :account_created, default: false has_many :authentications def account_created? account_created || authentications.any? endendtask :migrate do User.where({ :account_created.exists => false }).each do |user| user.update_attributes!({ account_created: user.account_created? }) endend
  10. 10. Shard?
  11. 11. iPad CMS Web REST API as little online processing as possible as much offlineparallel processing as possible
  12. 12. » Mongoid Collection Snapshot https://github.com/aaw/mongoid_collection_snapshot as much offline parallel processing as possible
  13. 13. Denormalize?https://github.com/logandk/mongoid_denormalize https://github.com/dzello/mongoid_alize
  14. 14. » Mongoid Cached JSON https://github.com/dblock/mongoid-cached-json REST API class Widget include Mongoid::CachedJson field :name has_many :gadgets json_fields :name => { }, :gadgets => { :type => :reference, :properties => :public } end
  15. 15. Throw Birds?
  16. 16. rpm_contrib 2.1.9newrelic_rpm 3.3.3https://github.com/newrelic/rpm_contrib/pull/16
  17. 17. class User include Mongoid::Document end class Admin < User end class Representative include Mongoid::Document belongs_to :user, inverse_of: :representative belongs_to :admin , inverse_of: nil endtesting models and APIs will save your life
  18. 18. • mongoid-history• carrierwave-mongoid• mongoid_fulltext• mongoid_slug• delayed_job_mongoid• mongoid_collection_snapshot• delayed_job_shallow_mongoid• mongoid-cached-json
  19. 19. Local MongoDBsudo rm /var/lib/mongodb/mongod.lock Heroku MongoDB small Heroku MongoDB shared replica set MongoHQ dedicted replica set
  20. 20. MongoHQ mongodump Heroku mongodump Heroku & Localhttp://code.dblock.org/a-rake-task-for-copying-mongodb-databases
  21. 21. » $15 - $49 per developer / month» 149$ / month for a Small Replica Set» $1345 / month for a Large Replica Set -------- ~ 25K$ / year on database hosting
  22. 22. art.sy: http://art.sytwitter: @dblockdotorgblog: http://code.dblock.orgemail: dblock@dblock.orgslides on slideshare: http://slideshare.net/dblockdotorg

×