Microservices Flashcards

1
Q

Why use microservices instead of just writing Python programs directly?

A

Only 1% of monolithic projects ever achieve the scale required to use microservices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the key characteristics of a microservices system?

A
  1. Multiple programs
  2. Each runs as multiple processes
  3. Communicate via network messages
  4. Each runs in its own address space
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why is it important to agree on the form of messages in microservices?

A

To ensure smooth communication and integration between microservices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is REST in microservices?

A

A commonly used network protocol, a conventional form of HTTP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the four REST resource archetypes?

A
  1. Document - File-like resources (GET, PUT, DELETE)
  2. Controller - External resources (POST)
  3. Collection - Directory-like resources with generated names (GET, POST)
  4. Store - Directory-like resources with given names (GET, PUT)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does a microservices enterprise typically store its data?

A

In a distributed database, accessed by individual microservices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the risk of using a shared database in microservices?

A

When one microservice updates the database, all others must be aware, causing complexity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the two ways to manage distributed transactions?

A
  1. Two-Phase Commit
  2. Sagas
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does Two-Phase Commit work?

A
  1. A coordinator asks participants to vote on committing.
  2. If all agree, they commit; otherwise, they abort.
  3. Participants hold locks until a decision is made.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a drawback of Two-Phase Commit?

A

Locks take time, making customers wait until the transaction is finished.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does the Saga transaction model work?

A
  1. A coordinator asks each participant to commit or abort in sequence.
  2. If one aborts, compensating transactions undo previous commits.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a drawback of Sagas?

A

They sacrifice atomicity and rely on eventual consistency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How is a microservices system typically scaled?

A

By horizontal scaling – adding machines that run one or more microservice instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why is horizontal scaling easier than vertical scaling?

A

Adding machines is simpler than upgrading a monolithic system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why are microservices more reliable than monoliths?

A

If one microservice crashes, it does not bring down the entire system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How does a load balancer help in microservices?

A

It detects failed microservices and stops sending requests to them.

17
Q

What is the main challenge of migrating from a monolith to microservices?

A

The system won’t work while upgrading, which takes time and risks losing customers.

18
Q

What is the Strangler Design Pattern?

A

A method for migrating from a monolithic MVP to microservices by gradually replacing modules behind a façade.

19
Q

How does the Strangler Fig analogy relate to microservices migration?

A

Just as the fig tree slowly replaces its host, microservices gradually replace monolithic modules behind a façade.

20
Q

What role does a façade play in microservices migration?

A

It acts as a proxy, ensuring customers don’t notice architecture changes.

21
Q

What are Martin Fowler’s 9 characteristics of microservices?

A
  1. Componentisation via services
  2. Organised around business capabilities
  3. Products not projects
  4. Smart endpoints, dumb pipes
  5. Decentralised governance
  6. Decentralised data management
  7. Infrastructure automation
  8. Design for failure
  9. Evolutionary design
22
Q

What is a component in microservices?

A

Something that is independently replaceable and upgradeable.

23
Q

Why should microservices be organized around business capabilities?

A

So that each service team connects directly to users and is judged by business impact.

24
Q

Should microservice endpoints be smart or dumb?

A

Endpoints should be smart, and pipes should be dumb.

25
What is the rule for microservice data management?
Every service should be responsible for its own data and persistence.
26
What must be assumed in any distributed system?
That **things will break**, so failure must be planned for.
27
How big should a microservice be?
Small enough to be developed by a team that can be fed with **two pizzas** (Amazon's idea).
28
What must be in place before adopting microservices?
1. Rapid provisioning 2. Basic monitoring 3. Rapid application deployment 4. DevOps culture