Cassandra Day SV 2014: Netflix’s Astyanax Java Client Driver for Apache Cassandra
-
Upload
planet-cassandra -
Category
Technology
-
view
766 -
download
1
description
Transcript of Cassandra Day SV 2014: Netflix’s Astyanax Java Client Driver for Apache Cassandra
Astyanax
Puneet Oberai Ne1lix, Inc.
h8ps://github.com/Ne1lix/astyanax
Useful features
– Load balancing
– ConnecDon pooling -‐ resilient with failover and retries
– Integrates with external host discovery
– Metrics (there are a lot!)
– Highly configurable and pluggable
Fluent query syntax
ColumnList<Integer> = keyspace
.readQuery( “myCF” ) .getRow( “A” ) .withColumnSlice( new RangeBuilder() .greaterThan(11) .lessThanEquals(18) .build()) .execute() .getResult();
Recipes
• All Rows Reader
• Distributed Row Lock
• Queue
• Chunked Object Store
How does Ne1lix use it
Java Driver release in 2013
• Async interface!
• Cursor support
• Batching for mutaDons
• Prepared statements
• Flexible retry policies
• And everything else in CQL ..
But what about thrie !!?? I’m sDll using it.
Calm down, thrie is sDll supported J
Astyanax can use both drivers
Now the good stuff! What about performance?
If you use prepared statements, you’re good!
Reads (about 2%)
Writes (a bit more 5%-‐10%)
Prepared Statements are a must
Prepared Statements
• There is no magic here – You “prepare” – Then you re-‐use
Astyanax value add
Structured queries naturally have some query signature
keyspace.prepareQuery( myCF ) .withRow( myRowKey )
.withColumnSlice( start, end)
.execute();
Translates to select * from ks.myCF where key=? and column1 >=? and column1 <=?;
Columns v/s Rows
• Are columns really columns? • Are rows sDll rows? • Are columns really rows?
Simple schema Key validator – int Col comparator – int Default validator – u18
Rows are now transposed
Astyanax value add
• Astyanax maintains backwards compaDbility with the api
• Hence rows are sDll rows and columns are sDll columns
So what should I use?
• Astyanax has recipes • Astyanax is good for structured queries
• If all you want is CQL3, then use Java Driver
QuesDons?