Upload
mabel-rich
View
218
Download
0
Tags:
Embed Size (px)
Citation preview
Who am I ? What am I doing here?• Twitter: @mcwoods
• Email: [email protected]
• Mind-Flip Blog:www.mind-flip.com/theBlog
• Linked In: http://www.linkedin.com/in/mindflip
• When I think I’m being profound, or funny: www.WithBigHair.com
Birth of an Idea…
ApplicationDesign
Application Design
Data Structure Design
• Resulting Structures– User Object– Feed Object– Story Object– Comment Object
WWR: VocZie’s Object linking
User ObjectFeed Object
Comment ObjectStory Object
1
1
1
1
0..1
1
*
1
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>
Selecting a Technology
MongoDB Structures
• Collections• Objects and their identity• The two ways of relating objects– Via pointers (aka _id)– Via embedding
Transaction Problem?UpdateStoriesFromFeed( 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
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
Stumbling along
Moment of Terror
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
More Terror
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!!!
The Technical Lesson
• VMs change over time…
More More Terror….
• Have I lost all my data ?• Can I back up now?
cat Terror | less
• The no backup – backup…• Check out /var/lib/mongodb
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
Questions ?• Twitter: @mcwoods• Email: [email protected]• Mind-Flip Blog:
www.mind-flip.com/theBlog• Linked In: http://
www.linkedin.com/in/mindflip • When I think I’m being profound, or funny:
www.WithBigHair.com
Application Design
• User Functionality First– What data does the UI need?
• What structure would best present that data?