{"id":20757908,"url":"https://github.com/amdmi3/nginx-bug-demo","last_synced_at":"2026-04-17T19:31:53.456Z","repository":{"id":139658182,"uuid":"152793984","full_name":"AMDmi3/nginx-bug-demo","owner":"AMDmi3","description":null,"archived":false,"fork":false,"pushed_at":"2018-10-13T01:32:44.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-11T16:24:23.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AMDmi3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-10-12T18:43:30.000Z","updated_at":"2018-10-13T01:32:46.000Z","dependencies_parsed_at":"2023-07-23T08:45:25.154Z","dependency_job_id":null,"html_url":"https://github.com/AMDmi3/nginx-bug-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AMDmi3/nginx-bug-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fnginx-bug-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fnginx-bug-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fnginx-bug-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fnginx-bug-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AMDmi3","download_url":"https://codeload.github.com/AMDmi3/nginx-bug-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fnginx-bug-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31943272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-17T09:46:20.876Z","updated_at":"2026-04-17T19:31:53.433Z","avatar_url":"https://github.com/AMDmi3.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nginx backend delay bug\n\nI've experienced strange behavior of nginx with slow uwsgi backend:\nif the backend replies in more than around 1.2 seconds, nginx introduces\nadditional delay, so total reply time raises up to around 2.2 seconds.\n\nA graph of nginx reply time vs. backend reply time demonstrates this\nin a more visual way:\n\n![graph](graph.svg)\n\n## Repository contents\n\nThis repository contains a setup which reliably reproduces the\nproblem for me. It consists of a simple HTTPish backed simulator\nwhich replies in 0.5 and 1.5 seconds interchangeably, an nginx\nconfig which uses the backend and a script which runs everything.\n\n## Expected behavior\n\nObviously, nginx should not add any additional delay over the backend,\nso since backend replies in 0.5 seconds and then in 1.5 seconds, nginx\nshould reply in around the same time.\n\n## Actual behavior\n\nIn practice, however, this happens:\n\n```\n===\u003e Compiling backend simulator\n===\u003e Running backend simulator\n===\u003e Running nginx\n===\u003e Waiting 1 sec for everybody to start\n===\u003e Trying request\n/!\\ First request: backend replies in 0.5 seconds\n        0,52 real         0,01 user         0,00 sys\n/!\\ Second request: backend replies in 1.5 seconds\n        2,23 real         0,00 user         0,00 sys\n/!\\ If you're seeing more than 2 seconds here, you're experiencing nginx problem\n===\u003e Shutting everything down\n```\n\nNote that the second response comes with 2.23 seconds instead of expected 1.52 or so.\n\n## ktrace dumps\n\nSee ktrace dumps [with bug](ktrace.11.2-bug.txt) [without bug](ktrace.12.x-ok.txt).\n\nThe relevant difference is how kevent behaves after nginx sends a reply back to client.\n\nWhen there's a bug, two events on client fd come come separately:\nWRITE with 100 msec delay (introducing its own latency) and then\nREAD with additional 630 msec.\n\nhttps://github.com/AMDmi3/nginx-bug-demo/blob/master/ktrace.11.2-bug.txt#L241-L249\n\nWhen there's no bug, both events come at the same time and immediately:\n\nNo bug: https://github.com/AMDmi3/nginx-bug-demo/blob/master/ktrace.12.x-ok.txt#L226-L227\n\n## Enviroment\n\n- OS\n  - :+1: FreeBSD 11.0-BETA1 amd54 (r302857) - does not reproduce\n  - :skull: FreeBSD 11.2-PRERELEASE amd64 (r334549)\n  - :skull: FreeBSD 11.2-RELEASE-p1 amd64\n  - :skull: FreeBSD 12.0-CURRENT amd64 (r316542)\n  - :skull: FreeBSD 12.0-CURRENT amd64 d71bcb11d(drm-next)\n  - :+1: FreeBSD 12.0-CURRENT amd64 (r333375) - does not reproduce\n  - :+1: FreeBSD 12.0-CURRENT amd64 ce438e4cdd8(master) - does not reproduce\n- nginx\n  - :skull: 1.14.0\n  - :skull: 1.15.4\n  - :skull: 1.15.5\n\n## Contacts\n\n- Dmitry Marakasov \u003camdmi3@amdmi3.ru\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdmi3%2Fnginx-bug-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famdmi3%2Fnginx-bug-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdmi3%2Fnginx-bug-demo/lists"}