ApacheCon NA 2013 - The New Face of Apache Cassandra
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

ApacheCon NA 2013 - The New Face of Apache Cassandra

on

  • 4,957 views

Cassandra has always been a highly performant distributed database, but not always simple to use though. Apache Cassandra 1.2 introduces some new features such as a Binary Protocol and Collections ...

Cassandra has always been a highly performant distributed database, but not always simple to use though. Apache Cassandra 1.2 introduces some new features such as a Binary Protocol and Collections datatype that together with the now finalized CQL3 query language provide a new interface to communicate with Cassandra that dramatically shrink its learning curve and simplify its daily use while still relying on its highly scalable architecture and storage engine. This presentation will iterate over all these new features including an overview of CQL3 query language, a look at the new client architecture, and an update on data modeling best practices. Then we'll see how to implement an enterprise application using this new interface so that the audience can realize that a number of design principles are inspired from those commonly used with relational databases while some other entirely different, due to Cassandra partitioning approach.

Statistics

Views

Total Views
4,957
Views on SlideShare
2,461
Embed Views
2,496

Actions

Likes
3
Downloads
33
Comments
0

10 Embeds 2,496

http://nosql.mypopescu.com 2342
https://twitter.com 118
http://feeds.feedburner.com 18
http://www.newsblur.com 7
http://www.hanrss.com 4
http://newsblur.com 2
http://127.0.0.1 2
http://www.acushare.com 1
http://dev.newsblur.com 1
http://translate.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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

ApacheCon NA 2013 - The New Face of Apache Cassandra Presentation Transcript

  • 1. The new face of CassandraMichaël Figuière@mfiguiere
  • 2. Speaker Michaël Figuière @mfiguiere©2012 DataStax 2
  • 3. Ring Architecture Node Node Node Cassandra Node Node Node©2012 DataStax 3
  • 4. Ring Architecture Node Replica Node Replica Node Replica©2012 DataStax 4
  • 5. Linear Scalability Client Writes/s by Node Count - Replication Factor = 3©2012 DataStax 5
  • 6. Client / Server Communication Client ? Node Replica Client Node Replica Client Node Client Replica©2012 DataStax 6
  • 7. Client / Server Communication Client Node Replica Client Node Replica Client Node Client Replica Coordinator node: Forwards all R/W requests to corresponding replicas©2012 DataStax 7
  • 8. Tunable Consistency Time A A A 3 replicas©2012 DataStax 8
  • 9. Tunable Consistency Time A A A B A A Write ‘B’ Write and wait for acknowledge from one node©2012 DataStax 9
  • 10. Tunable Consistency Time R +W < N A A A B A A B A A Read waiting for one node Write and wait for to answer acknowledge from one node©2012 DataStax 10
  • 11. Tunable Consistency Time R +W = N A A A B B A B B A Read waiting for one node Write and wait for to answer acknowledges from two nodes©2012 DataStax 11
  • 12. Tunable Consistency Time R +W > N A A A B B A B B A Read waiting for two nodes Write and wait for to answer acknowledges from two nodes©2012 DataStax 12
  • 13. Tunable Consistency Time R = W = QUORUM A A A B B A B B A QUORUM = (N / 2) + 1©2012 DataStax 13
  • 14. Request Path 1 Client Node Replica 2 3 Client 4 2 Node Replica 3 Client 2 3 Node Client Replica Coordinator node©2012 DataStax 14
  • 15. Multi-Datacenter Datacenter A Node 1 Node Node Node 2 1 2 Datacenter B Node 3 Node 6 Node 3 Node 4 Datacenter C Node Node 5 Node 5 4 Node 6©2012 DataStax 15
  • 16. Column Family Data Model address email name state jbellis 123 main jb@ds.com Jonathan TX address email name state dhutch 45 2nd st dh@ds.com Daria CA email name egilmore eg@ds.com Eric Row Key Columns = List of K/V pairs sorted by Key©2012 DataStax 16
  • 17. Column Family Data Model datastax dhutch egilmore mzcassie jbellis egilmore dhutch datastax mzcassie egilmore Row Key Columns = List of K/V pairs sorted by Key©2012 DataStax 17
  • 18. Storage Engine Memtable Memtable Commit SSTable Log SSTable SSTable SSTable©2012 DataStax 18
  • 19. CQL3 Denormalized Model CQL3 Query Language comes with a new Data Model abstraction made of denormalized, statically defined tables Data duplicated over several tables©2012 DataStax 19
  • 20. CQL3 Data Model Timeline Table user_id tweet_id author body gmason 1735 phenry Give me liberty or give me death gmason 1742 gwashington I chopped down the cherry tree ahamilton 1767 jadams A government of laws, not men ahamilton 1794 gwashington I chopped down the cherry tree Partition Clustering Key Key©2012 DataStax 20
  • 21. CQL3 Data Model Timeline Table user_id tweet_id author body gmason 1735 phenry Give me liberty or give me death gmason 1742 gwashington I chopped down the cherry tree ahamilton 1767 jadams A government of laws, not men ahamilton 1794 gwashington I chopped down the cherry tree CQL CREATE TABLE timeline ( user_id varchar, tweet_id timeuuid, author varchar, body varchar, PRIMARY KEY (user_id, tweet_id));©2012 DataStax 21
  • 22. CQL3 Data Model Timeline Table user_id tweet_id author body gmason 1735 phenry Give me liberty or give me death gmason 1742 gwashington I chopped down the cherry tree ahamilton 1767 jadams A government of laws, not men ahamilton 1794 gwashington I chopped down the cherry treeTimeline Physical Layout [1735, author] [1735, body] [1742, author] [1742, body] gmason gwashington I chopped down the... phenry Give me liberty or give... [1767, author] [1767, body] [1794, author] [1794, body] ahamilton gwashington I chopped down the... jadams A government of laws...©2012 DataStax 22
  • 23. Current Drivers Architecture CQL API Thrift API OO API DB API Thrift RPC Thrift RPC Client Library CQL Driver * This is a simplified view of drivers architecture. Details vary from one language to another.©2012 DataStax 23
  • 24. New Drivers Architecture DB API CQL API OO API CQL Native Protocol Next Generation Driver * This is a simplified view of drivers architecture. Details vary from one language to another.©2012 DataStax 24
  • 25. DataStax Java Driver • Reference Implementation • Asynchronous architecture based on Netty • Prepared Statements Support • Automatic Fail-over • Node Discovery • Cassandra Tracing Support • Tunable policies • LoadBalancingPolicy • ReconnectionPolicy •©2012 DataStax RetryPolicy 25
  • 26. Connect and Write Cluster cluster = new Cluster.Builder() .addContactPoints("10.0.0.1", "10.0.0.2") .build(); Session session = cluster.connect("myKeyspace"); session.execute( "INSERT INTO user (user_id, name, email) VALUES (12345, johndoe, john@doe.com)" );©2012 DataStax 26
  • 27. Read ResultSet rs = session.execute("SELECT * FROM test"); List<Row> rows = rs.fetchAll(); for (Row row : rows) { String userId = row.getString("user_id"); String name = row.getString("name"); String email = row.getString("email"); }©2012 DataStax 27
  • 28. Asynchronous Read ResultSet.Future future = session.executeAsync("SELECT * FROM test"); for (Row row : future.get()) { String userId = row.getString("user_id"); String name = row.getString("name"); String email = row.getString("email"); }©2012 DataStax 28
  • 29. Object Mapping @Table(name = "user") public class User { public enum Gender { @PartitionKey @EnumValue("m") @Column(name = "user_id") MALE, private String userId; @EnumValue("f") private String name; FEMALE; } private String email; private Gender gender; }©2012 DataStax 29
  • 30. Inheritance@Table(name = "catalog")@Inheritance( @InheritanceValue("tv") subClasses = {Phone.class, TV.class}, public class TV column = "product_type" extends Product {)public abstract class Product { private float size; } @Column(name = "product_id") private String productId; private float price; private String vendor; private String model;}©2012 DataStax 30
  • 31. Now Available! https://github.com/datastax/java-driver
  • 32. Stay Tuned! blog.datastax.com @mfiguiere