{"id":22283750,"url":"https://github.com/veaba/rustic","last_synced_at":"2025-03-25T19:51:27.205Z","repository":{"id":104582210,"uuid":"269253973","full_name":"veaba/rustic","owner":"veaba","description":"A  http proxy server for rust, likeness nginx. (Just a demo)","archived":false,"fork":false,"pushed_at":"2020-06-28T10:14:59.000Z","size":60,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T17:39:38.350Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/veaba.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":"2020-06-04T03:43:55.000Z","updated_at":"2022-09-20T07:38:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"534405a0-2de4-4d88-b819-4cab83ff643d","html_url":"https://github.com/veaba/rustic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Frustic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Frustic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Frustic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Frustic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veaba","download_url":"https://codeload.github.com/veaba/rustic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245535427,"owners_count":20631293,"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":[],"created_at":"2024-12-03T16:42:00.321Z","updated_at":"2025-03-25T19:51:27.172Z","avatar_url":"https://github.com/veaba.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rustic\n\n受Nginx、与BFE 启发，基于测试web服务支持并发的比较结果，想开发一款基于rust 编程语言的HTTP 服务器代理器，用来测试rust 在web方向的极限\n\n比较常见的编程语言和web服务器，rust 的hyper表现的太过卓越！go 已有了BFE。\n\nrust 可以build 为一个可执行文件，这就很方便了。如果嵌入一个内置的rust web server 理论上就可以实现一个类 nginx 的web服务\n\n开发期间，不会考虑内存等性能问题。\n\n自我怀疑，使用`nginx` 作为比较是不是走弯路了？？\n\n## 疑问\n\n- 如何实现类似`nginx worker` 呢？ 支持更多的worker，并发拉满？\n- 集群模式下，如何与其他机子绑定？\n- `panic!` ?\n- 到底是构建一个`rust`语言体系的配置文件好还是拖个`nginx.conf` 过来也可以用呢？(2020年6月24日14:38:48)\n  - 前期的工作其实是为了实现`rustic` 而非`nginx`\n  - 后期再增加平滑过渡的读取`nginx.config` 功能，并实现`nginx`功能\n\n\n## 方案设计\n\n要求\n\n|feature| 描述 |\n|-------| --- |\n|`hot-load`|热加载|\n|`Cache`|缓存|\n|`keep-alive`||\n|`proxy`||\n|`gzip`||\n|`log`||\n|`protocol`||\n|`plugins`||\n|`load banlans`|[百度BFE](https://www.bfe-networks.net/zh_cn/)|\n|||\n\n- TODO 支持调整logs目录和文件\n- TODO 支持调整默认服务错误页目录和文件\n- TODO 网络七层网络\n- TODO config worker_processes \n- TODO keepalive_timeout \n- TODO rewrite server_name\n- TODO 原生支持`nginx.conf` 配置文件，放在后期（现在缺少必要的`conf`文件解析器）\n\n### 协议支持\n- http\n- https\n- spdy\n- http/2\n- websocket\n- tls\n- gRpc\n- http/3\n\n### 配置文件\n\n- 热重载配置文件\n- 配置文件，config.yaml\n\n```yaml\nroot: \"绝对路径\"\nload-balance: \"\"\nhttp: http\nhttp2: http2\nrewrite: /world/anywhere/\nproxy:\n  /aa/: /bb/\n  /cc/: /dd/\nlog:\n  path: /usr/xx.log\n```\n\n## 对比测试结果\n\n* 测试的方法不当可能影响会结果，以下为个人的测试结果，仅供参考，测试代码用例见 `/benchmark`：\n* 基于`autocannon` 测试\n \n\n### 排名总览\n\n- 期待未来补充 java、php\n\n|rank|language|web 服务| Req/Sec 每秒平均请求(avg) | 5s总请求数据(total in 5s)|\n|----|----|-------|---------------------|------------|\n|1|go      | iris                | 68784| 344k requests in 5.63   | \n|2|Rust    | hyper               | 67644| 338k requests in 5.4s  | \n|3|Rust    | nickel              | 44892| 224k requests in 5.17s  | \n|4|node(js)| fastify(fast mode)  | 42441| 212k requests in 5.1s  | \n|5|node(js)| fastify(normal)     | 40995| 205k requests in 5.11s  | \n|6|node(js)| express             | 22103| 125k requests in 5.08s | \n|7|deno(ts)| oak                 | 20481| 102k requests in 5.09s | \n|8|nginx(c)|                     | 11098| 55k requests in 5.05s  |\n|9|python  | aiohttp             | 5015 | 25k requests in 5.07s  | \n\n\n## API\n\nrustic config=xxx.toml 文件\n- 默认同目录下的 config.toml 或者yaml、json文件\n\n- `config` config.toml\n- `port` 80\n- `test` 测试配置文件\n- [x] `?`\n- [x] `help`\n- `key`\n- `cert`\n- [x] `version`\n- [x] `v`\n- [x] `ver`\n- [x] `author`  \n- start \n- restart\n- stop\n- exit\n\n### default mode\n\n```shell\ncargo run\n# or : rustic\n```\n\n- 此模式下等同于：rustic config=config.toml \n  - 起 80 端口\n  - 执行文件所在目录的查找config.toml\n  - 如果没有config.toml 则调用内置config\n```toml\n\n[root]\nroot=\"./html\" # 执行文件的当前目录下./html，生成默认的`index.html`、`400.html`、`500.html`\n\n[http]\nport=\"80\"\n```\n\n### config 自定义配置文件\n\n\u003e rustic config=config.toml\n\n调用用户自定义的`config.toml` 文件\n\n### port 自定义端口\n\n- 默认：80\n\n\u003e rustic port=80\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveaba%2Frustic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveaba%2Frustic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveaba%2Frustic/lists"}