More Related Content Similar to Perform Like a frAg Star (20) Perform Like a frAg Star1. CouchDB
Perform like a frAg star
Casey Rosenthal
Maine Ruby Users Group
Slides by Renae Bair
16. RDBMS
table name
primary key structured data
scalar values column name
SQL consistency
integrity constraints
17. RDBMS
challenges for the web
- most/all fields become optional
- many-to-many relationships
- joins
- replication
- auto incremental ids
20. Distributed Hash Table
node B
Key/Value
node C
Key/Value node A
Key/Value node M
Key/Value
node L
Key/Value
node Z
Key/Value
21. Distributed Hash Table
-decentralized
-add/remove nodes ➟ scale
-fault tolerant
-p2p & IM
-memcached
-memcached ➟ disk
-MemcacheDB
-Project Voldemort
-Scalaris
-Tokyo Cabinet
-Redis
24. key/value
store
CouchDB
Key: "user-077-socialsecuritynumber"
value: "477-289-4690"
42. more
class Card < CouchRest::ExtendedDocument
include CouchRest::Validation
use_database SERVER.default_database
property :first_name
property :last_name, :alias => :family_name
property :pid, :read_only => true
timestamps!
validates_present :first_name
end
44. more
property :questions, :cast_as => ['Question']
property :professor, :cast_as => 'Person'
property :final_test_at, :cast_as => 'Time'
46. more
view_by :tags,
:map =>
"function(doc) {
if (doc['couchrest-type'] == 'Article' && doc.tags) {
doc.tags.forEach(function(tag){
emit(tag, 1);
});
}
}",
:reduce =>
"function(keys, values, rereduce) {
return sum(values);
}"
48. when to use couch?
-when you need to scale your DB
-when availability is more important than
consistency
-when your data is decentralized
-when you need to compute data