Skip to content

Conversation

@SAHU-01
Copy link
Contributor

@SAHU-01 SAHU-01 commented Sep 14, 2025

Closes #115

Summary
Implements configurable timeout for HTTP routing v1 client to prevent denial of service when routing responses take longer than the previously hardcoded 15 seconds.

Note: HTTP routing metrics were already implemented and working in the existing codebase this PR only adds the missing configurable timeout functionality.

Changes Made
✅ Configurable HTTP Client Timeout

  • Added RoutingV1HTTPClientTimeout config field
  • Added --routing-v1-http-timeout CLI flag (follows naming from feat!: independent dht and routing v1 flags #113)
  • Replaced missing HTTP client timeout (was infinite wait) with configurable value
  • Replaced hardcoded 15s ParallelRouter timeout with configurable value
  • Set default to 30s (safer than 15s for production, infra timeout ~1m)
  • Added environment variable support: RAINBOW_ROUTING_V1_HTTP_TIMEOUT

✅ Verified Existing Metrics Work

  • Confirmed existing httpclient.OpenCensusViews registration exposes metrics correctly
  • Verified routing_http_client_latency and related metrics appear at /debug/metrics/prometheus
  • Tested timeout configuration affects error metrics as expected

Testing

  • CLI flag and environment variable work correctly
  • HTTP client timeout prevents infinite waits
  • ParallelRouter timeout configurable (was hardcoded 15s)
  • Metrics show DeadlineExceeded errors with short timeouts
  • Default timeout increased from 15s to 30s

Reviewer: @lidel and @hsanjuan

@hsanjuan hsanjuan self-assigned this Sep 16, 2025
@hsanjuan hsanjuan self-requested a review September 16, 2025 14:23
@hsanjuan
Copy link
Contributor

Triage:

Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is setting a timeout for both the http.Client that makes requested to delegated routing endpoints, as well as the ParallelRouter.

Since we are introducing it, it's probably best to separate both timeout and have a RAINBOW_ROUTING_TIMEOUT next to RAINBOW_HTTP_ROUTERS_TIMEOUT.

@SAHU-01 SAHU-01 requested a review from hsanjuan September 29, 2025 06:37
@lidel
Copy link
Member

lidel commented Sep 30, 2025

Triage note:

  • @hsanjuan will review once he has free time

@hsanjuan hsanjuan merged commit d9b6690 into ipfs:main Oct 16, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/routing/v1 http client metrics and configuration

3 participants