SlideShare une entreprise Scribd logo
1  sur  51
A snapshot, a
stream, and a
bunch of deltas
Applying Lambda Architectures in a
post-Microservice World
Q-Con London March 6th 2018
Ade Trenaman, SVP Engineering, Raconteur,
HBC Tech
t: @adrian_trenaman
http://tech.hbc.com
t: @hbcdigital fa: @hbcdigital in: hbc_digital
InfoQ.com: News & Community Site
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
lambda-streams-delta
• Over 1,000,000 software developers, architects and CTOs read the site world-
wide every month
• 250,000 senior developers subscribe to our weekly newsletter
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• 2 dedicated podcast channels: The InfoQ Podcast, with a focus on
Architecture and The Engineering Culture Podcast, with a focus on building
• 96 deep dives on innovative topics packed as downloadable emags and
minibooks
• Over 40 new content items per week
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Presented at QCon London
www.qconlondon.com
~$3.5Bn
annual e-commerce revenue
00’s of
Stores
What this talk is about
Solving the problem of microservice dependencies with lambda architectures:
> performance, scalability, reliability
Lambda architecture examples:
> product catalog, search, real-time inventory, third-party integration
Lessons learnt:
> It’s not all rainbows and unicorns
> Kinesis vs. Kafka
Some context: a minimalist abstraction of our
architectural evolution
2007
Monolith
2010
Service
Oriented
2012
µ-Services
λ λ λ λ λ λ λ λ λ λ λ λ λ λ
λ λ λ
λ λ λ λ λ λ
λ
2016
Rise of
Serverless λ
λ λ λ λ λ λ λ λ λ λ λ λ λ λ
λ λ λ
λ λ λ λ λ λ
λ
2018+
Multi-banner
Multi-tenant
Multi-region
λ architectures
Streams
GraphQL In the
seams
Slam on the breaks! Dublin Microservices Meetup, Feb 2015
Part 0
In which we briefly describe lambda architecture, and the Hollywood Principle
Lambda architecture: making batch processing sexy again.
Some kind of
data-source
A view of the data
Batch processing ‘the
baseline’
Stream processing
‘real-time’
Provide low-latency,
high-throughput,
reliable, convenient
access to the data.
Preserve the
integrity and
purpose of the
source of truth.
Stream: an
append-only,
immutable log store of
interesting events.
Lambda architecture: making batch processing sexy again.
Some kind of
data-source
A view of the data
Batch processing ‘the
baseline’
Stream processing
‘real-time’
Need to rebuild the
view? Take latest
snapshot, and replay
all events with a
greater timestamp.
T_7:
po
T_6:
dipsy
T_8:
tinky
T_1: foo
T_2: bar
T_3: pepe
T_4: pipi
T_5: lala
T_1: foo
T_2: bar
T_3: pepe
T_4: pipi
T_5: lala
T_6: dipsy
...
“Don’t call us,
we’ll call you.”
Inversion of control: previously, we ask for data when we need it.
Some kind of
data-source
A view of the data
Provide low-latency,
high-throughput,
reliable, convenient
access to the data.
Preserve the
integrity and
purpose of the
source of truth.
Inversion of control: now, when the data changes, we are
informed.
Some kind of
data-source
A view of the data
Provide low-latency,
high-throughput,
reliable, convenient
access to the data.
Preserve the
integrity and
purpose of the
source of truth.
Part I
In which we learn the perils of caching in a microservices architecture, and how
lambda architecture helped us out.
Gilt: we source luxury brands...
… we shoot the product in our studios
… we receive
… we sell every day at noon
… stampede!
The Gilt Problem
Massive pulse of traffic, every day.
=> serve fast
Low inventory quantities of high value merchandise, changing rapidly
=> can’t cache
Individually personalised landing experiences
=> can’t cache
Caching
“Just say no.”
“Until you have to say yes.”
“Then, just say maybe.”
consumer (e.g. web-pdp)
A stateless, cache-free library, busted.
product-service inventory-service price-service
commons <<lib>>
Hmm, engineer adds a local brand cache
to reduce network calls..
… and then later, another cache for
product information.
Leads to (1) arbitrary caching policies, &
(2) duplicated cache information.
product cache
brand cache
A caching library. Worked well initially, but...
product-service inventory-service price-service
consumer (e.g. web-pdp)
commons <<lib>>
We changed the commons library to
cache products with a consistent, timed
refresh (20m).
Worked well, until the business changed
its mind about one small thing: let’s
make everything in the warehouse
sellable.
Orders of magnitude more SKUs:
* JSON from product service > 1Gb
* Startup time > 10m
* JVM garbage collection every 20m on
cache clear
* ~1hr to propagate a change.
* m4.xlarge, w/ 14Gb JVM Heap
product cache
brand cache
Near real-time caching at scale
Source of Truth - PG
admin
web-pdp
commons
L1
* Startup time ~1s
* No more stop-the-world GC
* ~seconds to propagate a change.
* c4.xlarge (CPU!!!), w/ 6Gb JVM Heap
Next: replace JSON marshalling with binary
OTW format (e.g. AVRO)
S3
Brands, products,
sales, channels, ...
s
Elasticache
product
-service
Kinesis
Calatrava λ
https://github.com/gilt/calatrava - soon to be public
Part 2
In which we learn how we’ve used Lambda architecture to implement a near
real-time search index, but needed an additional relational ‘view of truth’.
Problem: polling a polling service means changes to
product data are not reflected in realtime.
Source of Truth - PG
admin
product
-service
search
-indexer
Source of Truth - PG
admin
View of Truth - PG
svc-search
-feed
Kinesis
Calatrava
VOT
* Changes are propagated in real-time to Solr
* Rebuild of index (s + *) with zero down time
* Same logic for batch & stream (thank you akka-streams)
* V.O.T.: “We needed a relational DB to solve a relational
problem”
S3
Brands, products,
sales, channels, ...
s
Part 3
In which we use a lambda architecture to facade an unscalable unreliable system
as a reliable R+W API… and benefit from always using the same flow.
Real-time inventory: bridging bricks’n’clicks
internet
OMS
warehouse
stores
Inventory
SOT
?
Real-time inventory: bridging bricks’n’clicks
OMS
warehouse
stores
Inventory
SOT RTAM
* Every sku
inventory level
every 24hrs
* Threshold (O,
LWM, HWM)
inventory events.
λ
Elasticache
R+W
* Absolute
inventory values
REST API
* APIBuilder.io
Making a web reservation
OMS
warehouse
stores
Inventory
SOT RTAM
λ
Elasticache REST API
R+W
1. Is inventory >0 ?
2. Attempt a reservation with OMS. IF it fails, generate a
random reservation ID.
3. Put the change on the RTAM stream
4. Update the cache (and stream, not shown)
5, 6, 7. Trigger a best effort to true-up inventory with ATP
(available to purchase)
1.
2.
3.
4.
λ
5.
6.
7.
X
THERE IS ONLY ONE PATH
Part 4
In which we learn that the paradigm generalises across third-party boundaries.
International E-Commerce: Taxes, Shipping & Duty is
HARD. Performance is critical!
Typical solution: cache for PDP & PA, go direct at checkout. Asymmetric,
with chance of sticker-shock.
Third Party
Shipping Partner
Intl Pricing
Cache
Product Listing
Product Details
Checkout
pricing
service
Elasticache
Stream driven solution with flow.io
Pricing
Service
Product
Listing
Product
Details
Checkout
Part 5
In which we consider Kafka vs. Kinesis
∞
Stream: an immutable, append-only log.
Except it isn’t.
Which makes us use snapshots, and complicates our architecture.
LOG
COMPACTION
“Log compaction”: always remember the
latest version of the same object.
Source of Truth
(1, janes bond)
(2, dr. who)
(1, james bond)
(3, fr. ted)
(1, janes bond)
(2, dr. who)
(1, james bond)
(3, fr. ted)
TABLE
STREAM
DUALITY
KTable & Kafka Streams Library
K-Table & Kafka Streams...
#thanks @adrian_trenaman @gilttech @hbcdigital
(0) Apply lambda arch to create scalable, reliable offline systems.
(1) Replicate and transform the one source of truth
(2) It’s not all unicorns and rainbows: complex VOT, snapshots
(3) Kinesis is the gateway drug; Kafka is the destination.
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
lambda-streams-delta

Contenu connexe

Plus de C4Media

Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsC4Media
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechC4Media
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaC4Media
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayC4Media
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?C4Media
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseC4Media
 
A Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinA Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinC4Media
 

Plus de C4Media (20)

Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery Teams
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in Adtech
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven Utopia
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL Database
 
A Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinA Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with Brooklin
 

Dernier

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Dernier (20)

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Lambda Architectures: a Snapshot, a Stream, & a Bunch of Deltas

  • 1. A snapshot, a stream, and a bunch of deltas Applying Lambda Architectures in a post-Microservice World Q-Con London March 6th 2018 Ade Trenaman, SVP Engineering, Raconteur, HBC Tech t: @adrian_trenaman http://tech.hbc.com t: @hbcdigital fa: @hbcdigital in: hbc_digital
  • 2. InfoQ.com: News & Community Site Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ lambda-streams-delta • Over 1,000,000 software developers, architects and CTOs read the site world- wide every month • 250,000 senior developers subscribe to our weekly newsletter • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • 2 dedicated podcast channels: The InfoQ Podcast, with a focus on Architecture and The Engineering Culture Podcast, with a focus on building • 96 deep dives on innovative topics packed as downloadable emags and minibooks • Over 40 new content items per week
  • 3. Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide Presented at QCon London www.qconlondon.com
  • 4.
  • 5.
  • 6.
  • 9. What this talk is about Solving the problem of microservice dependencies with lambda architectures: > performance, scalability, reliability Lambda architecture examples: > product catalog, search, real-time inventory, third-party integration Lessons learnt: > It’s not all rainbows and unicorns > Kinesis vs. Kafka
  • 10. Some context: a minimalist abstraction of our architectural evolution 2007 Monolith 2010 Service Oriented 2012 µ-Services λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ 2016 Rise of Serverless λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ 2018+ Multi-banner Multi-tenant Multi-region λ architectures Streams GraphQL In the seams
  • 11. Slam on the breaks! Dublin Microservices Meetup, Feb 2015
  • 12. Part 0 In which we briefly describe lambda architecture, and the Hollywood Principle
  • 13. Lambda architecture: making batch processing sexy again. Some kind of data-source A view of the data Batch processing ‘the baseline’ Stream processing ‘real-time’ Provide low-latency, high-throughput, reliable, convenient access to the data. Preserve the integrity and purpose of the source of truth. Stream: an append-only, immutable log store of interesting events.
  • 14. Lambda architecture: making batch processing sexy again. Some kind of data-source A view of the data Batch processing ‘the baseline’ Stream processing ‘real-time’ Need to rebuild the view? Take latest snapshot, and replay all events with a greater timestamp. T_7: po T_6: dipsy T_8: tinky T_1: foo T_2: bar T_3: pepe T_4: pipi T_5: lala T_1: foo T_2: bar T_3: pepe T_4: pipi T_5: lala T_6: dipsy ...
  • 16. Inversion of control: previously, we ask for data when we need it. Some kind of data-source A view of the data Provide low-latency, high-throughput, reliable, convenient access to the data. Preserve the integrity and purpose of the source of truth.
  • 17. Inversion of control: now, when the data changes, we are informed. Some kind of data-source A view of the data Provide low-latency, high-throughput, reliable, convenient access to the data. Preserve the integrity and purpose of the source of truth.
  • 18. Part I In which we learn the perils of caching in a microservices architecture, and how lambda architecture helped us out.
  • 19. Gilt: we source luxury brands...
  • 20. … we shoot the product in our studios
  • 22. … we sell every day at noon
  • 24.
  • 25. The Gilt Problem Massive pulse of traffic, every day. => serve fast Low inventory quantities of high value merchandise, changing rapidly => can’t cache Individually personalised landing experiences => can’t cache
  • 26. Caching “Just say no.” “Until you have to say yes.” “Then, just say maybe.”
  • 27. consumer (e.g. web-pdp) A stateless, cache-free library, busted. product-service inventory-service price-service commons <<lib>> Hmm, engineer adds a local brand cache to reduce network calls.. … and then later, another cache for product information. Leads to (1) arbitrary caching policies, & (2) duplicated cache information. product cache brand cache
  • 28. A caching library. Worked well initially, but... product-service inventory-service price-service consumer (e.g. web-pdp) commons <<lib>> We changed the commons library to cache products with a consistent, timed refresh (20m). Worked well, until the business changed its mind about one small thing: let’s make everything in the warehouse sellable. Orders of magnitude more SKUs: * JSON from product service > 1Gb * Startup time > 10m * JVM garbage collection every 20m on cache clear * ~1hr to propagate a change. * m4.xlarge, w/ 14Gb JVM Heap product cache brand cache
  • 29. Near real-time caching at scale Source of Truth - PG admin web-pdp commons L1 * Startup time ~1s * No more stop-the-world GC * ~seconds to propagate a change. * c4.xlarge (CPU!!!), w/ 6Gb JVM Heap Next: replace JSON marshalling with binary OTW format (e.g. AVRO) S3 Brands, products, sales, channels, ... s Elasticache product -service Kinesis Calatrava λ
  • 31. Part 2 In which we learn how we’ve used Lambda architecture to implement a near real-time search index, but needed an additional relational ‘view of truth’.
  • 32. Problem: polling a polling service means changes to product data are not reflected in realtime. Source of Truth - PG admin product -service search -indexer
  • 33. Source of Truth - PG admin View of Truth - PG svc-search -feed Kinesis Calatrava VOT * Changes are propagated in real-time to Solr * Rebuild of index (s + *) with zero down time * Same logic for batch & stream (thank you akka-streams) * V.O.T.: “We needed a relational DB to solve a relational problem” S3 Brands, products, sales, channels, ... s
  • 34. Part 3 In which we use a lambda architecture to facade an unscalable unreliable system as a reliable R+W API… and benefit from always using the same flow.
  • 35. Real-time inventory: bridging bricks’n’clicks internet OMS warehouse stores Inventory SOT ?
  • 36. Real-time inventory: bridging bricks’n’clicks OMS warehouse stores Inventory SOT RTAM * Every sku inventory level every 24hrs * Threshold (O, LWM, HWM) inventory events. λ Elasticache R+W * Absolute inventory values REST API * APIBuilder.io
  • 37. Making a web reservation OMS warehouse stores Inventory SOT RTAM λ Elasticache REST API R+W 1. Is inventory >0 ? 2. Attempt a reservation with OMS. IF it fails, generate a random reservation ID. 3. Put the change on the RTAM stream 4. Update the cache (and stream, not shown) 5, 6, 7. Trigger a best effort to true-up inventory with ATP (available to purchase) 1. 2. 3. 4. λ 5. 6. 7.
  • 38. X THERE IS ONLY ONE PATH
  • 39. Part 4 In which we learn that the paradigm generalises across third-party boundaries.
  • 40. International E-Commerce: Taxes, Shipping & Duty is HARD. Performance is critical!
  • 41. Typical solution: cache for PDP & PA, go direct at checkout. Asymmetric, with chance of sticker-shock. Third Party Shipping Partner Intl Pricing Cache Product Listing Product Details Checkout pricing service
  • 42. Elasticache Stream driven solution with flow.io Pricing Service Product Listing Product Details Checkout
  • 43. Part 5 In which we consider Kafka vs. Kinesis
  • 44. ∞ Stream: an immutable, append-only log. Except it isn’t. Which makes us use snapshots, and complicates our architecture.
  • 46. “Log compaction”: always remember the latest version of the same object. Source of Truth (1, janes bond) (2, dr. who) (1, james bond) (3, fr. ted) (1, janes bond) (2, dr. who) (1, james bond) (3, fr. ted)
  • 48. KTable & Kafka Streams Library
  • 49. K-Table & Kafka Streams...
  • 50. #thanks @adrian_trenaman @gilttech @hbcdigital (0) Apply lambda arch to create scalable, reliable offline systems. (1) Replicate and transform the one source of truth (2) It’s not all unicorns and rainbows: complex VOT, snapshots (3) Kinesis is the gateway drug; Kafka is the destination.
  • 51. Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ lambda-streams-delta