{"id":16749882,"url":"https://github.com/abrahamgreyson/php-ios-protobuf-test","last_synced_at":"2025-03-16T04:19:53.729Z","repository":{"id":238482648,"uuid":"794018284","full_name":"abrahamgreyson/php-ios-protobuf-test","owner":"abrahamgreyson","description":"和杜斌调试一下 protobuf 协议","archived":false,"fork":false,"pushed_at":"2024-05-07T04:03:47.000Z","size":382,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T16:11:49.486Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/abrahamgreyson.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":"2024-04-30T09:53:16.000Z","updated_at":"2024-05-07T04:03:34.000Z","dependencies_parsed_at":"2024-11-22T04:00:17.865Z","dependency_job_id":null,"html_url":"https://github.com/abrahamgreyson/php-ios-protobuf-test","commit_stats":null,"previous_names":["abrahamgreyson/php-ios-protobuf-test"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrahamgreyson%2Fphp-ios-protobuf-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrahamgreyson%2Fphp-ios-protobuf-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrahamgreyson%2Fphp-ios-protobuf-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrahamgreyson%2Fphp-ios-protobuf-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abrahamgreyson","download_url":"https://codeload.github.com/abrahamgreyson/php-ios-protobuf-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243823132,"owners_count":20353617,"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-10-13T02:26:23.743Z","updated_at":"2025-03-16T04:19:53.704Z","avatar_url":"https://github.com/abrahamgreyson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"#### 和杜斌调试一下 protobuf 协议\n\n\u003e “非正式”表明这个仓库的内容既不是正式的产品开发线，也不是计划采用的项目。其主要用途可能为学习、实验或初步的想法验证和技术尝试。虽然这些项目可能包含有价值的信息和经验，但在参考或使用此项目的资料时，请注意其非正式的性质，并以适当的预防措施处理相关信息。\n\n\n###### 资料\n\n- https://github.com/protocolbuffers/protobuf 各个语言的运行时库\n- https://protobuf.dev/programming-guides/dos-donts/ 最佳实践\n\n###### proto 模板\n\n- dummy_event.proto\n\n###### 客户端接入文档\n\n- 端点\n  - ws://192.168.1.137:18081/app/0fv5zyndfzkszhp3bpf0\n  - http://192.168.1.137:18001\n  \n- [Apipost](https://console-docs.apipost.cn/preview/55b56dff48c6f99e/cbeb85ae0cc50ea6)\n\n###### Benchmark\n\n分别使用 `post_json.lua` 和 `post_proto.lua` 向接口发送 Json 和 Proto 数据，接口收到后解成 json 原样返回。\n\n```bash\nwrk -c 100 -t 4 --latency -s post_json.lua http://127.0.0.1:8000/json\n```\n![json.png](json.png)\n```bash\nwrk -c 100 -t 4 --latency -s post_proto.lua http://127.0.0.1:8000/protobuf\n```\n![proto.png](proto.png)\n\n初步结论： 速度上相差不大， 发送数据量减少 2/3 ， proto 约为 json 的三分之一。\n\n- 优点： 客户端提交数据量变小；等于用 proto 模板去约定数据结构。\n- 缺点： 前后端要关注同一个 proto 模板，如果结构变更，要同时迭代发版，其中一个回滚可能会出现错误，结构更改只能见见进行，无法进行重大更改。没有 JSON 字符串直观。\n\n- 建议：不使用， 个人觉得这东西更适合服务之间互相调用（同一个端，同一种发版策略，甚至服务之间的维护者是同一批人）\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrahamgreyson%2Fphp-ios-protobuf-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabrahamgreyson%2Fphp-ios-protobuf-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrahamgreyson%2Fphp-ios-protobuf-test/lists"}