{"id":18446581,"url":"https://github.com/cristalhq/hedgedhttp","last_synced_at":"2025-05-16T08:05:16.337Z","repository":{"id":44504298,"uuid":"349731241","full_name":"cristalhq/hedgedhttp","owner":"cristalhq","description":"Hedged HTTP client which helps to reduce tail latency at scale.","archived":false,"fork":false,"pushed_at":"2024-08-13T16:33:37.000Z","size":52,"stargazers_count":122,"open_issues_count":3,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-08T19:22:42.610Z","etag":null,"topics":["go","golang","http","http-client","latency","scale","timeout"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cristalhq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-20T13:22:42.000Z","updated_at":"2025-03-23T12:09:31.000Z","dependencies_parsed_at":"2023-11-29T10:49:16.723Z","dependency_job_id":"7dda3574-dd69-4421-9660-324ec0a76e04","html_url":"https://github.com/cristalhq/hedgedhttp","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fhedgedhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fhedgedhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fhedgedhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fhedgedhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristalhq","download_url":"https://codeload.github.com/cristalhq/hedgedhttp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","http","http-client","latency","scale","timeout"],"created_at":"2024-11-06T07:09:43.815Z","updated_at":"2025-05-16T08:05:11.328Z","avatar_url":"https://github.com/cristalhq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hedgedhttp\n\n[![build-img]][build-url]\n[![pkg-img]][pkg-url]\n[![reportcard-img]][reportcard-url]\n[![coverage-img]][coverage-url]\n[![version-img]][version-url]\n\nHedged HTTP client which helps to reduce tail latency at scale.\n\n## Rationale\n\nSee paper [Tail at Scale](https://www.barroso.org/publications/TheTailAtScale.pdf) by Jeffrey Dean, Luiz André Barroso. In short: the client first sends one request, but then sends an additional request after a timeout if the previous hasn't returned an answer in the expected time. The client cancels remaining requests once the first result is received.\n\n## Acknowledge\n\nThanks to [Bohdan Storozhuk](https://github.com/storozhukbm) for the review and powerful hints.\n\n## Features\n\n* Simple API.\n* Easy to integrate.\n* Optimized for speed.\n* Clean and tested code.\n* Supports `http.Client` and `http.RoundTripper`.\n* Dependency-free.\n\n## Install\n\nGo version 1.16+\n\n```\ngo get github.com/cristalhq/hedgedhttp\n```\n\n## Example\n\n```go\nctx := context.Background()\nreq, err := http.NewRequestWithContext(ctx, http.MethodGet, \"https://google.com\", http.NoBody)\nif err != nil {\n\tpanic(err)\n}\n\ntimeout := 10 * time.Millisecond\nupto := 7\nclient := \u0026http.Client{Timeout: time.Second}\nhedged, err := hedgedhttp.NewClient(timeout, upto, client)\nif err != nil {\n\tpanic(err)\n}\n\n// will take `upto` requests, with a `timeout` delay between them\nresp, err := hedged.Do(req)\nif err != nil {\n\tpanic(err)\n}\ndefer resp.Body.Close()\n```\n\nAlso see examples: [examples_test.go](https://github.com/cristalhq/hedgedhttp/blob/main/examples_test.go).\n\n## Documentation\n\nSee [these docs][pkg-url].\n\n## License\n\n[MIT License](LICENSE).\n\n[build-img]: https://github.com/cristalhq/hedgedhttp/workflows/build/badge.svg\n[build-url]: https://github.com/cristalhq/hedgedhttp/actions\n[pkg-img]: https://pkg.go.dev/badge/cristalhq/hedgedhttp\n[pkg-url]: https://pkg.go.dev/github.com/cristalhq/hedgedhttp\n[reportcard-img]: https://goreportcard.com/badge/cristalhq/hedgedhttp\n[reportcard-url]: https://goreportcard.com/report/cristalhq/hedgedhttp\n[coverage-img]: https://codecov.io/gh/cristalhq/hedgedhttp/branch/main/graph/badge.svg\n[coverage-url]: https://codecov.io/gh/cristalhq/hedgedhttp\n[version-img]: https://img.shields.io/github/v/release/cristalhq/hedgedhttp\n[version-url]: https://github.com/cristalhq/hedgedhttp/releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristalhq%2Fhedgedhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristalhq%2Fhedgedhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristalhq%2Fhedgedhttp/lists"}