Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Choosing between non-blocking synchronous APIs and event-driven asynchronous services

Pragya Keshap answered on February 20, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Blocking calls are synchronous
  • difference between asynchous and non blocking
  • A Reactive REST Template for making non-blocking async HTTP requests
  • cases where non-blocking synchronous APIs could be favorable to use
  • Non-blocking REST APIs in the core services
  • Non-blocking REST APIs in the composite services
  • Developing non-blocking synchronous REST APIs

  • Choosing between non-blocking synchronous APIs and event-driven asynchronous services

    0

    When developing reactive microservices, it is not always obvious when to use non-blocking synchronous APIs and when to use event-driven asynchronous services. In general, to make a microservice robust and scalable, it is important to make it as autonomous as possible, for example, by minimizing its runtime dependencies. This is also known as loose coupling. Therefore, asynchronous message passing of events is preferable over synchronous APIs. This is because the microservice will only depend on access to the messaging system at runtime, instead of being dependent on synchronous access to a number of other microservices.

    There are, however, a number of cases where synchronous APIs could be favorable. For example:

    For read operations where an end user is waiting for a response

    Where the client platforms are more suitable for consuming synchronous APIs, for example, mobile apps or SPA web applications

    Where the clients will connect to the service from other organizations – where it might be hard to agree on a common messaging system to use across organizations

    For the system landscape in this book, we will use the following:

    The create, read, and delete services exposed by the product composite microservice will be based on non-blocking synchronous APIs. The composite microservice is assumed to have clients on both web and mobile platforms, as well as clients coming from other organizations rather than the ones that operate the system landscape. Therefore, synchronous APIs seem like a natural match.

    The read services provided by the core microservices will also be developed as non-blocking synchronous APIs since there is an end user waiting for their responses.

    The create and delete services provided by the core microservices will be developed as event-driven asynchronous services, meaning that they will listen for create and delete events on topics dedicated to each microservice.

    The synchronous APIs provided by the composite microservices to create and delete aggregated product information will publish create and delete events on these topics. If the publish operation succeeds, it will return with a 202 (Accepted) response, otherwise an error response will be returned. The 202 response differs from a normal 200 (OK) response – it indicates that the request has been accepted, but not fully processed. Instead, the processing will be completed asynchronously and independently of the 202 response. 

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 20 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.