{"id":13478163,"url":"https://github.com/lsk569937453/silverwind","last_synced_at":"2025-04-06T09:09:48.030Z","repository":{"id":143531801,"uuid":"615301409","full_name":"lsk569937453/silverwind","owner":"lsk569937453","description":"The High Performance Proxy/Load Balancer","archived":false,"fork":false,"pushed_at":"2023-09-09T22:30:26.000Z","size":1029,"stargazers_count":381,"open_issues_count":4,"forks_count":19,"subscribers_count":5,"default_branch":"main","last_synced_at":"2023-12-16T14:41:42.201Z","etag":null,"topics":["api-gateway","api-management","cloud-native","gateway","load-balancer","reverse-proxy","rust-lang"],"latest_commit_sha":null,"homepage":"https://github.com/lsk569937453/silverwind/wiki","language":"Rust","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/lsk569937453.png","metadata":{"files":{"readme":"README-zh_CN.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}},"created_at":"2023-03-17T11:47:26.000Z","updated_at":"2024-03-04T02:20:08.422Z","dependencies_parsed_at":"2023-12-10T15:08:27.021Z","dependency_job_id":"23b70936-c16a-40ac-a14b-92b6f1200391","html_url":"https://github.com/lsk569937453/silverwind","commit_stats":{"total_commits":161,"total_committers":3,"mean_commits":"53.666666666666664","dds":0.1366459627329193,"last_synced_commit":"a2ad97bf31937545732af65f5646ad55ee9fdd0f"},"previous_names":[],"tags_count":19,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsk569937453%2Fsilverwind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsk569937453%2Fsilverwind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsk569937453%2Fsilverwind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsk569937453%2Fsilverwind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsk569937453","download_url":"https://codeload.github.com/lsk569937453/silverwind/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457803,"owners_count":20941906,"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":["api-gateway","api-management","cloud-native","gateway","load-balancer","reverse-proxy","rust-lang"],"created_at":"2024-07-31T16:01:53.307Z","updated_at":"2025-04-06T09:09:47.997Z","avatar_url":"https://github.com/lsk569937453.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Silverwind-下一代高性能云原生反向代理/负载均衡调度器\r\nSilverwind 是一个高性能的反向代理/负载均衡调度器。它同时也可以在K8S集群中用作入口控制器。\r\n## Sivlverwind-Dashboard\r\n### docker-compose 启动\r\n通过如下命令来启动Sivlverwind的Dashboard  \r\ndocker-compose.yaml的文件如下所示\r\n```\r\nversion: \"3.9\"\r\nservices:\r\n  silverwind-dashboard:\r\n    image: lsk569937453/silverwind-dashboard:0.0.7\r\n    container_name: silverwind-dashboard\r\n    ports:\r\n      - \"4486:4486\"\r\n\r\n  silverwind:\r\n      image: lsk569937453/silverwind:0.0.7\r\n      container_name: silverwind\r\n      ports:\r\n        - \"6980:6980\"\r\n      environment:\r\n        ADMIN_PORT: 6980\r\n```\r\n您执行**docker-compose up** 命令后，可以在浏览器中打开[主页](http://localhost:4486/index.html)来查看Silverwind的仪表盘。\r\n## 为什么我们选择 Silverwind\u0026\u0026Silverwind的优点\r\n### 基准测试\r\n我们针对当前主流的代理/负载均衡器(NGINX, Envoy, and Caddy)做了性能测试。测试结果在[这里](https://github.com/lsk569937453/silverwind/blob/main/benchmarks-zh_CN.md)。\r\n测试结果表明在相同的机器配置下(4核8G),在某些指标上(每秒请求数,平均响应时间),Silverwind的数据与NGINX, Envoy水平接近。\r\n在请求延迟上，Silverwind的数据要明显好于NGINX和Envoy。\r\n\r\n### 所有的基础功能全都是原生语言开发-速度快\r\nSilverwind不止是一个反向代理/负载均衡器，而且是一个API网关。作为一个API网关，Silverwind将会涵盖所有的基础功能(黑白名单/授权/熔断限流/灰度发布\r\n,蓝绿发布/监控/缓存/协议转换)。\r\n\r\n与其他的网关相比，Silverwind的优点是涵盖API网关所有的基础服务，并且性能高。其次，Silverwind的动态配置接近实时。每次修改完配置，会在5秒内生效(接近实时)。\r\n\r\n### Kong\r\nKong的免费限流插件[不准确]( https://github.com/Kong/kong/issues/5311)。如果想要实现更准确的限流，我们不得不买企业版的Kong。\r\n\r\n\r\n### Envoy\r\nEnvoy没有内嵌限流功能。Envoy提供了限流接口让用户自己实现。目前github上使用最多的是这个[项目](https://github.com/envoyproxy/ratelimit)。\r\n第一个缺点是该项目只支持固定窗口限流。固定窗口限流算法的坏处是不支持突发流量。  \r\n第二个缺点是每次请求Envoy都会通过使用grpc去请求限流集群。相比内嵌的限流算法，这其实额外的增加了一次网络跃点。 \r\n\r\n## 动态配置\r\n您可以通过Rest API更改配置。并且新配置将在**5 秒内**生效。\r\n## 编译 \r\n\r\n### 安装Openssl\r\n#### Mac \u0026 Linux\r\nhttps://docs.rs/openssl/latest/openssl/\r\n\r\n#### Windows\r\n通过vcpkg安装openssl。\r\n```\r\n\u003e git clone https://github.com/microsoft/vcpkg\r\n\u003e .\\vcpkg\\bootstrap-vcpkg.bat\r\n\u003e .\\vcpkg.exe install openssl\r\n``` \r\n从https://strawberryperl.com/ \r\n下载安装strawberryperl.\r\n### 开始编译\r\n请先安装rust，然后执行下面的命令。\r\n```\r\ncd rust-proxy\r\ncargo build --release\r\n```\r\n你可以在target/release目录下找到Silverwind.\r\n## 下载发行版\r\n从[这里](https://github.com/lsk569937453/silverwind/releases)下载发行版.\r\n## 配置文件介绍\r\n### 配置Silverwind作为http代理\r\n```\r\n- listen_port: 9969\r\n  service_config:\r\n    server_type: HTTP\r\n    routes:\r\n    - matcher:\r\n        prefix: /\r\n        prefix_rewrite: ssss\r\n      route_cluster:\r\n        type: RandomRoute\r\n        routes:\r\n        - base_route:\r\n            endpoint: http://localhost:8888/\r\n            try_file: null\r\n        - base_route:\r\n            endpoint: http://localhost:9999/\r\n            try_file: null\r\n        - base_route:\r\n            endpoint: http://localhost:7777/\r\n            try_file: null\r\n```\r\nSilverwind将会监听9969端口然后转发流量到 http://localhost:8888/,http://localhost:9999/.http://localhost:7777/ 。\r\n### Silverwind as the tcp proxy\r\n```\r\n- listen_port: 4486\r\n  service_config:\r\n    server_type: TCP\r\n    routes:\r\n    - matcher:\r\n        prefix: \"/\"\r\n        prefix_rewrite: ssss\r\n      route_cluster:\r\n        type: RandomRoute\r\n        routes:\r\n        - base_route:\r\n            endpoint: httpbin.org:443\r\n            try_file: null\r\n```\r\nSilverwind将会监听4486端口然后转发流量到 httpbin.org:443。\r\n### 启动:\r\n#### Windows下启动\r\n```\r\n$env:CONFIG_FILE_PATH='D:\\code\\app_config.yaml'; .\\rust-proxy.exe\r\n```\r\n或者也可以无配置文件启动。\r\n```\r\n.\\rust-proxy.exe\r\n```\r\n## Rest Api\r\n### 修改配置\r\n```\r\nPOST /appConfig HTTP/1.1\r\nHost: 127.0.0.1:8870\r\nContent-Type: application/json\r\nContent-Length: 1752\r\n\r\n[\r\n    {\r\n        \"listen_port\": 4486,\r\n        \"service_config\": {\r\n            \"server_type\": \"HTTP\",\r\n            \"cert_str\": null,\r\n            \"key_str\": null,\r\n            \"routes\": [\r\n                {\r\n                    \"matcher\": {\r\n                        \"prefix\": \"ss\",\r\n                        \"prefix_rewrite\": \"ssss\"\r\n                    },\r\n                    \"allow_deny_list\": null,\r\n                    \"route_cluster\": {\r\n                        \"type\": \"WeightBasedRoute\",\r\n                        \"routes\": [\r\n                            {\r\n                                \"base_route\": {\r\n                                    \"endpoint\": \"http://localhost:10000\",\r\n                                    \"try_file\": null\r\n                                }\r\n                            }\r\n                        ]\r\n                    }\r\n                },\r\n                {\r\n                    \"matcher\": {\r\n                        \"prefix\": \"sst\",\r\n                        \"prefix_rewrite\": \"ssss\"\r\n                    },\r\n                    \"allow_deny_list\": null,\r\n                    \"route_cluster\": {\r\n                        \"type\": \"WeightBasedRoute\",\r\n                        \"routes\": [\r\n                            {\r\n                                \"base_route\": {\r\n                                    \"endpoint\": \"http://localhost:9898\",\r\n                                    \"try_file\": null\r\n                                }\r\n                            }\r\n                        ]\r\n                    }\r\n                }\r\n            ]\r\n        }\r\n    }\r\n]\r\n```\r\n### 获取配置\r\n```\r\nGET /appConfig HTTP/1.1\r\nHost: 127.0.0.1:8870\r\n```\r\n### 更新路由\r\n```\r\nPUT /route HTTP/1.1\r\nHost: 127.0.0.1:8870\r\nContent-Type: application/json\r\nContent-Length: 629\r\n\r\n{\r\n    \"route_id\": \"90c66439-5c87-4902-aebb-1c2c9443c154\",\r\n    \"host_name\": null,\r\n    \"matcher\": {\r\n        \"prefix\": \"/\",\r\n        \"prefix_rewrite\": \"ssss\"\r\n    },\r\n    \"allow_deny_list\": null,\r\n    \"authentication\": null,\r\n    \"anomaly_detection\": null,\r\n    \"liveness_config\": null,\r\n    \"health_check\": null,\r\n    \"ratelimit\": null,\r\n    \"route_cluster\": {\r\n        \"type\": \"RandomRoute\",\r\n        \"routes\": [\r\n            {\r\n                \"base_route\": {\r\n                    \"endpoint\": \"http://127.0.0.1:10000\",\r\n                    \"try_file\": null,\r\n                    \"is_alive\": null\r\n                }\r\n            }\r\n        ]\r\n    }\r\n}\r\n```\r\n### 删除路由\r\n```\r\nDELETE /route/90c66439-5c87-4902-aebb-1c2c9443c154 HTTP/1.1\r\nHost: 127.0.0.1:8870\r\n```\r\n## \u003cspan id=\"api-gateway\"\u003eAPI网关中的基础功能\u003c/span\u003e\r\n![alt tag](https://raw.githubusercontent.com/lsk569937453/image_repo/main/api-gateway.png)\r\n## Silverwind已经实现了如下功能\r\n* IP 黑白名单\r\n* 授权(Basic Auth,ApiKey Auth)\r\n* 限流(Token Bucket,Fixed Window)\r\n* 路由\r\n* 负载均衡(论询，随机，基于权重,基于Header)\r\n* 动态配置(Rest Api)\r\n* 健康检查\u0026异常检测\r\n* 免费Https证书\r\n* 控制面板\r\n* 监控(Prometheus)\r\n## 将来会实现的功能\r\n- [ ] 协议转换\r\n- [ ] 缓存\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsk569937453%2Fsilverwind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsk569937453%2Fsilverwind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsk569937453%2Fsilverwind/lists"}