Cassandra Redis

Successfully reported this slideshow.

We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cassandra Redis
Cassandra & Redis Diego Pacheco
Cassandra
Cassandra ❏ FOSS ❏ NoSQL Database ❏ Low Latency ❏ High Throughput ❏ Battle tested by Netflix, Apple, Facebook. ❏ AP on CAP ...
Cassandra ~ Netflix 2013
Cassandra ~ Apple 2016
Cassandra ~ Spotify 2019
Cassandra ~ Data Model
How to have Success with Cassandra? ❏ Understand system / service / app requirements ❏ Identify your data access patterns ...
Netflix Benchmark: 1M writes/sec
Cassandra Cluster ❏ Master less ❏ Anti-entropy HH ❏ Consistent Hashing ❏ Murmur3 ❏ Virtual Nodes ❏ Dynamic Scale out
Cassandra Data Replication
Cassandra Tunable Consistency ❏ Tunable for Read | Writes ❏ Consistency VS Availability ❏ One, Two, Three, ❏ QUORUM(majori...
Cassandra Tombstones
Cassandra: Write Path
Cassandra: Read Path
Cassandra: Reads & Index ❏ Partition Key Cache | Row Cache ❏ Off Heap ❏ Configurable ❏ Secondary Index ❏ Filters data on tab...
Cassandra: Compaction ❏ Merge SSTables ❏ Can be trigger by node_tool ❏ Impact Cassandra Performance ❏ Different Strategies ...
Cassandra: Compaction
Cassandra: Compaction Strategies
Cassandra: Repair ❏ Anti-entropy mechanism (expensive, slow) ❏ 100% needed in Multi-region clusters ❏ Other scenarios that...
Cassandra: Read Repair ❏ Easy and cheap (when reading from multiples replicas) ❏ Hot Data will be repaired a lot
Cassandra: When to not Repair ❏ Short TTLs ❏ High Consistent read and writes ❏ High Read repair chance
Cassandra: Repair Pain points - most on scale ❏ Stream timeouts ❏ Tracking / Resume Repairs ❏ CPU Usage ❏ Disk I/O ❏ Laten...
Cassandra: Poor Usage - Anti-Patterns ❏ Batch usage: Select * from whole table / re-insert periodically ❏ Lack of denormal...
Running Cassandra: $ bin/cassandra
Running Cassandra: $ bin/cqlsh
Running Cassandra: Java Code
Running Cassandra: Java Code
Running Cassandra: Java Code
Running Cassandra: Java Code
Running Cassandra: Java Code
Running Cassandra: Java Code Async
Running Cassandra: Java Code Async
Running Cassandra: Java Code Async
Running Cassandra: Java Code Mapper
Running Cassandra: Java Code Mapper
Running Cassandra: Java Code Mapper
Want to join the DevOps side of the Force?
Redis
Redis ❏ FOSS ❏ In Memory K/V Store written in C ❏ Create for: Caching, Session Store, Queue, Analytics ❏ Specific Commands ...
V5
Redis - Data Structures
Redis >= 4.x ❏ Redis-Modules ❏ It's not Lua Scripting ❏ Built in C ❏ Low Latency | Embedded in Redis ❏ Use cases: Extends ...
Redis >= 5.x
Redis: make ; src/redis-server https://redis.io/download
Redis: src/redis-cli https://redis.io/download
Redis: src/redis-cli https://redis.io/commands/
Redis & Java: Lettuce
Redis & Java: Spring Data + Lettuce
Redis & Java: Spring Data + Lettuce
Redis & Java: Spring Data + Lettuce
Redis & Java: Spring Data + Lettuce
Redis & Java: Spring Data + Lettuce
Redis & Java: Spring Data + Lettuce : Hash Mapping
Redis & Java: Spring Data + Lettuce : Hash Mapping
Redis & Java: Spring Data + Lettuce : Hash Mapping
Redis & Java: Spring Data + Lettuce : Hash Mapping
Exercises Constraints You can code this exercises with Java, Scala or Clojure. You can use any framework you like. UI is n...
Cassandra & Redis Diego Pacheco
Cassandra Redis
Cassandra Redis

Upcoming SlideShare

Loading in …5

×

image1

Like this presentation? Why not share!

  • Be the first to like this

No Downloads

No notes for slide

  1. 1. Cassandra & Redis Diego Pacheco
  2. 2. Cassandra
  3. 3. Cassandra ❏ FOSS ❏ NoSQL Database ❏ Low Latency ❏ High Throughput ❏ Battle tested by Netflix, Apple, Facebook. ❏ AP on CAP - Favors availability over consistency. ❏ Multi-region support. ❏ Great software but hard to operate.
  4. 4. Cassandra ~ Netflix 2013
  5. 5. Cassandra ~ Apple 2016
  6. 6. Cassandra ~ Spotify 2019
  7. 7. Cassandra ~ Data Model
  8. 8. How to have Success with Cassandra? ❏ Understand system / service / app requirements ❏ Identify your data access patterns ❏ Model around the access patterns ❏ Denormalization is your friend (by* query tables) ❏ Benchmark ❏ Tuneup ❏ Repeat
  9. 9. Netflix Benchmark: 1M writes/sec
  10. 10. Cassandra Cluster ❏ Master less ❏ Anti-entropy HH ❏ Consistent Hashing ❏ Murmur3 ❏ Virtual Nodes ❏ Dynamic Scale out
  11. 11. Cassandra Data Replication
  12. 12. Cassandra Tunable Consistency ❏ Tunable for Read | Writes ❏ Consistency VS Availability ❏ One, Two, Three, ❏ QUORUM(majority n/2+1), Local_Quorun ❏ Each_Quorun ❏ Local_one ❏ All, Any
  13. 13. Cassandra Tombstones
  14. 14. Cassandra: Write Path
  15. 15. Cassandra: Read Path
  16. 16. Cassandra: Reads & Index ❏ Partition Key Cache | Row Cache ❏ Off Heap ❏ Configurable ❏ Secondary Index ❏ Filters data on table by non-primary key ❏ Allow Filtering (it can be problematic)
  17. 17. Cassandra: Compaction ❏ Merge SSTables ❏ Can be trigger by node_tool ❏ Impact Cassandra Performance ❏ Different Strategies for different workloads
  18. 18. Cassandra: Compaction
  19. 19. Cassandra: Compaction Strategies
  20. 20. Cassandra: Repair ❏ Anti-entropy mechanism (expensive, slow) ❏ 100% needed in Multi-region clusters ❏ Other scenarios that you need repairs: ❏ Low consistent reads and writes ❏ Frequent nodes outage ❏ Low reads repair chance ❏ Flaky networks
  21. 21. Cassandra: Read Repair ❏ Easy and cheap (when reading from multiples replicas) ❏ Hot Data will be repaired a lot
  22. 22. Cassandra: When to not Repair ❏ Short TTLs ❏ High Consistent read and writes ❏ High Read repair chance
  23. 23. Cassandra: Repair Pain points - most on scale ❏ Stream timeouts ❏ Tracking / Resume Repairs ❏ CPU Usage ❏ Disk I/O ❏ Latencies / SLA ❏ Wide Partitions
  24. 24. Cassandra: Poor Usage - Anti-Patterns ❏ Batch usage: Select * from whole table / re-insert periodically ❏ Lack of denormalized tables to support queries (allow filtering) ❏ Queue ❏ Extreme large row sizes ❏ Abuse of Collections Data types(tombstones) ❏ Read Before Writing (or write and read immediately.)
  25. 25. Running Cassandra: $ bin/cassandra
  26. 26. Running Cassandra: $ bin/cqlsh
  27. 27. Running Cassandra: Java Code
  28. 28. Running Cassandra: Java Code
  29. 29. Running Cassandra: Java Code
  30. 30. Running Cassandra: Java Code
  31. 31. Running Cassandra: Java Code
  32. 32. Running Cassandra: Java Code Async
  33. 33. Running Cassandra: Java Code Async
  34. 34. Running Cassandra: Java Code Async
  35. 35. Running Cassandra: Java Code Mapper
  36. 36. Running Cassandra: Java Code Mapper
  37. 37. Running Cassandra: Java Code Mapper
  38. 38. Want to join the DevOps side of the Force?
  39. 39. Redis
  40. 40. Redis ❏ FOSS ❏ In Memory K/V Store written in C ❏ Create for: Caching, Session Store, Queue, Analytics ❏ Specific Commands per Data Structures: Strings, Hash, sets ❏ Keys TTL ❏ Bring your own Data Structure ❏ Fast, Low Latency, Battle tested everybody. :D ❏ Single Thread :(
  41. 41. V5
  42. 42. Redis - Data Structures
  43. 43. Redis >= 4.x ❏ Redis-Modules ❏ It's not Lua Scripting ❏ Built in C ❏ Low Latency | Embedded in Redis ❏ Use cases: Extends Redis / New Capabilities DSs
  44. 44. Redis >= 5.x
  45. 45. Redis: make ; src/redis-server https://redis.io/download
  46. 46. Redis: src/redis-cli https://redis.io/download
  47. 47. Redis: src/redis-cli https://redis.io/commands/
  48. 48. Redis & Java: Lettuce
  49. 49. Redis & Java: Spring Data + Lettuce
  50. 50. Redis & Java: Spring Data + Lettuce
  51. 51. Redis & Java: Spring Data + Lettuce
  52. 52. Redis & Java: Spring Data + Lettuce
  53. 53. Redis & Java: Spring Data + Lettuce
  54. 54. Redis & Java: Spring Data + Lettuce : Hash Mapping
  55. 55. Redis & Java: Spring Data + Lettuce : Hash Mapping
  56. 56. Redis & Java: Spring Data + Lettuce : Hash Mapping
  57. 57. Redis & Java: Spring Data + Lettuce : Hash Mapping
  58. 58. Exercises Constraints You can code this exercises with Java, Scala or Clojure. You can use any framework you like. UI is not required. You need to run Cassandra 3.x and Redis 5.x (nativily, docker, does not matter). 1. Use cassandra and build Movie Catalog Service Where movies should have ID(UUID), name, category, length, linkToYouTubeTrailer. You should be able to query by category, name and ID. 2. Use Redis and Build a Twitter application where you should have tweet(message) and you should be able to follow people and people could follow you. 3. Build a profile Service using Cassandra, you should have a REST interface with the following data: ID(UUID), name, email, dateOfBirth, gender, twitterURL, faceURL. You need store the data in Cassandra and use Redis as a Cache. You need support the following operations: a. List all users by Id b. List all users by Email c. Add / Remove / Update users
  59. 59. Cassandra & Redis Diego Pacheco

×