DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Design Patterns for GenAI Creative Systems in Advertising
  • From APIs to Actions: Rethinking Back-End Design for Agents
  • Why SAP S/4HANA Landscape Design Impacts Cloud TCO More Than Compute Costs
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives

Trending

  • Building a High-Throughput Distributed Sequence Generator Using the Hi-Lo Algorithm
  • MuleSoft IDP: Enhancing Efficiency and Accuracy in Data Extraction
  • LLM-Powered Deep Parsing for Industrial Inventory Search
  • Building a Zero-Cost Approval Workflow With AWS Lambda Durable Functions

Retry Design Pattern With Istio

We take a look at this design pattern, how it can be implement into microservices using Istio, and the benefits of the Retry Pattern.

By 
Samir Behara user avatar
Samir Behara
·
Jun. 14, 19 · Analysis
Likes (4)
Comment
Save
Tweet
Share
16.3K Views

Join the DZone community and get the full member experience.

Join For Free

In a dynamic cloud environment, there can be scenarios when there are intermittent network connectivity errors causing your service to be unavailable. These issues are generally self-correcting and if you retry the operation after a small delay its most probably going to succeed. You need to design your microservice architecture to handle such transient errors gracefully.

Retry Design Pattern

The Retry Design Pattern states that you can retry a connection automatically which has failed earlier due to an exception. This is very handy in case of temporary or one-off issues with your services. A lot of times a simple retry might fix the issue. The load balancer might point you to a different healthy server on the retry, and your call might be successful.

You might have bumped into scenarios where your application is not able to connect with the database. However, if the application retries after a short delay it might successfully establish the database connection. Having a Retry Pattern can stabilize your applications from these intermittent network issues. This also reduces the burden on the application for handling failures in case of such transient errors.

Istio Retry Policy

You can specify the number of retry attempts for an HTTP request in a virtual service. You can mention the interval between retries — the service might be busy and processing the request after a delay sometimes does the trick. If the request is unsuccessful after the retry attempts, the service should treat it as an error and handle it accordingly.

Here's some YAML for a sample VirtualService: 

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: serviceB
spec:
  hosts:
  - serviceB
  http:
  - route:
    - destination:
        host: serviceB
    retries:
      attempts: 3
      perTryTimeout: 2s

The Retry Policy should be carefully implemented such that you are not negatively impacting the service. For example, you should not retry a large number of times nor try to retry with a small delay. You should set the Retry Policy such that you are confident in identifying any transient errors and then report the failure as soon as possible. If operations are not idempotent, the retry logic might introduce additional complexity.

Conclusion

Handling transient failures is required in a microservice architecture. The network is not unreliable and sometimes retrying the failed operation saves the day. Istio provides a transparent approach for handling application retires in case of such intermittent network errors.

Read more about Retry Pattern here.

Design

Published at DZone with permission of Samir Behara. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Design Patterns for GenAI Creative Systems in Advertising
  • From APIs to Actions: Rethinking Back-End Design for Agents
  • Why SAP S/4HANA Landscape Design Impacts Cloud TCO More Than Compute Costs
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook