Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application...
-
Upload
scarlett-adams -
Category
Documents
-
view
219 -
download
0
Transcript of Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application...
![Page 1: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/1.jpg)
Halloween Special a self Post-mortem – Using MongoDB for VocZie
Chris (I’m not a ghost) Woods
![Page 2: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/2.jpg)
![Page 3: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/3.jpg)
What went right (with Mongo)
• Application design• Application development and system
migration• Application debugging• MongoDB Documentation
![Page 4: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/4.jpg)
WWR: Application Design
![Page 5: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/5.jpg)
WWR: VocZie’s Structures
• Functionality First– What data does the UI need?– What structure would best present that data?
• Resulting Structures– User Object– Feed Object– Story Object– Comment Object
![Page 6: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/6.jpg)
WWR: MongoDB Structures
• Collections• Objects and their identity• The two ways of relating objects– Via pointers (aka _id)– Via embedding
![Page 7: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/7.jpg)
WWR: VocZie’s Object linking
• User Object– Array of pointers to feeds subscribed
• Story Object– Pointer to a feed object– One embedded comment object (if available)
• Comment Object– Pointer to a story object– Pointer to a user object (if available)
![Page 8: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/8.jpg)
WWR: VocZie’s Object linking
User ObjectFeed Object
Comment Object
Story Object
Comment Object
1
1
1
1
0..1
1
*
1
![Page 9: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/9.jpg)
WWR: VocZie’s REST API
Examples:
• /feeds/<feed_id>• /feeds/<feed_id>/stories• /feeds/<feed_id>/story/<story_id>/comments• /feeds/<feed_id>/story/<story_id>
![Page 10: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/10.jpg)
What went wrong (with Mongo)
![Page 11: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/11.jpg)
What went wrong (with Mongo)
• VM is just a VM except when it is Hell…• Oh yeah, and there are no transactions• MongoDB Documentation good…. PHP Driver
Documentation ..?...?
![Page 12: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/12.jpg)
WWR: The VM from Hell
• VMs change over time…
![Page 13: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/13.jpg)
WWR: The VM from Hell
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
![Page 14: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/14.jpg)
WWR: The VM from Hell
root@1310-1064-2283:~# mongod
mongod --help for help and startup optionsMon Jul 23 14:38:35 [initandlisten] MongoDB starting : pid=26105 port=27017dbpath=/data/db/ 64-bit
** WARNING: You are running in OpenVZ. This is known to be broken!!!
![Page 15: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/15.jpg)
WWR: The VM from Hell
• Have I lost all my data ?• Can I back up now?
![Page 16: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/16.jpg)
WWR: The VM from Hell
• The no backup – backup…• Check out /var/lib/mongodb
![Page 17: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/17.jpg)
WWR: TransactionsUpdateStoriesFromFeed( url )
if ( url is being updated ) then wait for notificationelse
lock out everyone else from updating urlfetch and parse stories from feed’s urlfor each story returned
if ( story doesn’t already exist in DB)add storyend if
end forremove lock preventing anyone else from updating url
end ifEnd function
![Page 18: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/18.jpg)
WWR: Implementing a lock manually
• update if current– Aka Compare and Swap – Atomic MongoDB actions allow for manual
creation of locks– http://www.mongodb.org/display/DOCS/Atomic+
Operations#AtomicOperations-TheABANuance
![Page 19: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/19.jpg)
Conclusions
• Good– No SQL DB is great for avoiding the DAL translation
pain– Aid development time– MongoDB Core Documentation is good
• Bad– Small print – VM compatibility– MongoDB Driver Documentation isn’t as good as
the core
![Page 20: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/20.jpg)
Q&A
![Page 21: Chris (I’m not a ghost) Woods. What went right (with Mongo) Application design Application development and system migration Application debugging MongoDB.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697bfed1a28abf838cb8c2c/html5/thumbnails/21.jpg)
Who am I ? What am I doing here?
• Twitter: @mcwoods
• Email: [email protected]
• Mind-Flip Blog: www.mind-flip.com/theBlog
• When I think I’m being profound, or funny: www.WithBigHair.com