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

  • Patterns To Make Synchronous Communication in Microservices Resilient
  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • Why Queues Don’t Fix Scaling Problems
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms

Trending

  • Building AI-Powered Java Applications With Jakarta EE and LangChain4j
  • Building Threat Intelligence Pipelines Using Python, APIs, and Elasticsearch
  • 5 AI Security Incidents That Broke Things in Production (and What They Have in Common)
  • GenAI Implementation Isn't Magic — It’s a Lifecycle
  1. DZone
  2. Data Engineering
  3. Data
  4. Handling Service Timeouts Using Istio

Handling Service Timeouts Using Istio

The best practice for service timeouts is to prevent them, or at least make them as short as possible.

By 
Samir Behara user avatar
Samir Behara
·
Jun. 06, 19 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
9.5K Views

Join the DZone community and get the full member experience.

Join For Free

The Timeout Design Pattern states that you should not wait for a service response for an indefinite amount of time — you should rather throw an exception instead of waiting for too long. This will ensure that you are not stuck in a limbo state while continuing to consume application resources.

In my earlier blog post, I discussed the fallacies of Distributed Computing and how service calls made over the network are not reliable and might fail.

Service calls made over the network might fail. There can be congestion in the network or a power failure impacting your systems. The request might reach the destination service but it might fail to send the response back to the primary service. The data might get corrupted or lost during transmission over the wire. While architecting distributed cloud applications, you should assume that these types of network failures will happen and design your applications for resiliency. Implementing a timeout strategy ensures that your microservices are resilient and available.

When you encounter latency with your service communication and you are not sure what the root cause is, it is a preferred approach to not just wait for the response. Implementing a timeout strategy between your service-to-service communication over the network is critical. Istio makes it pretty simple to implement this functionality within your service mesh.

Setting Request Timeouts

In Istio you can set a request timeout either by using the route rules explained below or on a per-request basis by adding a header entry in outbound requests. You can mention the timeout in milliseconds on the header.

By default, the timeout for HTTP requests is disabled, but it can be overridden by using a routing rule as below.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: serviceB
spec:
  hosts:
  - serviceB
  http:
  - route:
    - destination:
        host: serviceB
    timeout: 10s


To test the timeout functionality you can inject a delay of say 10 seconds between your services. You can verify that when you invoke the service endpoint there is a delay of 10 seconds to get a response.

The next step is to configure the timeout rule to introduce a timeout period of, say, three seconds. Now you will see that the service call timeouts after three seconds and does not wait 10 seconds to get a response back.

If you want to quickly try out this capability without having to download the required tooling and installations, I would highly recommend you to try out the interactive platform right from your browser using Katacoda.


Timeout (computing) microservice

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

Opinions expressed by DZone contributors are their own.

Related

  • Patterns To Make Synchronous Communication in Microservices Resilient
  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • Why Queues Don’t Fix Scaling Problems
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms

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