Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unshackling the database!

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Unshackling the database!

Using Redis as the primary data storage to ensure rapid growth scalability

Avatar for marcbransn

marcbransn

May 28, 2019

Other Decks in Programming

Transcript

  1. $ whoami • marc.brandenburg • 3 years in Japan •

    3 months at SmartNews ◦ Fundamental Architecture Squad • Interests: Kotlin, DDD, Clean Architecture
  2. Agenda • Project case study ◦ Improving an existing system

    • Workflow ◦ Analysis ◦ Design ◦ Implementation ◦ Deployment
  3. Use cases System Project team User Analytics 1) create new

    tests 2) fetch test identifiers 3) analyze test results
  4. Quality Attributes • Performance ◦ 200ms response time of news

    feed refresh • Scalability ◦ 30k+ requests / second ◦ 1.5M+ unique users during peak time • Availability ◦ 99.99% of requests return a response
  5. Problem Analysis Analytics Admin Database Not optimized for read-heavy load

    API 1) query 2) read 3) compute 4) write 5) return
  6. Problem Analysis Analytics Admin Database Response waits for database writes

    API 1) query 2) read 3) compute 4) write 5) return
  7. Problem Analysis Analytics Admin Database Database serves too many masters

    API 1) query 2) read 3) compute 4) write 5) return
  8. Problem Analysis Analytics Admin Database Logic spread over multiple project

    API Logic isn’t flexible enough 1) query 2) read 3) compute 4) write 5) return
  9. Proposed Architecture Analytics Admin API Database 1) query 2) read

    3) compute 5) write 4) return Cache Stream 6) write
  10. Proposed Architecture Analytics Admin API Database 1) query 2) read

    3) compute 5) write 4) return Cache Stream 6) write Write admin changes into fast cache
  11. Proposed Architecture Analytics Admin API Database 1) query 2) read

    3) compute 5) write 4) return Cache Stream 6) write Update asynchronously
  12. Proposed Architecture Analytics Admin API Database 1) query 2) read

    3) compute 5) write 4) return Cache Stream 6) write Refactor into single code base Follow principles of clean architecture
  13. Research • Redis seems like a good choice for the

    cache ◦ How to optimize memory consumption? ◦ How to ensure data durability?
  14. Use Cases Delivery Entities Admin Sync Asynchronous data flow between

    components External dependencies defined as interfaces Modelling the applications BDD test scenarios
  15. Performance tests • Locust • Determine correct instance sizing •

    Setup monitoring dashboards/alerts • Observe any resource leakage
  16. Canary deployment • New Relic • Observe on a subset

    of production users • Identify any final issues
  17. Outcome • Slashed peak response time by up to 50%

    • Removed rate limiting database protection