the hardest part of microservices: your data

65

Upload: ceposta

Post on 08-Feb-2017

2.182 views

Category:

Software


0 download

TRANSCRIPT

Page 1: The hardest part of microservices: your data
Page 2: The hardest part of microservices: your data
Page 3: The hardest part of microservices: your data

Twitter: @christianpostaBlog: http://blog.christianposta.comEmail: [email protected]

Christian PostaPrincipal Architect – Red Hat

• Author “Microservices for Java Developers”• Committer/contributor Apache Camel, Apache

ActiveMQ, Fabric8.io, Apache Kafka, Debezium.io, et. al.

• Worked with large Microservices, web-scale, unicorn company

• Blogger, speaker about DevOps, integration, and microservices

Page 4: The hardest part of microservices: your data

Free download @ http://developers.redhat.com

Page 5: The hardest part of microservices: your data
Page 6: The hardest part of microservices: your data

“Microservices” is about optimizing… for speed.

Page 7: The hardest part of microservices: your data

People try to copy Netflix, but they can only copy what they see. They copy the results, not the process.

Adrian Cockcroft, former Chief Cloud Architect, Netflix

Page 8: The hardest part of microservices: your data

How does your company go fast?

Page 9: The hardest part of microservices: your data

Manage dependencies.

Page 10: The hardest part of microservices: your data

Data is a major dependency.

Page 11: The hardest part of microservices: your data

Wait. What is data?

Page 12: The hardest part of microservices: your data

What is one “thing”?

Page 13: The hardest part of microservices: your data

Book checkout / purchase Title Search

Recommendations

Weekly reporting

Page 14: The hardest part of microservices: your data
Page 15: The hardest part of microservices: your data

Focus on domain models, not data models

• Break things into smaller, understandable models

• Surround a model and its “context” with a boundary

• Implement the model in code or get a new model

• Explicitly map between different contexts

• Model transactional boundaries as aggregates

Page 16: The hardest part of microservices: your data

“A microservice has its own database”

Page 17: The hardest part of microservices: your data
Page 18: The hardest part of microservices: your data
Page 19: The hardest part of microservices: your data
Page 20: The hardest part of microservices: your data
Page 21: The hardest part of microservices: your data
Page 22: The hardest part of microservices: your data
Page 23: The hardest part of microservices: your data

Stick with these conveniences as long as you can.Seriously.

Page 24: The hardest part of microservices: your data

But ...• Load/size is too great to fit on one box• Modules/use cases have different read/write

characteristics• Queries/joins are getting too complex• Security issues• Lots of conflicting changes to the model/schema• Need denormalized, optimized indexing engines• We can live with eventual consistency (whatever

that really means)

Page 25: The hardest part of microservices: your data

Kinda looks like a combinatorial mess….

Page 26: The hardest part of microservices: your data
Page 27: The hardest part of microservices: your data

How do we deal with data in this world?

Page 28: The hardest part of microservices: your data

We’re now building a full-fledged distributed system.Some things to remember…

Page 29: The hardest part of microservices: your data
Page 30: The hardest part of microservices: your data
Page 31: The hardest part of microservices: your data
Page 32: The hardest part of microservices: your data
Page 33: The hardest part of microservices: your data
Page 34: The hardest part of microservices: your data
Page 35: The hardest part of microservices: your data
Page 36: The hardest part of microservices: your data

Plan for failures. Build concepts of time, delay, network, and failures into the design as a first-class citizen.

Page 37: The hardest part of microservices: your data
Page 38: The hardest part of microservices: your data
Page 39: The hardest part of microservices: your data
Page 40: The hardest part of microservices: your data
Page 41: The hardest part of microservices: your data
Page 42: The hardest part of microservices: your data

https://secure.phabricator.com/book/phabcontrib/article/n_plus_one/

Page 43: The hardest part of microservices: your data

https://secure.phabricator.com/book/phabcontrib/article/n_plus_one/

Page 44: The hardest part of microservices: your data

We need “consistency”. But we expect failures. This is starting to sound like CAP theorem…

Page 45: The hardest part of microservices: your data

What is consistency?

The history of past operations we observe as a reader of the data

Page 46: The hardest part of microservices: your data

Consistency models…

https://en.wikipedia.org/wiki/Consistency_model

• Strict consistency (Linearizability)• Sequential consistency• Causal consistency• Processor consistency• PRAM consistency (FIFO)• Bounded staleness consistency• Monotonic read consistency• Monotonic write consistency• Read your writes consistency• Eventual consistency

Page 47: The hardest part of microservices: your data
Page 48: The hardest part of microservices: your data
Page 49: The hardest part of microservices: your data
Page 50: The hardest part of microservices: your data

Linearizable (strict) consistency

Page 51: The hardest part of microservices: your data

Sequential consistency

Page 52: The hardest part of microservices: your data

Monotonic reads consistency

Page 53: The hardest part of microservices: your data

Eventual consistency

Page 54: The hardest part of microservices: your data

Can we really use relaxed consistency models?

Page 55: The hardest part of microservices: your data

Replicated Data Consistency Explained through Baseball (Doug Terry)

https://www.microsoft.com/en-us/research/publication/replicated-data-consistency-explained-through-baseball/

• What consistency model do you need, depending on what role you’re playing?

• What consistency model are you willing to pay for?• Official score keeper? (Linearizability or RMW)• Umpire? (Linearizability)• Sports writer? (Bounded staleness, Eventual

consistency)• Radio updates? (Monotonic read, Bounded

staleness)• Statistician (Bounded staleness)• Friends in the pub (Eventual consistency)

Page 56: The hardest part of microservices: your data

Replicated Data Consistency Explained through Baseball (Doug Terry)

https://www.microsoft.com/en-us/research/publication/replicated-data-consistency-explained-through-baseball/

Page 57: The hardest part of microservices: your data

Tradeoffs to make with read consistency and performance

Page 58: The hardest part of microservices: your data

Maybe we can use a relaxed consistency model for some of those previously mentioned use cases…

Page 59: The hardest part of microservices: your data

Example using sequential consistency…

Page 60: The hardest part of microservices: your data

Internet companies created their own toolsfor helping with this. (some opensource!!)

• Yelp – MySQL Streamerhttps://github.com/Yelp/mysql_streamer

• LinkedIn – Databushttps://github.com/linkedin/databus

• Zendesk – Maxwellhttps://github.com/zendesk/maxwell

Page 61: The hardest part of microservices: your data

Meet debezium.io

Page 62: The hardest part of microservices: your data
Page 63: The hardest part of microservices: your data

Meet debezium.io

Page 64: The hardest part of microservices: your data
Page 65: The hardest part of microservices: your data

Twitter: @christianpostaBlog: http://blog.christianposta.comEmail: [email protected]

Thanks for listening! Time for demo?