Http2 on go1.6rc2

0
-1

Published on

abou http2 on go1.6rc2
at Go1.6 release party 2016/2/17

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
0
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Http2 on go1.6rc2

  1. 1. HTTP2 on Go1.6 Go1.6 Release Party 2016 Jxck
  2. 2. ● id: Jxck ● github: Jxck ● twitter: @jxck_ ● blog: https://blog.jxck.io ● podcast: http://mozaic.fm ● Love: music Jack
  3. 3. 3 #http2study #wdpress vol.75#http2go (deprecated) and more... #mozaicfm ep2 http2 activity
  4. 4. RFC7540 4
  5. 5. 5 HTTP2 in Go1.6
  6. 6. net/http supports http2 6
  7. 7. 7 before import ( fmt log net/http ) func main() { var s http.Server s.Addr = ":8080" http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") fmt.Fprintf(w, "Hello World") }) log.Fatal(s.ListenAndServeTLS(cert, key)) }
  8. 8. 8 after import ( fmt log net/http ) func main() { var s http.Server s.Addr = ":8080" http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") fmt.Fprintf(w, "Hello World") }) log.Fatal(s.ListenAndServeTLS(cert, key)) }
  9. 9. 9 you don’t need this after 1.6 $ git clone --depth=1 https://go.googlesource.com/go $HOME/gotip $ cd $HOME/gotip/src $ ./make.bash $ cd $YOUR_PROJ $ $HOME/gotip/bin/go {install,build,test}.
  10. 10. 10 how http2 bundled ? $ tree $GOROOT/src/net/http |-- fs.go |-- fs_test.go |-- h2_bundle.go |-- header.go |-- header_test.go |-- http_test.go bundle golang.org/x/net/http2 into net/http package prefixed with `http2`
  11. 11. prefixed source 11 bundled original
  12. 12. inject h2 to net/http2 12 App App ALPN http/2 client http/1.1 client http/1.1 server http/2 server TCP
  13. 13. inside (current status rc2) 13
  14. 14. hpack 14 ● compress http header ○ with static/dynamic table ○ with huffman encoding ○ with binary frame ● Encode Strategy ○ depends on implement ● Benchmark ○ using hpack-test-case ○ https://gist.github.com/Jxck/a2125cfc162229e4f54f implementation go-hpack haskell nghttp2 node-http2 ration(small is better) 62% 31% 31% 32%
  15. 15. Server Push 15 ● Push data from server ○ sending PUSH_PROMISE frame ● Low Level API ○ WritePushPromise() ● High Level API ○ not yet ○ wip ? https://goo.gl/IV0fyI // CAUTION: wip code if p, ok := w.(http2.Pusher); push && ok { p.Push("GET", “/path/to/push”, nil) }
  16. 16. Flow Control 16 ● 2 Level Flow Control ○ Stream level ○ Connection level ○ with WindowUpdate Frame ● Current Implement ○ supported ○ default sends big window update for connection ○ stream window update each 4M transfer
  17. 17. Priority 17 ● Priorities Contents ○ with weight of Stream ○ make dependency tree ○ ignorable ○ ex) high for html, low for image.. ● Low Level ○ WritePriority() ● High Level ○ no high level api ○ no auto priorities content like html, css, img etc ○ priority respected ?? I can’t find.
  18. 18. Spec Coverage 18 ● testing with h2spec ○ https://github.com/summerwind/h2spec ● toward http2.golang.org $ h2spec -t http2.golang.org 3.5. HTTP/2 Connection Preface ✓ Sends invalid connection preface ….. 8.2. Server Push ✓ Sends a PUSH_PROMISE frame 71 tests, 58 passed, 0 skipped, 13 failed
  19. 19. more 19 ● DEBUG ● h2i $ GODEBUG="http2debug=1" go run main.go $ GODEBUG="http2debug=2" go run main.go $ h2i jxck.io Connected to 160.16.234.102:443 ... h2i> headers (as HTTP/1.1)> GET / HTTP/1.1 (as HTTP/1.1)> Opening Stream-ID 1: ...
  20. 20. Go to the HTTP2!! 20
  21. 21. Jack

×