finian
1D
V2EX  ›  Node.js

http和https的连接速度差别有这么大么?

  •  
  •   finian · Oct 18, 2013 · 6776 views
    This topic created in 4622 days ago, the information mentioned may be changed or developed.
    用的ucloud云主机,写了个简单的输出hello world的http和https(godaddy证书)。用alibench测试,http的平均连接时间在50ms上下,https的在1500ms,这差别也太大了吧?请问如何加速https的连接速度?
    8 replies    1970-01-01 08:00:00 +08:00
    Tr0y
        1
    Tr0y  
       Oct 18, 2013
    换个其它的bench试试,ssl链接不应该差别这么大.
    cloudzhou
        2
    cloudzhou  
       Oct 18, 2013   ❤️ 3
    https 的最大消耗是握手阶段,所以数据很可能就是你上面展示的。但握手之后,在现代机器硬件水平下,和 http 差不多,所以服务端要启用 keep-alive ,增加 ssl 的 cache,以 nginx 为例子:
    keepalive_timeout 90;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 15m;
    cloudzhou
        3
    cloudzhou  
       Oct 18, 2013
    alibench测试不能说明一切,因为这个测试很可能是每次链接都是一个新的session,也就是说,你测试的是握手需要的时间
    dndx
        4
    dndx  
       Oct 18, 2013
    在未使用 Keep-Alive 的情况下,SSL 握手阶段消耗时间很长,自然不占优势。
    luikore
        5
    luikore  
       Oct 18, 2013
    可能他们的 https 设置根本没优化. 例如用 aesni 就可以快一些

    ssl_engine aesni;

    ssl_ciphers AES128-SHA:AES256-SHA:HIGH:!aNULL:!eNULL:!LOW:!ADH:!MD5;
    ssl_prefer_server_ciphers on;
    feuvan
        6
    feuvan  
       Oct 18, 2013
    ssl_session_cache 蛮有效的。推荐
    ihacku
        7
    ihacku  
       Oct 19, 2013   ❤️ 1
    vagase
        8
    vagase  
       Nov 2, 2013
    可能是证书问题,看看证书密钥长度是不是太长,而且证书最好包含所有中间证书,这样会减少证书检查时间。

    详情见:
    https://www.imperialviolet.org/2010/06/25/overclocking-ssl.html
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3931 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 00:57 · PVG 08:57 · LAX 17:57 · JFK 20:57
    ♥ Do have faith in what you're doing.