Skip to content

Timeout pattern #2845

Open
Open

Description

@iluwatar

Description:
The Timeout design pattern is crucial in a microservices architecture to handle latency and prevent cascading failures. By setting a timeout, we can avoid long waits for responses from dependent services, improving overall system resilience and performance. This pattern helps in defining a period within which a service call must complete, otherwise, it gets aborted and a fallback mechanism is triggered. This implementation is particularly important for maintaining the robustness of the system under heavy load or when some services are down or slow to respond.

Main Elements of the Pattern:

  • Timeout Duration: Defines the maximum time a service call is allowed to take.
  • Fallback Mechanism: Provides a default response or alternative workflow if a service call times out.
  • Configuration: Ability to configure different timeouts for different services based on their response times.
  • Logging and Monitoring: Capture timeout events for monitoring and debugging purposes.
  • Circuit Breaker Integration: Work in conjunction with the Circuit Breaker pattern to prevent repeated calls to failing services.

References:

  1. Microservices Patterns
  2. Resilience4j - TimeLimiter
  3. Project Contribution Guidelines
  4. Timeout pattern

Acceptance Criteria:

  • Implement a configurable timeout for service calls.
  • Provide a fallback mechanism for timed-out calls.
  • Ensure the timeout duration can be configured per service.
  • Log timeout events for further analysis and monitoring.
  • Demonstrate the pattern with a practical example within the existing microservices.
  • Ensure the implementation follows the project's contribution guidelines and coding standards.

Activity

  1. converted this from a draft issue on Mar 24, 2024
  2. changed the title [-]Implement Timeout Design Pattern[/-] [+]Timeout pattern[/+] on Jun 1, 2024
  3. kanishkawithanawasam commented on Aug 1, 2024

    @kanishkawithanawasam

    Hello,

    I am a third-year undergraduate computer science student. I am new to this project and would like to contribute. I will be working on this issue.

  4. moved this from Todo to In Progress in Java Design Patterns projecton Aug 6, 2024
  5. stale commented on Oct 5, 2024

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. The issue will be unassigned if no further activity occurs. Thank you for your contributions.

  6. added
    status: staleissues and pull requests that have not had recent interaction
    on Oct 5, 2024
  7. removed
    status: staleissues and pull requests that have not had recent interaction
    on Oct 13, 2024
  8. 33 remaining items

  9. moved this from Todo to In Progress in Java Design Patterns projecton Jun 1, 2026
  10. added a commit that references this issue on Jun 7, 2026
    48e8b92
  11. github-actions commented on Aug 3, 2026

    @github-actions

    This issue is stale because it has been open 60 days with no activity.

  12. moved this from In Progress to Todo in Java Design Patterns projecton Aug 16, 2026
  13. ylcn91 commented on Sep 3, 2026

    @ylcn91
    Contributor

    Hi @iluwatar, I picked this one up. Per-service configurable timeouts with cancellation, timeout metrics and fallback, plus tests, README and class diagram are in #3598. Happy to adjust anything in review.

  14. moved this from Todo to In Progress in Java Design Patterns projecton Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions