{"id":26149454,"url":"https://github.com/gofarsi/forker","last_synced_at":"2025-12-15T03:12:38.446Z","repository":{"id":61627647,"uuid":"547076092","full_name":"GoFarsi/forker","owner":"GoFarsi","description":"Get high performance http requests with fork process","archived":false,"fork":false,"pushed_at":"2023-03-07T03:33:36.000Z","size":94,"stargazers_count":37,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T03:56:00.538Z","etag":null,"topics":["collaborate","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoFarsi.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}},"created_at":"2022-10-07T05:10:32.000Z","updated_at":"2025-02-20T09:13:09.000Z","dependencies_parsed_at":"2023-07-18T16:25:23.529Z","dependency_job_id":null,"html_url":"https://github.com/GoFarsi/forker","commit_stats":null,"previous_names":["ja7ad/forker"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/GoFarsi/forker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoFarsi%2Fforker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoFarsi%2Fforker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoFarsi%2Fforker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoFarsi%2Fforker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoFarsi","download_url":"https://codeload.github.com/GoFarsi/forker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoFarsi%2Fforker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278263065,"owners_count":25958046,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["collaborate","go","golang"],"created_at":"2025-03-11T05:32:03.914Z","updated_at":"2025-10-04T04:13:55.893Z","avatar_url":"https://github.com/GoFarsi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# forker\n[![Go Reference](https://pkg.go.dev/badge/github.com/Ja7ad/forker.svg)](https://pkg.go.dev/github.com/Ja7ad/forker)\n\nGet high performance http requests with fork process (forker inspired prefork feature in web servers)\n\nprefork is a solution which is also used by other webservers\n\nA server instance is opened for each processor core and incoming requests are shared between these instances\n\nIn order to distribute the load more evenly and handle more requests per second, there is a master that starts by the user, which then starts child processes on the other processor cores based on configuration\n\nmemory between the different processes is not shared, beacuse  goroutines are independent processes\n\n![alt text](assets/diagram.jpg \"diagram\")\n\n# how to install\n\n```shell\ngo get -u github.com/Ja7ad/forker\n```\n\n## forker benchmark\n\nforker tested 500 concurrent with 200k http requests\n\n![alt text](assets/forker.png \"forker\")\n\n```shell\noha -c 500 -n 200000 --latency-correction --disable-keepalive http://localhost:8080\n```\n\n```shell\nSummary:\n  Success rate:\t1.0000\n  Total:\t24.4907 secs\n  Slowest:\t0.5000 secs\n  Fastest:\t0.0004 secs\n  Average:\t0.0610 secs\n  Requests/sec:\t8166.3762\n\n  Total data:\t2.10 MiB\n  Size/request:\t11 B\n  Size/sec:\t87.72 KiB\n\nResponse time histogram:\n  0.000 [1]     |\n  0.050 [82408] |■■■■■■■■■■■■■■■■■■■■■■■■■■\n  0.100 [98705] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n  0.150 [16180] |■■■■■\n  0.200 [2245]  |\n  0.250 [361]   |\n  0.300 [59]    |\n  0.350 [33]    |\n  0.400 [3]     |\n  0.450 [1]     |\n  0.500 [4]     |\n\nLatency distribution:\n  10% in 0.0291 secs\n  25% in 0.0404 secs\n  50% in 0.0557 secs\n  75% in 0.0754 secs\n  90% in 0.0989 secs\n  95% in 0.1170 secs\n  99% in 0.1581 secs\n\nDetails (average, fastest, slowest):\n  DNS+dialup:\t0.0259 secs, 0.0001 secs, 0.3010 secs\n  DNS-lookup:\t0.0000 secs, 0.0000 secs, 0.0239 secs\n\n```\n\n## Example\n\n### http server\n\n```go\npackage main\n\nimport (\n\t\"github.com/Ja7ad/forker\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc main() {\n\tsrv := \u0026http.Server{\n\t\tHandler: GreetingHandler(),\n\t}\n\n\tf := forker.New(srv)\n\n\tlog.Fatalln(f.ListenAndServe(\":8080\"))\n\n}\n\nfunc GreetingHandler() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"greeting!!!\"))\n\t}\n}\n```\n\n### grpc server\n\n[benchmark](_example/grpc)\n\n```go\npackage main\n\nimport (\n\t\"github.com/Ja7ad/forker\"\n\t\"google.golang.org/grpc/health\"\n\t\"google.golang.org/grpc/health/grpc_health_v1\"\n\t\"google.golang.org/grpc/reflection\"\n\t\"log\"\n)\n\nfunc main() {\n\tf := forker.NewGrpcForker(nil)\n\tsrv := f.GetGrpcServer()\n\n\tgrpc_health_v1.RegisterHealthServer(srv, health.NewServer())\n\n\treflection.Register(srv)\n\n\tlog.Fatalln(f.ServeGrpc(\":9090\"))\n}\n\n```\n\n### echo framework\n\n[benchmark](_example/echo)\n\n```go\npackage main\n\nimport (\n\t\"github.com/Ja7ad/forker\"\n\t\"github.com/labstack/echo/v4\"\n)\n\nfunc main() {\n\tf := forker.NewEchoForker()\n\te := f.GetEcho()\n\n\te.GET(\"/\", Greeting)\n\n\te.Logger.Fatal(f.Start(\":8080\"))\n}\n\nfunc Greeting(c echo.Context) error {\n\treturn c.String(200, \"greeting\")\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgofarsi%2Fforker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgofarsi%2Fforker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgofarsi%2Fforker/lists"}