{"id":35190186,"url":"https://github.com/chainbuff/grpc-benchmark-ts","last_synced_at":"2025-12-29T05:37:57.713Z","repository":{"id":270704294,"uuid":"911195949","full_name":"ChainBuff/grpc-benchmark-ts","owner":"ChainBuff","description":"A simple tool for measuring gRPC latency. 一个测量gRPC延迟的工具。新增对比多个 GRPC 服务的性能。","archived":false,"fork":false,"pushed_at":"2025-02-26T05:45:45.000Z","size":40,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T06:27:59.746Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChainBuff.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-02T13:08:14.000Z","updated_at":"2025-02-26T05:48:21.000Z","dependencies_parsed_at":"2025-02-26T06:23:52.391Z","dependency_job_id":"90dd452e-f1ab-4a31-8cd3-ccfeff12fea7","html_url":"https://github.com/ChainBuff/grpc-benchmark-ts","commit_stats":null,"previous_names":["chainbuff/grpc-benchmark-ts"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ChainBuff/grpc-benchmark-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainBuff%2Fgrpc-benchmark-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainBuff%2Fgrpc-benchmark-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainBuff%2Fgrpc-benchmark-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainBuff%2Fgrpc-benchmark-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChainBuff","download_url":"https://codeload.github.com/ChainBuff/grpc-benchmark-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainBuff%2Fgrpc-benchmark-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28111183,"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-12-29T02:00:07.021Z","response_time":58,"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":[],"created_at":"2025-12-29T05:37:56.721Z","updated_at":"2025-12-29T05:37:57.700Z","avatar_url":"https://github.com/ChainBuff.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GRPC 延迟测试\n\n\u003e **English Version**: [grpc-benchmark-ts-en](https://github.com/ChainBuff/grpc-benchmark-ts-en)\n\n## 安装\n\n### 前提条件\n\n- **Node.js** v22.0.0 (推荐)\n\n### 安装依赖\n\n```bash\npnpm install\n# or\nnpm install\n```\n\n## 测试工具说明\n\n本项目提供了两种不同的 GRPC 测试方法，分别适用于不同场景：\n\n### 1. GRPC 服务对比测试（推荐）\n\n**grpc-comparison** 工具用于对比多个 GRPC 服务的性能，通过分析它们接收相同 slot 的时间差来评估相对延迟。这种方法更接近实际使用场景，能够准确反映 GRPC 服务在处理 Solana 区块时的实际表现。\n\n#### 与 ping-pong 测试的主要区别\n\n- **更接近真实场景**：测量的是接收真实区块数据的延迟，而不仅仅是网络通信延迟\n- **支持多端点对比**：可同时测试多个 GRPC 服务，直观对比它们的性能差异\n- **精确的性能指标**：提供\"首先接收百分比\"、\"落后时平均延迟\"等更有意义的指标\n\n#### 使用方法\n\n```bash\nnpx tsx src/grpc-bench/grpc-comparison.ts\n```\n\n配置多个端点进行对比：\n\n```bash\nGRPC_URL_1=https://grpc1.example.com:443 \\\nGRPC_URL_2=https://grpc2.example.com:443 \\\nGRPC_COMPARISON_DURATION_SEC=30 \\\nnpx tsx src/grpc-bench/grpc-comparison.ts\n```\n\n详细配置和使用说明请参考 [grpc-comparison.md](./grpc-comparison.md)。\n\n### 2. Ping-Pong 延迟测试（基础测试）\n\n这种方法通过发送 ping 请求并测量收到 pong 回复的时间来测试 GRPC 服务的基本网络通信延迟。适用于简单评估 GRPC 服务的网络连接质量，但不能完全反映服务处理实际区块数据的性能。\n\n#### 串行测试\n\n连续发送 ping 请求，每个间隔 100ms：\n\n```bash\nnpx tsx src/grpc-bench/latency-serial.ts --total_rounds=10\n```\n\n#### 并发测试\n\n同时保持多个 ping 请求：\n\n```bash\nnpx tsx src/grpc-bench/latency-parallel.ts --concurrency=10\n```\n\n#### 配置参数\n\n| 变量名         | 描述                                 | 默认值                                               |\n| -------------- | ------------------------------------ | ---------------------------------------------------- |\n| `GRPC_URL`     | 要测试的 gRPC 服务 URL               | `https://solana-yellowstone-grpc.publicnode.com:443` |\n| `GRPC_TOKEN`   | gRPC 服务认证令牌 (X-Token)          | 无                                                   |\n| `TOTAL_ROUNDS` | 要发送的总 ping 请求数量             | `50`                                                 |\n| `CONCURRENCY`  | 并发数量，即同时进行的 ping 请求数量 | `10`                                                 |\n\n## 输出示例\n\n### GRPC 服务对比测试输出示例\n\n```plaintext\n[12:06:42.505] INFO: 开始对比多个 GRPC 服务性能...\n[12:06:42.506] INFO: 测试持续时间: 30秒\n[12:06:42.506] INFO: 测试端点: GRPC_1, GRPC_2\n[12:06:43.547] INFO: 所有端点都已接收到第一个 slot, 开始正式统计...\n[12:07:12.613] INFO: ===== 端点性能对比 =====\n[12:07:12.613] INFO: GRPC_2  : 首先接收  85.14%, 落后时平均延迟  28.69ms, 总体平均延迟   4.27ms\n[12:07:12.613] INFO: GRPC_1  : 首先接收  14.86%, 落后时平均延迟   3.86ms, 总体平均延迟   3.29ms\n```\n\n### Ping-Pong 测试输出示例\n\n```plaintext\n[11:09:18.626] INFO: GRPC_URL: https://grpc.example.com\n[11:09:18.761] INFO: Round 1: 12.38ms\n[11:09:18.762] INFO: Round 2: 12.86ms\n[11:09:19.672] INFO:\n延迟统计:\n  平均延迟: 10.65ms\n  最小延迟: 9.38ms\n  最大延迟: 19.50ms\n  样本数量: 100\n```\n\n## 联系方式\n\nTelegram: @bloxflux\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainbuff%2Fgrpc-benchmark-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainbuff%2Fgrpc-benchmark-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainbuff%2Fgrpc-benchmark-ts/lists"}