SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
Building a 100%
ScyllaDB Shard-Aware
Application Using Rust
Alexys Jacob, Joseph Perez, Yassir Barchi
Alexys
CTO
Joseph
Senior Software
Engineer
Yassir
Lead Software
Engineer
The Path to a
100% Shard-Aware
Application
Project Context at Numberly
The Omnichannel Delivery team got tasked to build a platform that could be the single point of
entry for all the messages Numberly is operating and routing for their clients.
■ Clients & Platforms send messages using REST API gateways (Email, SMS, WhatsApp)
■ Gateways render and relay the messages to the Central Message Routing Platform
■ Which offers strong and consistent features for all channels
■ Scheduling
■ Accounting
■ Tracing
■ Routing
Before
After
Central Messaging Platform Constraints
■ High Availability
The platform is a Single Point Of Failure for _all_ our messages, it must be resilient.
■ Horizontal scalability
Ability to scale to match our message routing needs, no matter the channel.
Central Messaging Platform Guarantees
■ Observability
Expose per channel metrics and allow per message or per batch tracing.
■ Idempotence
The platform guarantees that the same message can’t be sent twice.
Design Thinking & Key Concepts
We need to apply some key concepts in our design to keep up with the constraints and
guarantees of our platform.
Reliability
- Simple: few share-(almost?)-nothing components
- Low coupling: keep remote dependencies to its minimum
- Coding language: performant with explicit patterns and strict paradigms
Design Thinking & Key Concepts
Scale
- Application layer: easy to deploy & scale with strong resilience
- Data bus: high-throughput, highly-resilient, horizontally scalable, time and order
preserving capabilities message bus
- Data querying: low-latency, one-or-many query support
Idempotence
- Processing isolation: workload distribution should be deterministic
Considering Numberly’s stack, the first go-to architecture could have been…
Platform Architecture 101
Reliability
HA with low coupling Relies on 3 data technologies
Scalability
Easy to deploy Kubernetes
Data horizontal scaling ScyllaDB Kafka Redis
Data low latency querying ScyllaDB Kafka Redis
Data ordered bus ScyllaDB Kafka Redis
Idempotence
Deterministic workload distribution SUM( ScyllaDB + Kafka + Redis ) ?!
Platform Architecture Not So 101
Reliability
HA with low coupling Use only ONE data technology
Scalability
Easy to deploy Kubernetes
Data horizontal scaling ScyllaDB Kafka Redis
Data low latency querying ScyllaDB Kafka Redis
Data ordered bus ScyllaDB Kafka Redis
Idempotence
Deterministic workload distribution ScyllaDB?!
The Daring Architecture
What if I used ScyllaDB’s
shard-per-core
architecture inside
my application?
ScyllaDB Shard-Per-Core Architecture
ScyllaDB shard-per-core data distribution and deterministic processing.
Using ScyllaDB Shard-Per-Core Architecture
Let’s align our application with ScyllaDB’s shard-per-core deterministic data distribution!
Using ScyllaDB’s shard-awareness at the core of our application we gain:
- Deterministic workload distribution
- Super optimized data processing capacity aligned from the application to the storage layer
- Strong latency and isolation guarantees per application instance (pod)
- Patterned after ScyllaDB’s Infinite scale
The 100% Shard-Aware Application
Building a Shard-Aware
Application
The Language Dilemma
The Language Dilemma
■ We need a modern language that reflects our
desire to build a reliable, secure and efficient
platform.
The Language Dilemma
■ We need a modern language that reflects our
desire to build a reliable, secure and efficient
platform.
■ Shard calculation algorithm requires performant
hashing capabilities and a great synergy with the
ScyllaDB driver.
The Language Dilemma
■ We need a modern language that reflects our
desire to build a reliable, secure and efficient
platform.
■ Shard calculation algorithm requires performant
hashing capabilities and a great synergy with the
ScyllaDB driver.
reliable + secure + efficient = Rust
The Language Dilemma
■ We need a modern language that reflects our
desire to build a reliable, secure and efficient
platform.
■ Shard calculation algorithm requires performant
hashing capabilities and a great synergy with the
ScyllaDB driver.
reliable + secure + efficient + = Rust
Our Stack is Born
Deterministic Data Ingestion
Partition Key is a tuple of
(channel, customer, message id)
Clustering Key
(event date, event action)
1
Ingester Store
Deterministic Data Ingestion
Partition Key is a tuple of
(channel, customer, message id)
Clustering Key
(event date, event action)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
1
2
2
Ingester Store
Deterministic Data Processing
Partition Key is a tuple of
(channel, customer, message id)
Clustering Key
(event date, event action)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
1
2
2
Ingester Store Scheduler
Shard (1) handler
Shard (2) handler
Shard (3) handler
Shard (N) handler
Deterministic Data Processing
Partition Key is a tuple of
(channel, customer, message id)
Clustering Key
(event date, event action)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
1
2
2
Ingester Store Scheduler
3
Shard (1) handler
Shard (2) handler
Shard (3) handler
Shard (N) handler
SELECT ... FROM buffer
WHERE channel = ?
AND shard = 2
AND timestamp >= ?
AND timestamp <= currentTimestamp()
LIMIT ?
Deterministic Data Processing
Partition Key is a tuple of
(channel, customer, message id)
Clustering Key
(event date, event action)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
1
2
2
Ingester Store Scheduler
3
Shard (1) handler
Shard (2) handler
Shard (3) handler
Shard (N) handler
SELECT ... FROM buffer
WHERE channel = ?
AND shard = 2
AND timestamp >= ?
AND timestamp <= currentTimestamp()
LIMIT ?
4
Deterministic Message Routing
Partition Key is a tuple of
(channel, customer, message id)
Clustering Key
(event date, event action)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
1
2
2
Ingester Store Scheduler
3
5
Channel
EMAIL MTA
Shard (1) handler
Shard (2) handler
Shard (3) handler
Shard (N) handler
SELECT ... FROM buffer
WHERE channel = ?
AND shard = 2
AND timestamp >= ?
AND timestamp <= currentTimestamp()
LIMIT ?
4
Could We Replace Kafka With ScyllaDB?
Partition Key is a tuple of
(channel, shard)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
Store Scheduler
Shard (1) handler
Shard (2) handler
Shard (3) handler
Shard (N) handler
Trying To Replace Kafka With ScyllaDB
Partition Key is a tuple of
(channel, shard)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
Store Scheduler
Shard (1) handler
Shard (2) handler
Shard (3) handler
Shard (N) handler
SELECT buffer_last_pull_ts
FROM sharding
WHERE channel = ?
AND shard = 2
3.1
Replacing Kafka With ScyllaDB
Partition Key is a tuple of
(channel, shard)
Partition Key is a tuple of
(channel, shard)
Clustering Key
(timestamp, customer, message id)
Store Scheduler
Shard (1) handler
Shard (2) handler
Shard (3) handler
Shard (N) handler
SELECT ... FROM buffer
WHERE channel = ?
AND shard = 2
AND timestamp >= ?
AND timestamp <= currentTimestamp()
LIMIT ?
SELECT buffer_last_pull_ts
FROM sharding
WHERE channel = ?
AND shard = 2
3.2
- window_offset
buffer_last_pulled_ts
currentTimestamp()
3.1
Retrospective
What We Learned on the Road
■ Load testing is more than useful
Spotted a lot of non trivial issues (batch execution delay, timeouts, large partitions, etc.)
■ Time-Window Compaction Strategy
Message buffering as time-series processing allowed us to avoid large partitions!
What We Contributed to Make it Possible
■ Rust driver contributions
What We Contributed to Make it Possible
■ Rust driver contributions
■ Bugs discovery
What We Contributed to Make it Possible
■ Rust driver contributions
■ Bugs discovery
❤ ScyllaDB support
What We Wish We Could Do
■ Long-polling for time-series
Our architecture implies regular fetching, but we have idea to improve this.
■ A Rust driver with less allocations
We did encounter some memory issues and have (a lot?) of ideas to improve the Rust driver!
Going Further with ScyllaDB Features
■ CDC Kafka source connector
Use CDC to stream message events to the rest of the infrastructure, without touching
applicative code
■ Replace LWT by Raft?
We use LWT in a few places, e.g. dynamic shard workload attribution, and can’t wait to test
strongly-consistent tables!
Thank You
Stay in Touch
Want to have fun with us? Reach out!
alexys@numberly.com | joseph@numberly.com | yassir@numberly.com
@ultrabug
numberly

Weitere ähnliche Inhalte

Ähnlich wie Building a 100% ScyllaDB Shard-Aware Application Using Rust

Explore big data at speed of thought with Spark 2.0 and Snappydata
Explore big data at speed of thought with Spark 2.0 and SnappydataExplore big data at speed of thought with Spark 2.0 and Snappydata
Explore big data at speed of thought with Spark 2.0 and Snappydata
Data Con LA
 
sector-sphere
sector-spheresector-sphere
sector-sphere
xlight
 

Ähnlich wie Building a 100% ScyllaDB Shard-Aware Application Using Rust (20)

Swift distributed tracing method and tools v2
Swift distributed tracing method and tools v2Swift distributed tracing method and tools v2
Swift distributed tracing method and tools v2
 
Data Pipelines and Telephony Fraud Detection Using Machine Learning
Data Pipelines and Telephony Fraud Detection Using Machine Learning Data Pipelines and Telephony Fraud Detection Using Machine Learning
Data Pipelines and Telephony Fraud Detection Using Machine Learning
 
Westpac Bank Tech Talk 1: Dive into Apache Kafka
Westpac Bank Tech Talk 1: Dive into Apache KafkaWestpac Bank Tech Talk 1: Dive into Apache Kafka
Westpac Bank Tech Talk 1: Dive into Apache Kafka
 
Seattle spark-meetup-032317
Seattle spark-meetup-032317Seattle spark-meetup-032317
Seattle spark-meetup-032317
 
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
 
TechEvent Apache Cassandra
TechEvent Apache CassandraTechEvent Apache Cassandra
TechEvent Apache Cassandra
 
Building Reliable Cloud Storage with Riak and CloudStack - Andy Gross, Chief ...
Building Reliable Cloud Storage with Riak and CloudStack - Andy Gross, Chief ...Building Reliable Cloud Storage with Riak and CloudStack - Andy Gross, Chief ...
Building Reliable Cloud Storage with Riak and CloudStack - Andy Gross, Chief ...
 
Productionizing your Streaming Jobs
Productionizing your Streaming JobsProductionizing your Streaming Jobs
Productionizing your Streaming Jobs
 
Scylla Summit 2022: Building Zeotap's Privacy Compliant Customer Data Platfor...
Scylla Summit 2022: Building Zeotap's Privacy Compliant Customer Data Platfor...Scylla Summit 2022: Building Zeotap's Privacy Compliant Customer Data Platfor...
Scylla Summit 2022: Building Zeotap's Privacy Compliant Customer Data Platfor...
 
Structured Streaming Data Pipeline Using Kafka, Spark, and MapR-DB
Structured Streaming Data Pipeline Using Kafka, Spark, and MapR-DBStructured Streaming Data Pipeline Using Kafka, Spark, and MapR-DB
Structured Streaming Data Pipeline Using Kafka, Spark, and MapR-DB
 
Explore big data at speed of thought with Spark 2.0 and Snappydata
Explore big data at speed of thought with Spark 2.0 and SnappydataExplore big data at speed of thought with Spark 2.0 and Snappydata
Explore big data at speed of thought with Spark 2.0 and Snappydata
 
Sector Sphere 2009
Sector Sphere 2009Sector Sphere 2009
Sector Sphere 2009
 
sector-sphere
sector-spheresector-sphere
sector-sphere
 
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
 
Cassandra in xPatterns
Cassandra in xPatternsCassandra in xPatterns
Cassandra in xPatterns
 
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
 
AWS re:Invent 2016: Cross-Region Replication with Amazon DynamoDB Streams (DA...
AWS re:Invent 2016: Cross-Region Replication with Amazon DynamoDB Streams (DA...AWS re:Invent 2016: Cross-Region Replication with Amazon DynamoDB Streams (DA...
AWS re:Invent 2016: Cross-Region Replication with Amazon DynamoDB Streams (DA...
 
Realtime Detection of DDOS attacks using Apache Spark and MLLib
Realtime Detection of DDOS attacks using Apache Spark and MLLibRealtime Detection of DDOS attacks using Apache Spark and MLLib
Realtime Detection of DDOS attacks using Apache Spark and MLLib
 
Free Code Friday - Spark Streaming with HBase
Free Code Friday - Spark Streaming with HBaseFree Code Friday - Spark Streaming with HBase
Free Code Friday - Spark Streaming with HBase
 
Osd ctw spark
Osd ctw sparkOsd ctw spark
Osd ctw spark
 

Mehr von ScyllaDB

Mehr von ScyllaDB (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQLWhat Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQL
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & Pitfalls
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance Dilemmas
 
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBBeyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance Dilemmas
 
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
 
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
 
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr SarnaDatabase Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
 
Replacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDB
 
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear ScalabilityPowering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
 
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
 
Getting the most out of ScyllaDB
Getting the most out of ScyllaDBGetting the most out of ScyllaDB
Getting the most out of ScyllaDB
 
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a MigrationNoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
 
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsNoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
 
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and ChallengesNoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
 
ScyllaDB Virtual Workshop
ScyllaDB Virtual WorkshopScyllaDB Virtual Workshop
ScyllaDB Virtual Workshop
 
DBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & TradeoffsDBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & Tradeoffs
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDB
 
NoSQL Data Modeling 101
NoSQL Data Modeling 101NoSQL Data Modeling 101
NoSQL Data Modeling 101
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Building a 100% ScyllaDB Shard-Aware Application Using Rust

  • 1. Building a 100% ScyllaDB Shard-Aware Application Using Rust Alexys Jacob, Joseph Perez, Yassir Barchi
  • 3. The Path to a 100% Shard-Aware Application
  • 4. Project Context at Numberly The Omnichannel Delivery team got tasked to build a platform that could be the single point of entry for all the messages Numberly is operating and routing for their clients. ■ Clients & Platforms send messages using REST API gateways (Email, SMS, WhatsApp) ■ Gateways render and relay the messages to the Central Message Routing Platform ■ Which offers strong and consistent features for all channels ■ Scheduling ■ Accounting ■ Tracing ■ Routing
  • 6. Central Messaging Platform Constraints ■ High Availability The platform is a Single Point Of Failure for _all_ our messages, it must be resilient. ■ Horizontal scalability Ability to scale to match our message routing needs, no matter the channel.
  • 7. Central Messaging Platform Guarantees ■ Observability Expose per channel metrics and allow per message or per batch tracing. ■ Idempotence The platform guarantees that the same message can’t be sent twice.
  • 8. Design Thinking & Key Concepts We need to apply some key concepts in our design to keep up with the constraints and guarantees of our platform. Reliability - Simple: few share-(almost?)-nothing components - Low coupling: keep remote dependencies to its minimum - Coding language: performant with explicit patterns and strict paradigms
  • 9. Design Thinking & Key Concepts Scale - Application layer: easy to deploy & scale with strong resilience - Data bus: high-throughput, highly-resilient, horizontally scalable, time and order preserving capabilities message bus - Data querying: low-latency, one-or-many query support Idempotence - Processing isolation: workload distribution should be deterministic
  • 10. Considering Numberly’s stack, the first go-to architecture could have been… Platform Architecture 101
  • 11. Reliability HA with low coupling Relies on 3 data technologies Scalability Easy to deploy Kubernetes Data horizontal scaling ScyllaDB Kafka Redis Data low latency querying ScyllaDB Kafka Redis Data ordered bus ScyllaDB Kafka Redis Idempotence Deterministic workload distribution SUM( ScyllaDB + Kafka + Redis ) ?! Platform Architecture Not So 101
  • 12. Reliability HA with low coupling Use only ONE data technology Scalability Easy to deploy Kubernetes Data horizontal scaling ScyllaDB Kafka Redis Data low latency querying ScyllaDB Kafka Redis Data ordered bus ScyllaDB Kafka Redis Idempotence Deterministic workload distribution ScyllaDB?! The Daring Architecture
  • 13. What if I used ScyllaDB’s shard-per-core architecture inside my application?
  • 14. ScyllaDB Shard-Per-Core Architecture ScyllaDB shard-per-core data distribution and deterministic processing.
  • 15. Using ScyllaDB Shard-Per-Core Architecture Let’s align our application with ScyllaDB’s shard-per-core deterministic data distribution!
  • 16. Using ScyllaDB’s shard-awareness at the core of our application we gain: - Deterministic workload distribution - Super optimized data processing capacity aligned from the application to the storage layer - Strong latency and isolation guarantees per application instance (pod) - Patterned after ScyllaDB’s Infinite scale The 100% Shard-Aware Application
  • 19. The Language Dilemma ■ We need a modern language that reflects our desire to build a reliable, secure and efficient platform.
  • 20. The Language Dilemma ■ We need a modern language that reflects our desire to build a reliable, secure and efficient platform. ■ Shard calculation algorithm requires performant hashing capabilities and a great synergy with the ScyllaDB driver.
  • 21. The Language Dilemma ■ We need a modern language that reflects our desire to build a reliable, secure and efficient platform. ■ Shard calculation algorithm requires performant hashing capabilities and a great synergy with the ScyllaDB driver. reliable + secure + efficient = Rust
  • 22. The Language Dilemma ■ We need a modern language that reflects our desire to build a reliable, secure and efficient platform. ■ Shard calculation algorithm requires performant hashing capabilities and a great synergy with the ScyllaDB driver. reliable + secure + efficient + = Rust
  • 23. Our Stack is Born
  • 24. Deterministic Data Ingestion Partition Key is a tuple of (channel, customer, message id) Clustering Key (event date, event action) 1 Ingester Store
  • 25. Deterministic Data Ingestion Partition Key is a tuple of (channel, customer, message id) Clustering Key (event date, event action) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) 1 2 2 Ingester Store
  • 26. Deterministic Data Processing Partition Key is a tuple of (channel, customer, message id) Clustering Key (event date, event action) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) 1 2 2 Ingester Store Scheduler Shard (1) handler Shard (2) handler Shard (3) handler Shard (N) handler
  • 27. Deterministic Data Processing Partition Key is a tuple of (channel, customer, message id) Clustering Key (event date, event action) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) 1 2 2 Ingester Store Scheduler 3 Shard (1) handler Shard (2) handler Shard (3) handler Shard (N) handler SELECT ... FROM buffer WHERE channel = ? AND shard = 2 AND timestamp >= ? AND timestamp <= currentTimestamp() LIMIT ?
  • 28. Deterministic Data Processing Partition Key is a tuple of (channel, customer, message id) Clustering Key (event date, event action) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) 1 2 2 Ingester Store Scheduler 3 Shard (1) handler Shard (2) handler Shard (3) handler Shard (N) handler SELECT ... FROM buffer WHERE channel = ? AND shard = 2 AND timestamp >= ? AND timestamp <= currentTimestamp() LIMIT ? 4
  • 29. Deterministic Message Routing Partition Key is a tuple of (channel, customer, message id) Clustering Key (event date, event action) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) 1 2 2 Ingester Store Scheduler 3 5 Channel EMAIL MTA Shard (1) handler Shard (2) handler Shard (3) handler Shard (N) handler SELECT ... FROM buffer WHERE channel = ? AND shard = 2 AND timestamp >= ? AND timestamp <= currentTimestamp() LIMIT ? 4
  • 30. Could We Replace Kafka With ScyllaDB? Partition Key is a tuple of (channel, shard) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) Store Scheduler Shard (1) handler Shard (2) handler Shard (3) handler Shard (N) handler
  • 31. Trying To Replace Kafka With ScyllaDB Partition Key is a tuple of (channel, shard) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) Store Scheduler Shard (1) handler Shard (2) handler Shard (3) handler Shard (N) handler SELECT buffer_last_pull_ts FROM sharding WHERE channel = ? AND shard = 2 3.1
  • 32. Replacing Kafka With ScyllaDB Partition Key is a tuple of (channel, shard) Partition Key is a tuple of (channel, shard) Clustering Key (timestamp, customer, message id) Store Scheduler Shard (1) handler Shard (2) handler Shard (3) handler Shard (N) handler SELECT ... FROM buffer WHERE channel = ? AND shard = 2 AND timestamp >= ? AND timestamp <= currentTimestamp() LIMIT ? SELECT buffer_last_pull_ts FROM sharding WHERE channel = ? AND shard = 2 3.2 - window_offset buffer_last_pulled_ts currentTimestamp() 3.1
  • 34. What We Learned on the Road ■ Load testing is more than useful Spotted a lot of non trivial issues (batch execution delay, timeouts, large partitions, etc.) ■ Time-Window Compaction Strategy Message buffering as time-series processing allowed us to avoid large partitions!
  • 35. What We Contributed to Make it Possible ■ Rust driver contributions
  • 36. What We Contributed to Make it Possible ■ Rust driver contributions ■ Bugs discovery
  • 37. What We Contributed to Make it Possible ■ Rust driver contributions ■ Bugs discovery ❤ ScyllaDB support
  • 38. What We Wish We Could Do ■ Long-polling for time-series Our architecture implies regular fetching, but we have idea to improve this. ■ A Rust driver with less allocations We did encounter some memory issues and have (a lot?) of ideas to improve the Rust driver!
  • 39. Going Further with ScyllaDB Features ■ CDC Kafka source connector Use CDC to stream message events to the rest of the infrastructure, without touching applicative code ■ Replace LWT by Raft? We use LWT in a few places, e.g. dynamic shard workload attribution, and can’t wait to test strongly-consistent tables!
  • 40. Thank You Stay in Touch Want to have fun with us? Reach out! alexys@numberly.com | joseph@numberly.com | yassir@numberly.com @ultrabug numberly