When and where to use gRPC: A comprehensive guide

Play video
This article is a summary of a YouTube video "Where should you use gRPC? And where NOT to use it!" by CodeOpinion
TLDR While gRPC is useful for certain scenarios, it should not be used for service-to-service communication as it can lead to a tightly coupled system, and messaging should be used instead for decoupling services and enabling long-running business processes.

Key insights

  • 🔄
    The speaker discusses different options for dealing with failures in gRPC, including automatic retry, exponential back off, and dead letter queues.
  • 💡
    gRPC is well-suited for interacting with infrastructure, such as databases, as it provides options for dealing with failures and fault tolerance.
  • 🚀
    gRPC is not suitable for managing a distributed monolith or a distributed turd pile, as it adds latency and requires everything to be online for it to work correctly.

Q&A

  • Is gRPC suitable for service-to-service communication?

    No, gRPC is useful for request-response scenarios but should not be used for service-to-service communication.

  • When is gRPC a good choice for communication?

    gRPC is a good choice for browser requests to backend services or API gateways that require request-response communication and building view models.

  • Why is messaging preferred over gRPC for decoupling services?

    Messaging is preferred over gRPC for decoupling services because it allows them to work independently and enables long-running business processes involving multiple services.

  • What are the challenges of using gRPC in long-running business processes?

    It is difficult to handle failures and undo previous actions without a distributed transaction system like in a monolith when using gRPC in long-running business processes.

  • When may gRPC not be suitable for service-to-service communication?

    gRPC may not be suitable for service-to-service communication when the originating request starts from a message pulled from a queue or broker, as failures can occur without impacting end users.

Timestamped Summary

  • 📌
    00:00
    gRPC is useful for request-response scenarios like queries or UI/view composition, but it should not be used for service-to-service communication.
  • 🚫
    01:50
    Using gRPC for direct service-to-service communication can lead to a tightly coupled system, making it harder to build a resilient system.
  • 📌
    02:47
    Use messaging instead of gRPC to decouple services and allow them to work independently in long-running business processes involving multiple services.
  • 📌
    04:15
    Asynchronous messaging with gRPC allows for request-reply communication and temporal decoupling of services, ensuring that workflows can continue even if some services are unavailable.
  • 🚫
    05:38
    gRPC may not be suitable for service-to-service communication when the request starts from a message pulled from a queue or broker, as failures can occur without impacting end users, and handling failures originating from end users is more challenging than those from asynchronous messages.
  • 👍
    07:16
    gRPC is a good choice for dealing with failures and fault tolerance in infrastructure interactions, such as with databases, and for view composition.
  • 📌
    08:18
    Avoid using gRPC for service to service communication involved in workflow and business processes; instead, use messaging for orchestration and event choreography to decouple services and enable temporary decoupling through message-based communication.
  • 📚
    09:36
    Using gRPC in a distributed monolith or a distributed service chain can be challenging due to added latency and the requirement for everything to be online.
Play video
This article is a summary of a YouTube video "Where should you use gRPC? And where NOT to use it!" by CodeOpinion
Report the article Report the article
Thanks for feedback Thank you for the feedback

We’ve got the additional info