0
The new face of CassandraMichaël Figuière@mfiguiere
Speaker                 Michaël Figuière                      @mfiguiere©2012 DataStax                      2
Ring Architecture                        Node     Node                 Node     Cassandra     Node                        ...
Ring Architecture                         Node     Replica                 Node                                           ...
Linear Scalability                 Client Writes/s by Node Count - Replication Factor = 3©2012 DataStax                   ...
Client / Server Communication          Client   ?           Node     Replica          Client                       Node   ...
Client / Server Communication          Client           Node         Replica          Client                   Node       ...
Tunable Consistency                                    Time                        A   A   A           3 replicas©2012 Dat...
Tunable Consistency                                                            Time                        A   A      A   ...
Tunable Consistency                                                                  Time                               R ...
Tunable Consistency                                                                    Time                               ...
Tunable Consistency                                                                    Time                               ...
Tunable Consistency                                        Time                  R = W = QUORUM                   A      A...
Request Path                       1          Client                   Node             Replica                           ...
Multi-Datacenter                                              Datacenter A                                                ...
Column Family Data Model                             address       email         name          state                  jbel...
Column Family Data Model                            datastax     dhutch       egilmore      mzcassie                  jbel...
Storage Engine                 Memtable   Memtable                 Commit                                       SSTable   ...
CQL3 Denormalized Model           CQL3 Query Language comes with a new Data Model abstraction made of                     ...
CQL3 Data Model    Timeline Table         user_id     tweet_id       author                       body         gmason     ...
CQL3 Data Model    Timeline Table         user_id     tweet_id     author                       body         gmason       ...
CQL3 Data Model    Timeline Table         user_id         tweet_id        author                            body         g...
Current Drivers Architecture      CQL API             Thrift API             OO API                        DB API         ...
New Drivers Architecture                 DB API                   CQL API                    OO API                       ...
DataStax Java Driver  • Reference Implementation  • Asynchronous architecture based on Netty  • Prepared Statements Suppor...
Connect and Write       Cluster cluster = new Cluster.Builder()                         .addContactPoints("10.0.0.1", "10....
Read             ResultSet rs = session.execute("SELECT * FROM test");             List<Row> rows = rs.fetchAll();        ...
Asynchronous Read            ResultSet.Future future =               session.executeAsync("SELECT * FROM test");          ...
Object Mapping     @Table(name = "user")     public class User {           public enum Gender {     	     	 @PartitionKey ...
Inheritance@Table(name = "catalog")@Inheritance(                                          @InheritanceValue("tv")  subClas...
Now Available!  https://github.com/datastax/java-driver
Stay Tuned!          blog.datastax.com          @mfiguiere
Upcoming SlideShare
Loading in...5
×

ApacheCon NA 2013 - The New Face of Apache Cassandra

4,666

Published on

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.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,666
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
34
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

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

  1. 1. The new face of CassandraMichaël Figuière@mfiguiere
  2. 2. Speaker Michaël Figuière @mfiguiere©2012 DataStax 2
  3. 3. Ring Architecture Node Node Node Cassandra Node Node Node©2012 DataStax 3
  4. 4. Ring Architecture Node Replica Node Replica Node Replica©2012 DataStax 4
  5. 5. Linear Scalability Client Writes/s by Node Count - Replication Factor = 3©2012 DataStax 5
  6. 6. Client / Server Communication Client ? Node Replica Client Node Replica Client Node Client Replica©2012 DataStax 6
  7. 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. 8. Tunable Consistency Time A A A 3 replicas©2012 DataStax 8
  9. 9. Tunable Consistency Time A A A B A A Write ‘B’ Write and wait for acknowledge from one node©2012 DataStax 9
  10. 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. 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. 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. 13. Tunable Consistency Time R = W = QUORUM A A A B B A B B A QUORUM = (N / 2) + 1©2012 DataStax 13
  14. 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. 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. 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. 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. 18. Storage Engine Memtable Memtable Commit SSTable Log SSTable SSTable SSTable©2012 DataStax 18
  19. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 31. Now Available! https://github.com/datastax/java-driver
  32. 32. Stay Tuned! blog.datastax.com @mfiguiere
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×