Microservices Flashcards
Why use microservices instead of just writing Python programs directly?
Only 1% of monolithic projects ever achieve the scale required to use microservices.
What are the key characteristics of a microservices system?
- Multiple programs
- Each runs as multiple processes
- Communicate via network messages
- Each runs in its own address space
Why is it important to agree on the form of messages in microservices?
To ensure smooth communication and integration between microservices.
What is REST in microservices?
A commonly used network protocol, a conventional form of HTTP.
What are the four REST resource archetypes?
- Document - File-like resources (GET, PUT, DELETE)
- Controller - External resources (POST)
- Collection - Directory-like resources with generated names (GET, POST)
- Store - Directory-like resources with given names (GET, PUT)
How does a microservices enterprise typically store its data?
In a distributed database, accessed by individual microservices.
What is the risk of using a shared database in microservices?
When one microservice updates the database, all others must be aware, causing complexity.
What are the two ways to manage distributed transactions?
- Two-Phase Commit
- Sagas
How does Two-Phase Commit work?
- A coordinator asks participants to vote on committing.
- If all agree, they commit; otherwise, they abort.
- Participants hold locks until a decision is made.
What is a drawback of Two-Phase Commit?
Locks take time, making customers wait until the transaction is finished.
How does the Saga transaction model work?
- A coordinator asks each participant to commit or abort in sequence.
- If one aborts, compensating transactions undo previous commits.
What is a drawback of Sagas?
They sacrifice atomicity and rely on eventual consistency.
How is a microservices system typically scaled?
By horizontal scaling – adding machines that run one or more microservice instances.
Why is horizontal scaling easier than vertical scaling?
Adding machines is simpler than upgrading a monolithic system.
Why are microservices more reliable than monoliths?
If one microservice crashes, it does not bring down the entire system.
How does a load balancer help in microservices?
It detects failed microservices and stops sending requests to them.
What is the main challenge of migrating from a monolith to microservices?
The system won’t work while upgrading, which takes time and risks losing customers.
What is the Strangler Design Pattern?
A method for migrating from a monolithic MVP to microservices by gradually replacing modules behind a façade.
How does the Strangler Fig analogy relate to microservices migration?
Just as the fig tree slowly replaces its host, microservices gradually replace monolithic modules behind a façade.
What role does a façade play in microservices migration?
It acts as a proxy, ensuring customers don’t notice architecture changes.
What are Martin Fowler’s 9 characteristics of microservices?
- Componentisation via services
- Organised around business capabilities
- Products not projects
- Smart endpoints, dumb pipes
- Decentralised governance
- Decentralised data management
- Infrastructure automation
- Design for failure
- Evolutionary design
What is a component in microservices?
Something that is independently replaceable and upgradeable.
Why should microservices be organized around business capabilities?
So that each service team connects directly to users and is judged by business impact.
Should microservice endpoints be smart or dumb?
Endpoints should be smart, and pipes should be dumb.