Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/2t6qfgf.
Randy Shoup discusses managing data in microservices and shares proven patterns and practical advice that has been successful at Google, eBay, and Stitch Fix. Filmed at qconsf.com.
Randy Shoup is a 25-year veteran of Silicon Valley, and has worked as a senior technology leader and executive at companies ranging from small startups, to mid-sized places, to eBay and Google. He is currently VP Engineering at Stitch Fix in San Francisco. He is particularly passionate about the nexus of culture, technology, and organization.
2. InfoQ.com: News & Community Site
• 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
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
microservices-managing-data
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 San Francisco
www.qconsf.com
4. Background
• VP Engineering at Stitch Fix
o Using technology and data science to revolutionize clothing retail
• Consulting “CTO as a service”
o Helping companies move fast at scale J
• Director of Engineering for Google App Engine
o World’s largest Platform-as-a-Service
• Chief Engineer at eBay
o Evolving multiple generations of eBay’s infrastructure
11. Data at the Center
• 1:1 Ratio of Data Science to Engineering
o More than 100 software engineers
o ~80 data scientists and algorithm developers
o Unique ratio in our industry
• Apply intelligence to *every* part of the business
o Buying
o Inventory management
o Logistics optimization
o Styling recommendations
o Demand prediction
• Humans and machines augmenting each other
@randyshoup linkedin.com/in/randyshoup
12. Design Goals
• Feature Velocity
o Teams can move rapidly and independently
• Scalability
o Components can be scaled independently depending on load
• Resilience
o Component failures are isolated, do not cascade
@randyshoup linkedin.com/in/randyshoup
13. High-Performing
Organizations
• Multiple deploys per day vs. one per month
• Commit to deploy in less than 1 hour vs. one week
• Recover from failure in less than 1 hour vs. one day
• Change failure rate of 0-15% vs. 31-45%
@randyshoup linkedin.com/in/randyshoup
https://puppet.com/resources/whitepaper/state-of-devops-report
14. High-Performing
Organizations
è2.5x more likely to exceed
business goals
o Profitability
o Market share
o Productivity
@randyshoup linkedin.com/in/randyshoup
https://puppet.com/resources/whitepaper/state-of-devops-report
15. “Tell us how you did things at
Google and eBay.”
…
“Sure, I will tell you, but you
have to promise not to do them!
[… yet]”
16. Evolution to
Microservices
• eBay
• 5th generation today
• Monolithic Perl à Monolithic C++ à Java à microservices
• Twitter
• 3rd generation today
• Monolithic Rails à JS / Rails / Scala à microservices
• Amazon
• Nth generation today
• Monolithic Perl / C++ à Java / Scala à microservices
@randyshoup linkedin.com/in/randyshoup
17. No one starts with microservices
…
Past a certain scale, everyone
ends up with microservices
18. If you don’t end up regretting
your early technology
decisions, you probably over-
engineered.
30. Events as
First-Class Construct
• “A significant change in state”
o Statement that some interesting thing occurred
• Traditional 3-tier system
o Presentation è interface / interaction
o Application è stateless business logic
o Persistence è database
• Fourth fundamental building block
o State changes è events
o 0 | 1 | N consumers subscribe to the event, typically asynchronously
@randyshoup linkedin.com/in/randyshoup
31. Microservices
and Events
• Events are a first-class part of a service interface
• A service interface includes
o Synchronous request-response (REST, gRPC, etc)
o Events the service produces
o Events the service consumes
o Bulk reads and writes (ETL)
• The interface includes any mechanism for getting
data in or out of the service (!)
@randyshoup linkedin.com/in/randyshoup
32. Microservice Techniques:
Shared Data
• Monolithic database makes it easy to leverage
shared data
• Where does shared data go in a microservices
world?
@randyshoup linkedin.com/in/randyshoup
33. Microservice Techniques:
Shared Data
• Principle: Single System of Record
o Every piece of data is owned by a single service
o That service is the canonical system of record for that data
• Every other copy is a read-only, non-authoritative
cache
@randyshoup linkedin.com/in/randyshoup
customer-service
styling-service
customer-search
billing-service
34. Microservice Techniques:
Shared Data
• Approach 1: Synchronous Lookup
o Customer service owns customer data
o Fulfillment service calls customer service in real time
fulfillment-service
customer-service
@randyshoup linkedin.com/in/randyshoup
35. Microservice Techniques:
Shared Data
• Approach 2: Async event + local cache
o Customer service owns customer data
o Customer service sends address-updated event when customer address
changes
o Fulfillment service caches current customer address
fulfillment-servicecustomer-service
@randyshoup linkedin.com/in/randyshoup
36. Microservice Techniques:
Joins
• Monolithic database makes it easy to join tables
• Splitting the data across microservices makes joins
very hard
@randyshoup linkedin.com/in/randyshoup
SELECT FROM A INNER JOIN B ON …
37. Microservice Techniques:
Joins
• Approach 1: Join in Client Application
o Get a single customer from customer-service
o Query matching orders for that customer from order-service
Customers
Orders
order-history-page
customer-service order-service
38. Microservice Techniques:
Joins
• Approach 2: Service that “Materializes the View”
o Listen to events from item-service, events from order-service
o Maintain denormalized join of items and orders together in local storage
Items Order Feedback
item-feedback-service
item-service
order-feedback-service
39. Microservice Techniques:
Joins
• Many common systems do this
o “Materialized view” in database systems
o Most NoSQL systems
o Search engines
o Analytic systems
@randyshoup linkedin.com/in/randyshoup
40. Microservice Techniques:
Workflows and Sagas
• Monolithic database makes transactions across
multiple entities easy
• Splitting data across services makes transactions
very hard
@randyshoup linkedin.com/in/randyshoup
BEGIN; INSERT INTO A …; UPDATE B...; COMMIT;
41. Microservice Techniques:
Workflows and Sagas
• Transaction è Saga
o Model the transaction as a state machine of atomic events
• Reimplement as a workflow
• Roll back by applying compensating operations in
reverse
A B C
A B C
@randyshoup linkedin.com/in/randyshoup
42. Microservice Techniques:
Workflows and Sagas
• Many common systems do this
o Payment processing
o Expense approval
o Any multi-step workflow
@randyshoup linkedin.com/in/randyshoup
44. Thanks!
• Stitch Fix is hiring!
o www.stitchfix.com/careers
o Based in San Francisco
o Hiring everywhere!
o More than half remote, all across US
o Application development, Platform engineering,
Data Science
• Please contact me
o @randyshoup
o linkedin.com/in/randyshoup
45. Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
microservices-managing-data