Publish Subscribe Architecture Flashcards

1
Q

What advantage can be realized when using publish subscribe over request response?

A

Request response, even asynchronous has to wait for a response from all the dependent services in a micro services architecture which may result in a delay to the client. Implementing PS reduces the coupling between the services such that the request is handled when services become available and don’t block the original service from sending a successful reply to the client.

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

Advantages

A
  1. Decouples services and instead publishes to the broker
  2. Simplifies debugging errors by reducing the points of failure to the broker and not in the exchange of messages between services.
  3. You have a single contract across the services rather than multiple different messages that need to be created and consumed per services (b/c the original message is just propagated through the system and handled accordingly).
  4. Guarantees delivery of messages through the architecture because the broker persists messages. A lost transaction guarantee of at least once.
  5. More salable by allowing for a new service to simply be registered to the broker and doesn’t need any knowledge of the other subscribers to receive the messages.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Disadvantages

A
  1. Can’t use for systems that need to have transactions across services and can result in data consistency issues because all services may not execute in a coordinated manner (i.e. transferring money)
  2. Can’t guarantee idempotency (i.e. a message causes a service to withdraw money, if it fails and the message is resent more money is withdrawn). Instead it needs a key to compare with to see if money has already been withdrawn and if it has than ignore (this architecture requires application logic to do this).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s an example of a publish subscriber system?

A

Twitter, post tweets, read tweets in the timeline.

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