2017-08-04#
Ran Across Today#
Which brings us to the second reason for this post, the difference between “Architecture” and “Design”. In a nutshell, architecture is a type of design where the focus is quality attributes and wide(er) scope whereas design focuses on functional requirements and more localized concerns.Randy Shoup - Techniques for dealing with shared data, joins, and transactions in a microservices architecture#
https://www.infoq.com/presentations/microservices-data-centric
Scratch Notes...
Software combines #
Organizes- Small Teams directly defined within a particular function of the business.
- Teams need other teams.
Processes - Test Driven Development#
- Testing increases velocity
- Tests make better code
- Provides courage to try new thing, knowing you can refrator something and know it will work or not.
- Tests allow fast failures
We do not have time to do it right? - Do you have time to do it more than once?
- The more time constraints the more it is better to build it right (80/20 rule)
- Better to build one thing right than two things half-right.
Continuous Delivery #
- Release smaller sprints.
- Allows rapid experiments
DevOps#
- You build it, you Run it.
- End-to-end ownership of what you write - Full lifecycle of software.
- No separate QA team
- No separate Deployment team
Evolution to microservices#
- ebay 5th generation
- Pearl
- C++ 3.4 million lines of code
- Java - Several different Java Apps
- Polyglot of microservices.
Twiter similar.#
Amazon #
- Mono perl and c++ OBIDOUS
- Java Scala
No place started with Microservice and no place at this scale is NOT using Microservice.
Microservices may not be the right for startups. Monos are ok.
Microservices #
- Scope is single purpose
- Moduler and independenrt
- SOA done properly (Bounded Context)
Isolatated persistence
- No sneaking in to look at the other guys data.
- Same team that writes the micorservice owns the data store OR - use a external data store
- Still ISOLATED
- Only external access to data store is via public interface
Event-triggered should be a first-class object#
- A thing happend - Something I cared about
- Asynchronous Operation - No care if someone is listening.
- State changes or events must be used.
- Why - Represents how the world works
Must be within an interface within microservices
- interface is for any data into or out of a microservice
- Stich Fix is still a mono data base with 175 tables
- Single point of failure.
Solution is decoupling data how to do it #
- Write a service interface to isolate data access for the table.
- Rinse and repaet
- Simple discussion but a lot of code changes and joins etc.
Bounded context mentioned many times.
Managing data within microservices.
- shared data
- Joins work well in mono-data
One service OWNS the data (Customer)
- Every other service is a RO non-authoritative service
Approach one just look it up? - Every other service looks it up
If too expensive to do ...Eventing from Customer service
Shared metadata - Much of it does not change often.#
- colors, US States, Shoe Sizes zip codes ....
Joins in microservices #
- Approach one - Joins in application
- make two calls to different services.
- Works well for one-to-many just as a Web page does.
Approach two
- Maintain a cache of a join
- Item feedback example many-to-many
- Listens to items service and feedback service to make join ....
- Materializing a view in realtime
- NoSql does this
Transactions #
Easy in relation db. ACID etc.- SAGA Pattern -
- Commit - Workflow that updates different data stores.
- Rollback - reverse workflow
- Serverless - Functions as a Service is a great way to do this.
Big believer Lambda Google Cloud functions Azure Functions - triggered by events and produces an event
Stich Fix is hiring - 50% are remote
Events that do not arrive or like SLP exactly once deliver out of order more than once
Evens should use - At least once deliver
- More than once Mutiple times - Item impotent
- Out of order - Do you care - Consumer must maintain state
At most once - think of UDP