{"id":49969967,"url":"https://github.com/khaledalam/api-stress-kit","last_synced_at":"2026-05-18T07:33:25.421Z","repository":{"id":323072824,"uuid":"1092032821","full_name":"khaledalam/api-stress-kit","owner":"khaledalam","description":"A minimal, production-ready starter to build, benchmark, and stress‑test REST APIs using Go, Gin, and popular load tools (Vegeta / k6).","archived":false,"fork":false,"pushed_at":"2025-11-07T22:19:26.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-08T00:16:34.142Z","etag":null,"topics":["api","api-rest","gin","go","golang","k6","stress-testing","vegeta"],"latest_commit_sha":null,"homepage":"","language":"Go","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/khaledalam.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-07T22:14:31.000Z","updated_at":"2025-11-07T22:19:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/khaledalam/api-stress-kit","commit_stats":null,"previous_names":["khaledalam/api-stress-kit"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/khaledalam/api-stress-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khaledalam%2Fapi-stress-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khaledalam%2Fapi-stress-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khaledalam%2Fapi-stress-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khaledalam%2Fapi-stress-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khaledalam","download_url":"https://codeload.github.com/khaledalam/api-stress-kit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khaledalam%2Fapi-stress-kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33169265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T05:43:36.989Z","status":"ssl_error","status_checked_at":"2026-05-18T05:43:19.133Z","response_time":71,"last_error":"SSL_read: 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":["api","api-rest","gin","go","golang","k6","stress-testing","vegeta"],"created_at":"2026-05-18T07:33:24.659Z","updated_at":"2026-05-18T07:33:25.412Z","avatar_url":"https://github.com/khaledalam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 api-stress-kit\n\n**api-stress-kit** is a minimal, production-ready starter to **build**, **benchmark**, and **stress-test** REST APIs using **Go**, **Gin**, and popular load-testing tools — **Vegeta** and **k6**.\n\n---\n\n## ✨ Features\n- ⚡ Fast HTTP API built with **Gin**\n- 🧪 Stress testing using **Vegeta** \u0026 **k6**\n- 🐳 Dockerfile + Compose for reproducible environments\n- ✅ Basic unit test for `/ping`\n- 🧩 Ready for profiling with `pprof`\n\n---\n\n## ⚙️ Quick Start\n\n### Run Locally\n```bash\ngo mod tidy\ngo run main.go\n```\n\n### Install Load Testing Tools\n```bash\n# Vegeta\ngo install github.com/tsenart/vegeta/v12@latest\n# or using Homebrew\nbrew install vegeta\n\n# k6\nbrew install k6\n```\n\n---\n\n## 🔥 Stress Testing Examples\n\n### Vegeta\n```bash\necho \"GET http://localhost:8080/ping\" | vegeta attack -duration=15s -rate=200 | vegeta report\n```\n\n### k6\n```bash\nk6 run tests/stress/k6_test.js\n```\n\n---\n\n## 🐳 Run with Docker\n```bash\ndocker-compose up --build\n# Server available at: http://localhost:8080\n```\n\n---\n\n## 🧠 Endpoints\n| Method | Path | Description | Example Response |\n|--------|------|--------------|------------------|\n| `GET` | `/ping` | Health check with latency info | `{ \"message\": \"pong\", \"latency_ms\": \u003cint\u003e }` |\n| `GET` | `/health` | Simple status check | `{ \"status\": \"ok\" }` |\n| `GET` | `/users` | List of demo users | `[{\"id\":1,\"name\":\"Alice\"},{\"id\":2,\"name\":\"Bob\"}]` |\n\n---\n\n## 📊 Output\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e▶️ Click to expand full test results (k6 + Vegeta)\u003c/b\u003e\u003c/summary\u003e\n\n### 🧪 k6 Test Output\n```bash\n% k6 run tests/stress/k6_test.js\n\n         /\\      Grafana   /‾‾/  \n    /\\  /  \\     |\\  __   /  /   \n   /  \\/    \\    | |/ /  /   ‾‾\\ \n  /          \\   |   (  |  (‾)  |\n / __________ \\  |_|\\_\\  \\_____/ \n\n     execution: local\n        script: tests/stress/k6_test.js\n        output: -\n\n     scenarios: (100.00%) 1 scenario, 20 max VUs, 50s max duration (incl. graceful stop):\n              * default: 20 looping VUs for 20s (gracefulStop: 30s)\n\n\n  █ TOTAL RESULTS \n\n    checks_total.......: 800     39.43/s\n    checks_succeeded...: 100.00% 800 out of 800\n    checks_failed......: 0.00%   0 out of 800\n\n    ✓ status was 200\n\n    HTTP\n    http_req_duration..............: avg=5.71ms   min=710µs    med=5.67ms   max=15.08ms  \n      { expected_response:true }...: avg=5.71ms   min=710µs    med=5.67ms   max=15.08ms  \n    http_req_failed................: 0.00%  0 out of 800\n    http_reqs......................: 800    39.43/s\n\n    EXECUTION\n    iteration_duration.............: avg=507.21ms min=500.91ms med=507.06ms max=519.43ms\n    iterations.....................: 800    39.43/s\n    vus............................: 20     min=20       max=20\n    vus_max........................: 20     min=20       max=20\n\n    NETWORK\n    data_received..................: 125 kB 6.2 kB/s\n    data_sent......................: 59 kB  2.9 kB/s\n\nrunning (20.3s), 00/20 VUs, 800 complete and 0 interrupted iterations\ndefault ✓ [======================================] 20 VUs  20s\n```\n\n---\n\n### ⚡ Vegeta Test Output\n```bash\n% echo \"GET http://localhost:8080/users\" | vegeta attack -duration=15s -rate=200 | vegeta report\n\nRequests      [total, rate, throughput]         3000, 200.07, 200.05\nDuration      [total, attack, wait]             14.996s, 14.995s, 1.339ms\nLatencies     [min, mean, 50, 90, 95, 99, max]  428.25µs, 1.749ms, 1.252ms, 3.208ms, 4.227ms, 8.217ms, 33.845ms\nBytes In      [total, mean]                     141000, 47.00\nBytes Out     [total, mean]                     0, 0.00\nSuccess       [ratio]                           100.00%\nStatus Codes  [code:count]                      200:3000  \nError Set:\n```\n\u003c/details\u003e\n\n---\n\n## ⚙️ Performance Comparison\n\nCommand used:\n```bash\necho \"GET http://localhost:8080/users\" | vegeta attack -duration=10s -rate=2000 | vegeta report\n```\n\n---\n\n### 🖥️ Native Execution (Direct Go Run)\n```bash\ngo run main.go\n```\n\n#### 🕒 Idle (0 Requests)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/os-0.png\" width=\"70%\" alt=\"Native - Idle CPU Graph\" /\u003e\n\u003c/p\u003e\n\n#### 🚀 Load Test (10s @ 2000 RPS)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/os-cpu.png\" width=\"70%\" alt=\"Native - CPU Load\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"docs/os-stress.png\" width=\"70%\" alt=\"Native - Stress Graph\" /\u003e\n\u003c/p\u003e\n\n---\n\n### 🐳 Inside Docker (Containerized Execution)\n```bash\ndocker-compose up --build\n```\n\n#### 🕒 Idle (0 Requests)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/docker-0.png\" width=\"70%\" alt=\"Docker - Idle CPU Graph\" /\u003e\n\u003c/p\u003e\n\n#### 🚀 Load Test (10s @ 2000 RPS)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/docker-cpu.png\" width=\"70%\" alt=\"Docker - CPU Load\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"docs/docker-stress.png\" width=\"70%\" alt=\"Docker - Stress Graph\" /\u003e\n\u003c/p\u003e\n\n---\n\n### 📊 Summary\n| Environment | Command | Overhead Observed | Network Mode |\n|--------------|----------|-------------------|---------------|\n| 🖥️ Native | `go run main.go` | Minimal CPU overhead | Direct host |\n| 🐳 Docker | `docker-compose up --build` | Slightly higher baseline CPU (due to VM bridge) | Docker bridge |\n\n\u003e 🧠 *Observation:* Running under Docker introduces an extra CPU overhead layer caused by virtualization, filesystem overlay, and bridged networking — especially visible during high RPS bursts.\n\n---\n\n## 🧾 License\n**MIT License**\n\n---\n\n## 👤 Maintainer\n**Khaled Alam**  \nFull-Stack Software Engineer \n\n🌐 [Portfolio](https://khaledalam.net)  \n✉️ [khaledalam.net@gmail.com](mailto:khaledalam.net@gmail.com)  \n💼 [LinkedIn](https://linkedin.com/in/khaledalam)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledalam%2Fapi-stress-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhaledalam%2Fapi-stress-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledalam%2Fapi-stress-kit/lists"}