{"action":"created","issue":{"url":"https://api.github.com/repos/tatsuhiro-t/nghttp2/issues/182","labels_url":"https://api.github.com/repos/tatsuhiro-t/nghttp2/issues/182/labels{/name}","comments_url":"https://api.github.com/repos/tatsuhiro-t/nghttp2/issues/182/comments","events_url":"https://api.github.com/repos/tatsuhiro-t/nghttp2/issues/182/events","html_url":"https://github.com/tatsuhiro-t/nghttp2/issues/182","id":61270533,"number":182,"title":"Timigs and latency http/2 vs tls","user":{"login":"brk0v","id":47447,"avatar_url":"https://avatars.githubusercontent.com/u/47447?v=3","gravatar_id":"","url":"https://api.github.com/users/brk0v","html_url":"https://github.com/brk0v","followers_url":"https://api.github.com/users/brk0v/followers","following_url":"https://api.github.com/users/brk0v/following{/other_user}","gists_url":"https://api.github.com/users/brk0v/gists{/gist_id}","starred_url":"https://api.github.com/users/brk0v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brk0v/subscriptions","organizations_url":"https://api.github.com/users/brk0v/orgs","repos_url":"https://api.github.com/users/brk0v/repos","events_url":"https://api.github.com/users/brk0v/events{/privacy}","received_events_url":"https://api.github.com/users/brk0v/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-13T22:08:30Z","updated_at":"2015-03-14T19:53:41Z","closed_at":null,"body":"Hi, \r\n\r\nI'm a little confused about multiplexing over tcp in http/2 and timings. \r\n\r\nI have a simple html page with 2 images:\r\n\r\n```html\r\n<html>\r\n  <head><title>http2 test</title></head>\r\n  <body>\r\n   <img src=\"1.jpg\" />\r\n   <img src=\"2.jpg\" />\r\n  </body>\r\n</html>\r\n```\r\n\r\nWhile I'm serving it using nginx – I get following timings (with disabled browser cache and after TLS handshake):\r\n\r\n![](http://habrastorage.org/files/5ba/9ae/8b0/5ba9ae8b069749208c1a98e392ea71b4.png)\r\n\r\nIn total: **240ms**.\r\n\r\nIn ```netstat``` we can see that FireFox opened 2 connections:\r\n```\r\nroot@vagrant-ubuntu-trusty-64:~# netstat -ntp | grep 8443\r\ntcp        0      0 192.168.32.10:8443      192.168.32.1:55232      ESTABLISHED 9206/nginx: worker\r\ntcp        0      0 192.168.32.10:8443      192.168.32.1:55233      ESTABLISHED 9206/nginx: worker\r\n```\r\n\r\nAnd while serving nghttp2d:\r\n\r\n![](http://habrastorage.org/files/2ff/786/1d1/2ff7861d1220475ea391a22cb9265d98.png)\r\n\r\nIn total: **310ms**.\r\n\r\nnghttp2d start line:\r\n```\r\nsudo ./nghttpd  -d /var/www/  443  ./server.key ./server.crt\r\n```\r\n\r\nAnd one socket:\r\n```\r\nvagrant@vagrant-ubuntu-trusty-64:~/nghttp2/src$ sudo netstat -ntp | grep 443\r\ntcp        0      0 192.168.32.100:443      192.168.32.1:55325      ESTABLISHED 12574/lt-nghttpd\r\n```\r\n\r\nNginx's TLS config:\r\n```\r\n    ssl_protocols TLSv1.2;\r\n    ssl_ciphers kEECDH+AES128:kEECDH:kEDH:-3DES:kEDH+3DES:kRSA+AES128:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv2;\r\n    ssl_session_cache    shared:SSL:64m;\r\n    ssl_session_timeout  12h;\r\n```\r\n\r\n**So the question is why we loose so much time? I think that multiplexing should fix it.**\r\n\r\nP.S. I've emulated latency using ```iproute2``` and ```tc```:\r\n```\r\nsudo tc qdisc add dev eth1 root netem delay 100ms\r\n```"},"comment":{"url":"https://api.github.com/repos/tatsuhiro-t/nghttp2/issues/comments/80692542","html_url":"https://github.com/tatsuhiro-t/nghttp2/issues/182#issuecomment-80692542","issue_url":"https://api.github.com/repos/tatsuhiro-t/nghttp2/issues/182","id":80692542,"user":{"login":"brk0v","id":47447,"avatar_url":"https://avatars.githubusercontent.com/u/47447?v=3","gravatar_id":"","url":"https://api.github.com/users/brk0v","html_url":"https://github.com/brk0v","followers_url":"https://api.github.com/users/brk0v/followers","following_url":"https://api.github.com/users/brk0v/following{/other_user}","gists_url":"https://api.github.com/users/brk0v/gists{/gist_id}","starred_url":"https://api.github.com/users/brk0v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brk0v/subscriptions","organizations_url":"https://api.github.com/users/brk0v/orgs","repos_url":"https://api.github.com/users/brk0v/repos","events_url":"https://api.github.com/users/brk0v/events{/privacy}","received_events_url":"https://api.github.com/users/brk0v/received_events","type":"User","site_admin":false},"created_at":"2015-03-14T19:53:41Z","updated_at":"2015-03-14T19:53:41Z","body":"I guess I've found the answer. It is slow start after idle. You really should turn it of on the server side with http/2.\r\n\r\n```\r\nsysctl -w net.ipv4.tcp_slow_start_after_idle=0\r\n```\r\n\r\nAnd  now look at ```cwnd``` using this command:\r\n\r\n```\r\nss -n  --processes --options --info | grep  -A 1 lt-nghttpd\r\n```\r\n\r\nWe can see our ```cwnd``` and  ```ssthresh```:\r\n\r\nIn my case:\r\n\r\n```\r\n# ss -n  --processes --options --info | grep  -A 1 lt-nghttpd\r\ntcp    ESTAB      0      0         192.168.32.100:443        192.168.32.1:52096  users:((\"lt-nghttpd\",16117,7))\r\n         ts sack cubic wscale:5,6 rto:312 rtt:107/3 ato:40 mss:1448 cwnd:262 ssthresh:219 send 28.4Mbps rcv_rtt:319776 rcv_space:29102\r\n```"}}