Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请求使用httpx替代requests,使用http2的多路复用 #53

Open
ilpl opened this issue Jan 7, 2022 · 2 comments
Open

请求使用httpx替代requests,使用http2的多路复用 #53

ilpl opened this issue Jan 7, 2022 · 2 comments

Comments

@ilpl
Copy link

ilpl commented Jan 7, 2022

httpx 支持http2,
pip3 install httpx
pip3 install 'httpx[http2]'
requests.Session() 替换成 httpx.Client(http2=True)

使用http2的多路复用减少握手.

@L-codes
Copy link
Owner

L-codes commented Jan 8, 2022

httpx.Client(http2=True) 会向下兼容 http1.0 http1.1 等吗?

@L-codes
Copy link
Owner

L-codes commented Jan 8, 2022

感谢你的建议,由于下面的几点分析,这个性能效果并不会很明显,由于目前项目追求稳定性,暂不会加入,但后续测试http2能够稳定运行后加入支持~

  1. requests http1.1时,支持Keep-Alive的方式减少tcp握手,所以http2的多路复用并不会给 neoreg 减少握手。
  2. http2 的 header 压缩可以减少一点上下行宽带,但是效果不大。
  3. http2 的多路复用,支持异步的请求方式,但是 neoreg write/read 行为是顺序的,或许能提高 write/read 的实时性。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants