Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate best approach for communication (queues, notification - pub sub model) between the API and microservices based on AWS technologies #1

Open
emettely opened this issue Jun 20, 2019 · 7 comments

Comments

@emettely
Copy link
Contributor

emettely commented Jun 20, 2019

Context

Deciding the best approach for communication between microservices and API.

Acceptance Criteria

Decide and create an ADR around this.

Things to consider

  • locally running
  • simplicity
  • resilience
@emettely emettely self-assigned this Jun 20, 2019
@emettely
Copy link
Contributor Author

emettely commented Jun 20, 2019

Microservices that poll on the queue to receive the jobs

                                                 +-------+
                                          Poll   | Video |
                                            +----+ Pre   |
                                            |    +-------+
                                            |
+----------+            AWS Queue           |    +-------+
|          | PUSH  +-+-+-+-+-+-+-+-+-+-+    |    | Audio |
|   API    +------>+ | | | | | | | | | +<--------+ Strip +----+
|          |       +---+-+-+-+-+-+-+-+-+    |    +-------+    |
|          |         ^                      |                 |
+----------+         |                      |    +-------+    |
                     |                      |    | STT   |    |
                     |                      +----+       |    |
                     |                           +-------+    |
                     |                                        |
                     |                                        |
                     +----------------------------------------+
                                       PUSH

@emettely
Copy link
Contributor Author

emettely commented Jun 20, 2019

Message processing microservice fronts API Microservices. The message processor polls the queues and calls the APIs.

                                                                  +-------+
                                                                  | Video |
                                                             +--->+ Pre   |
                                                             |    +-------+
                                                             |
+----------+            AWS Queue              +------+      |    +-------+
|          | PUSH  +-+-+-+-+-+-+-+-+-+-+  POLL | msg  | POST |    | Audio |
|   API    +------>+ | | | | | | | | | +<------+ proc +---------->+ Strip +---+
|          |       +---+-+-+-+-+-+-+-+-+       +------+      |    +-------+   |
|          |         ^                                       |                |
+----------+         |                                       |    +-------+   |
                     |                                       |    | STT   |   |
                     |                                       +--->+       |   |
                     |                                            +-------+   |
                     |                                                        |
                     |                                                        |
                     +--------------------------------------------------------+
                                       PUSH

@emettely
Copy link
Contributor Author

Alternatively, get rid of all the queues.

                       +-------+
                       | Video |
                  +--->+ Pre   |
                  |    +-------+
+----------+      |
|          |      |    +-------+
|   API    | POST |    | Audio |
|          +---------->+ Strip |
|          |      |    +-------+
+----------+      |
                  |    +-------+
                  |    | STT   |
                  +--->+       |
                       +-------+

@pietrop
Copy link
Contributor

pietrop commented Jun 20, 2019

This is a very good read on Microservices architecture style

But to flash this out a bit more we should also look into other Architecture styles

Also worth reading this awesome API design guide about RESTful APIs.

In particular the section about dealing with Asynchronous operations.

Sometimes a POST, PUT, PATCH, or DELETE operation might require processing that takes a while to complete. If you wait for completion before sending a response to the client, it may cause unacceptable latency. If so, consider making the operation asynchronous. Return HTTP status code 202 (Accepted) to indicate the request was accepted for processing but is not completed.

You should expose an endpoint that returns the status of an asynchronous request, so the client can monitor the status by polling the status endpoint. Include the URI of the status endpoint in the Location header of the 202 response. For example:

Also see Simple Microservices Architecture on AWS

10 Design Principles for AWS Cloud Architecture

IT systems should ideally be designed in a way that reduces inter-dependencies. Your components need to be loosely coupled to avoid changes or failure in one of the components from affecting others.

Your infrastructure also needs to have well defined interfaces that allow the various components to interact with each other only through specific, technology-agnostic interfaces. Modifying any underlying operations without affecting other components should be made possible.

Competing Consumers pattern

An application running in the cloud is expected to handle a large number of requests. Rather than process each request synchronously, a common technique is for the application to pass them through a messaging system to another service (a consumer service) that handles them asynchronously. This strategy helps to ensure that the business logic in the application isn't blocked while the requests are being processed.

Queue-Based Load Leveling pattern

Use a queue that acts as a buffer between a task and a service it invokes in order to smooth intermittent heavy loads that can cause the service to fail or the task to time out. This can help to minimize the impact of peaks in demand on availability and responsiveness for both the task and the service.


TL;DR: we don’t have to use microservices - we could use

@emettely
Copy link
Contributor Author

20190621_162914

@emettely
Copy link
Contributor Author

emettely commented Jun 21, 2019

Will write up an ADR around this with an updated diagram in infrastructure.

emettely pushed a commit to bbc/digital-paper-edit-infrastructure that referenced this issue Jun 21, 2019
@emettely emettely moved this from In progress to Review in progress in BBC News Labs - (0) Digital Paper Edit - Sprint Board Jun 24, 2019
emettely added a commit to bbc/digital-paper-edit-infrastructure that referenced this issue Jun 25, 2019
* bbc/digital-paper-edit-api#1 adding diagrams and updated ADR

* Updated diagram

* updated adr for option 3

* Update docs/adr/2019-04-23-transcript-architecture.md

Co-Authored-By: Pietro <[email protected]>

* Update docs/adr/2019-04-23-transcript-architecture.md

Co-Authored-By: Pietro <[email protected]>

* Updated with more details

* Adding heading to each diagram

* Spelling error fix and added another change in option 3

* Review done by Pietro - adding final conclusion
@emettely emettely moved this from Review in progress to Reviewer approved in BBC News Labs - (0) Digital Paper Edit - Sprint Board Jun 26, 2019
@emettely emettely moved this from Reviewer approved to Done in BBC News Labs - (0) Digital Paper Edit - Sprint Board Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants