推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
itertools
V2EX  ›  Python

关于 grpc 如何扩展

  •  
  •   itertools · Aug 23, 2017 · 5116 views
    This topic created in 3273 days ago, the information mentioned may be changed or developed.

    最近刚接触 grpc 有个不明白的地方: 官方例子中 grpc 服务端和客户端都是写死了 host 和 port,那么如果由于用户量的上升,grpc 服务端需要扩展到多台,那么这个时候如何处理? grpc 有现成的方案?

    11 replies    2017-08-23 22:24:45 +08:00
    donyee
        1
    donyee  
       Aug 23, 2017
    实现个 DNS 轮询服务
    或者试试 grpc + consul
    maemual
        2
    maemual  
       Aug 23, 2017
    了解一下什么叫 服务注册发现
    maemual
        3
    maemual  
       Aug 23, 2017
    简单方案就是服务端前面用 HAProxy,客户端连 HA
    timonwong
        4
    timonwong  
       Aug 23, 2017   ❤️ 1
    python 的 grpc 就放弃吧,虽然你可以写 C extension 扩展 resolver,但是要在最开头引入,因为 grpcio 的所有 class,__init__ 都隐含调用 grpc_init(),这样你写的 resolver 就没有用了

    c-core 原生支持 dns resolver,target 用 dns:// 开头,不过只支持 A 记录
    c-core 的 client side lb 自带了,不需要你自己做,但是参数你要看 C 的代码。
    完全没有 go client 那么方便。

    最终你可能还是会考虑 @maemual 说的 HAProxy 方案
    cloudzhou
        5
    cloudzhou  
       Aug 23, 2017
    JohnSmith
        6
    JohnSmith  
       Aug 23, 2017
    go 的话很方便,etcd 的 v3 版本客户端已经提供 grpclb 的实现,几行代码就能使用,而且不仅仅可以简单的负载算法,还可以自己实现一些特定的算法来满足特定需求,比如一致性 hash
    @cloudzhou +1
    Finest
        7
    Finest  
       Aug 23, 2017
    Java 版本可以自己实现 Loadbalancer,不过略复杂
    janxin
        8
    janxin  
       Aug 23, 2017
    python 选择 HA 方案挺方便的
    zh5e
        9
    zh5e  
       Aug 23, 2017
    用的 aws loadblance 服务
    owt5008137
        10
    owt5008137  
       Aug 23, 2017 via Android
    这和 grpc 有半毛钱关系?
    0915240
        11
    0915240  
       Aug 23, 2017
    grpc 只负责 rpc,你这个需要的是服务发现与 client 负载均衡。

    当然系统化的话就更多了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2862 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 08:38 · PVG 16:38 · LAX 01:38 · JFK 04:38
    ♥ Do have faith in what you're doing.