SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
GO1.8
NET/HTTP
TIMEOUTS
2017-03-25 Tetsuya Morimoto
ABOUT ME
Tetsuya Morimoto
twitter: @t2y
I like Python, Java and Go!
Yahoo Japan Corporation
Data & Science Solutions Group
Apprentice Infrastructure engineer
Mission: OPS → SRE
RECENT WORK
Qiita
[ ] (SRE)
Go 1.8 Graceful Shutdown
Python
3/21
3/18
1/27
GO 1.8 FEATURE
MINOR CHANGES
Go 1.8 net/http changes from release note
“The Server adds configuration options
ReadHeaderTimeout and IdleTimeout and
documentsWriteTimeout. ”
NOTABLE ARTICLES
https://blog.cloudflare.com/
The complete guide to Go net/http timeouts
So you want to expose Go on the Internet
Written by @FiloSottile (FilippoValsorda)
“ Back when crypto/tls was slow and net/http young,
the general wisdom was to always put Go servers
behind a reverse proxy like NGINX.
That's not necessary anymore! ”
STUDY TIMEOUTS
SOCKETTIMEOUTS
net.Conn interface
SetDeadline (SetReadDeadline/SetWriteDeadline)
I/O operation with timeout
Let’s Socket Programming!
Socket is an API working on transport layer
Go TCP
Go TCP
socket
bind
listen
accept
Conn
Transport Layer
HTTP SERVERTIMEOUTS Application Layer
Go1.8
Go1.7
new!
ReadHeaderTimeout
These images are quoted from Filippo’s article on https://blog.cloudflare.com
HTTP SERVERTIMEOUTS
net/http: no way of manipulating timeouts in Handler #16100
issued at 2016-06-18 (Go 1.6.x)
Go 1.8 introduces ReadHeaderTimeout
Reset read deadline after reading the request header
Application Layer
“ Go 1.8 introduces ReadHeaderTimeout,
which only covers up to the request headers.
However, there's still no clear way to do reads
with timeouts from a Handler. ”
HTTP CLIENTTIMEOUTS Application Layer
This image is quoted from Filippo’s article on https://blog.cloudflare.com
“ Client-side timeouts can be simpler or much more complex, … ”
CONTEXT PACKAGE
context is standard way
the advantage
a request will cancel if
parent context would
cancel
ctx, cancel := context.WithCancel(context.TODO())
timer := time.AfterFunc(5*time.Second, func() {
cancel()
})
req, err := http.NewRequest("GET",“http://
example.com”, nil)
if err != nil {
log.Fatal(err)
}
req = req.WithContext(ctx)
SUMMARY
Timeouts is important for effective/stable Web service.
including against malicious attack (DoS/DDoS)
Go 1.8 http.Server is enough stable!

Weitere ähnliche Inhalte

Was ist angesagt?

Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
Nap Ramirez
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
Ailsa126
 

Was ist angesagt? (20)

Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginning
 
Git training with Devaamo
Git training with DevaamoGit training with Devaamo
Git training with Devaamo
 
Helios in Action: Git at Eclipse
Helios in Action: Git at EclipseHelios in Action: Git at Eclipse
Helios in Action: Git at Eclipse
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
Git hooks for front end developers
Git hooks for front end developersGit hooks for front end developers
Git hooks for front end developers
 
Git hooks
Git hooksGit hooks
Git hooks
 
Pharo Status ESUG 2014
Pharo Status ESUG 2014Pharo Status ESUG 2014
Pharo Status ESUG 2014
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Microsoft & open source a 'brave new world' - CORESTART 2.0
Microsoft & open source a 'brave new world' - CORESTART 2.0Microsoft & open source a 'brave new world' - CORESTART 2.0
Microsoft & open source a 'brave new world' - CORESTART 2.0
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
 
Git Heaven with Wakanda
Git Heaven with WakandaGit Heaven with Wakanda
Git Heaven with Wakanda
 
Git hooks
Git hooksGit hooks
Git hooks
 
Pharo Status Fosdem 2015
Pharo Status Fosdem 2015Pharo Status Fosdem 2015
Pharo Status Fosdem 2015
 
Paving the way with Jakarta EE and apache TomEE at cloudconferenceday
Paving the way with Jakarta EE and apache TomEE at cloudconferencedayPaving the way with Jakarta EE and apache TomEE at cloudconferenceday
Paving the way with Jakarta EE and apache TomEE at cloudconferenceday
 
Git ongithub
Git ongithubGit ongithub
Git ongithub
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
 
git and github
git and githubgit and github
git and github
 

Andere mochten auch

Andere mochten auch (9)

My client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoMy client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with Go
 
Coding in the context era
Coding in the context eraCoding in the context era
Coding in the context era
 
Go conference 2017 Lightning talk
Go conference 2017 Lightning talkGo conference 2017 Lightning talk
Go conference 2017 Lightning talk
 
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 SpringGoでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
 
Goをカンストさせる話
Goをカンストさせる話Goをカンストさせる話
Goをカンストさせる話
 
20171105 go con2017_lt
20171105 go con2017_lt20171105 go con2017_lt
20171105 go con2017_lt
 
Gocon2017:Goのロギング周りの考察
Gocon2017:Goのロギング周りの考察Gocon2017:Goのロギング周りの考察
Gocon2017:Goのロギング周りの考察
 
GOCON Autumn (Story of our own Monitoring Agent in golang)
GOCON Autumn (Story of our own Monitoring Agent in golang)GOCON Autumn (Story of our own Monitoring Agent in golang)
GOCON Autumn (Story of our own Monitoring Agent in golang)
 
条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化
 

Ähnlich wie go 1.8 net/http timeouts

Github:fi Presentation
Github:fi PresentationGithub:fi Presentation
Github:fi Presentation
PTIHPA
 
The Path to Stackato
The Path to StackatoThe Path to Stackato
The Path to Stackato
Platform CF
 
The Path to Stackato
The Path to StackatoThe Path to Stackato
The Path to Stackato
Platform CF
 

Ähnlich wie go 1.8 net/http timeouts (20)

Global EC Cluster Updates (OpenStack Mitaka Swift Design Summit)
Global EC Cluster Updates (OpenStack Mitaka Swift Design Summit)Global EC Cluster Updates (OpenStack Mitaka Swift Design Summit)
Global EC Cluster Updates (OpenStack Mitaka Swift Design Summit)
 
Pavimentando el camino con Jakarta EE 9 y Apache TomEE
Pavimentando el camino con Jakarta EE 9 y Apache TomEE Pavimentando el camino con Jakarta EE 9 y Apache TomEE
Pavimentando el camino con Jakarta EE 9 y Apache TomEE
 
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
 
OCDET Activity and Glusterfs
OCDET Activity and GlusterfsOCDET Activity and Glusterfs
OCDET Activity and Glusterfs
 
FOSDEM 2020: How can we make WebRTC Easier?
FOSDEM 2020: How can we make WebRTC Easier?FOSDEM 2020: How can we make WebRTC Easier?
FOSDEM 2020: How can we make WebRTC Easier?
 
Tranquilizer
TranquilizerTranquilizer
Tranquilizer
 
Paving the way with Jakarta EE and Apache TomEE - itkonekt 2020
Paving the way with Jakarta EE and Apache TomEE - itkonekt 2020Paving the way with Jakarta EE and Apache TomEE - itkonekt 2020
Paving the way with Jakarta EE and Apache TomEE - itkonekt 2020
 
Github:fi Presentation
Github:fi PresentationGithub:fi Presentation
Github:fi Presentation
 
BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108
 
The Path to Stackato
The Path to StackatoThe Path to Stackato
The Path to Stackato
 
The Path to Stackato
The Path to StackatoThe Path to Stackato
The Path to Stackato
 
Dc ch02 : protocol architecture
Dc ch02 : protocol architectureDc ch02 : protocol architecture
Dc ch02 : protocol architecture
 
HTTP/2 and SAP Fiori
HTTP/2 and SAP FioriHTTP/2 and SAP Fiori
HTTP/2 and SAP Fiori
 
Intro to Perfect - LA presentation
Intro to Perfect - LA presentationIntro to Perfect - LA presentation
Intro to Perfect - LA presentation
 
Jetty 9 – The Next Generation Servlet Container
Jetty 9 – The Next Generation Servlet ContainerJetty 9 – The Next Generation Servlet Container
Jetty 9 – The Next Generation Servlet Container
 
Updates on webSpoon and other innovations from Hitachi R&D
Updates on webSpoon and other innovations from Hitachi R&DUpdates on webSpoon and other innovations from Hitachi R&D
Updates on webSpoon and other innovations from Hitachi R&D
 
Kamailio - Unifying SIP and Web Worlds with Lua
Kamailio - Unifying SIP and Web Worlds with LuaKamailio - Unifying SIP and Web Worlds with Lua
Kamailio - Unifying SIP and Web Worlds with Lua
 
Monkey Server
Monkey ServerMonkey Server
Monkey Server
 
Nodejs on 02/22/2012
Nodejs on 02/22/2012Nodejs on 02/22/2012
Nodejs on 02/22/2012
 
netty_qcon_v4
netty_qcon_v4netty_qcon_v4
netty_qcon_v4
 

Mehr von Yahoo!デベロッパーネットワーク

Mehr von Yahoo!デベロッパーネットワーク (20)

ゼロから始める転移学習
ゼロから始める転移学習ゼロから始める転移学習
ゼロから始める転移学習
 
継続的なモデルモニタリングを実現するKubernetes Operator
継続的なモデルモニタリングを実現するKubernetes Operator継続的なモデルモニタリングを実現するKubernetes Operator
継続的なモデルモニタリングを実現するKubernetes Operator
 
ヤフーでは開発迅速性と品質のバランスをどう取ってるか
ヤフーでは開発迅速性と品質のバランスをどう取ってるかヤフーでは開発迅速性と品質のバランスをどう取ってるか
ヤフーでは開発迅速性と品質のバランスをどう取ってるか
 
オンプレML基盤on Kubernetes パネルディスカッション
オンプレML基盤on Kubernetes パネルディスカッションオンプレML基盤on Kubernetes パネルディスカッション
オンプレML基盤on Kubernetes パネルディスカッション
 
LakeTahoe
LakeTahoeLakeTahoe
LakeTahoe
 
オンプレML基盤on Kubernetes 〜Yahoo! JAPAN AIPF〜
オンプレML基盤on Kubernetes 〜Yahoo! JAPAN AIPF〜オンプレML基盤on Kubernetes 〜Yahoo! JAPAN AIPF〜
オンプレML基盤on Kubernetes 〜Yahoo! JAPAN AIPF〜
 
Persistent-memory-native Database High-availability Feature
Persistent-memory-native Database High-availability FeaturePersistent-memory-native Database High-availability Feature
Persistent-memory-native Database High-availability Feature
 
データの価値を最大化させるためのデザイン~データビジュアライゼーションの方法~ #devsumi 17-E-2
データの価値を最大化させるためのデザイン~データビジュアライゼーションの方法~ #devsumi 17-E-2データの価値を最大化させるためのデザイン~データビジュアライゼーションの方法~ #devsumi 17-E-2
データの価値を最大化させるためのデザイン~データビジュアライゼーションの方法~ #devsumi 17-E-2
 
eコマースと実店舗の相互利益を目指したデザイン #yjtc
eコマースと実店舗の相互利益を目指したデザイン #yjtceコマースと実店舗の相互利益を目指したデザイン #yjtc
eコマースと実店舗の相互利益を目指したデザイン #yjtc
 
ヤフーを支えるセキュリティ ~サイバー攻撃を防ぐエンジニアの仕事とは~ #yjtc
ヤフーを支えるセキュリティ ~サイバー攻撃を防ぐエンジニアの仕事とは~ #yjtcヤフーを支えるセキュリティ ~サイバー攻撃を防ぐエンジニアの仕事とは~ #yjtc
ヤフーを支えるセキュリティ ~サイバー攻撃を防ぐエンジニアの仕事とは~ #yjtc
 
Yahoo! JAPANのIaaSを支えるKubernetesクラスタ、アップデート自動化への挑戦 #yjtc
Yahoo! JAPANのIaaSを支えるKubernetesクラスタ、アップデート自動化への挑戦 #yjtcYahoo! JAPANのIaaSを支えるKubernetesクラスタ、アップデート自動化への挑戦 #yjtc
Yahoo! JAPANのIaaSを支えるKubernetesクラスタ、アップデート自動化への挑戦 #yjtc
 
ビッグデータから人々のムードを捉える #yjtc
ビッグデータから人々のムードを捉える #yjtcビッグデータから人々のムードを捉える #yjtc
ビッグデータから人々のムードを捉える #yjtc
 
サイエンス領域におけるMLOpsの取り組み #yjtc
サイエンス領域におけるMLOpsの取り組み #yjtcサイエンス領域におけるMLOpsの取り組み #yjtc
サイエンス領域におけるMLOpsの取り組み #yjtc
 
ヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtc
ヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtcヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtc
ヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtc
 
Yahoo! JAPAN Tech Conference 2022 Day2 Keynote #yjtc
Yahoo! JAPAN Tech Conference 2022 Day2 Keynote #yjtcYahoo! JAPAN Tech Conference 2022 Day2 Keynote #yjtc
Yahoo! JAPAN Tech Conference 2022 Day2 Keynote #yjtc
 
新技術を使った次世代の商品の見せ方 ~ヤフオク!のマルチビュー機能~ #yjtc
新技術を使った次世代の商品の見せ方 ~ヤフオク!のマルチビュー機能~ #yjtc新技術を使った次世代の商品の見せ方 ~ヤフオク!のマルチビュー機能~ #yjtc
新技術を使った次世代の商品の見せ方 ~ヤフオク!のマルチビュー機能~ #yjtc
 
PC版Yahoo!メールリニューアル ~サービスのUI/UX統合と改善プロセス~ #yjtc
PC版Yahoo!メールリニューアル ~サービスのUI/UX統合と改善プロセス~ #yjtcPC版Yahoo!メールリニューアル ~サービスのUI/UX統合と改善プロセス~ #yjtc
PC版Yahoo!メールリニューアル ~サービスのUI/UX統合と改善プロセス~ #yjtc
 
モブデザインによる多職種チームのコミュニケーション改善 #yjtc
モブデザインによる多職種チームのコミュニケーション改善 #yjtcモブデザインによる多職種チームのコミュニケーション改善 #yjtc
モブデザインによる多職種チームのコミュニケーション改善 #yjtc
 
「新しいおうち探し」のためのAIアシスト検索 #yjtc
「新しいおうち探し」のためのAIアシスト検索 #yjtc「新しいおうち探し」のためのAIアシスト検索 #yjtc
「新しいおうち探し」のためのAIアシスト検索 #yjtc
 
ユーザーの地域を考慮した検索入力補助機能の改善の試み #yjtc
ユーザーの地域を考慮した検索入力補助機能の改善の試み #yjtcユーザーの地域を考慮した検索入力補助機能の改善の試み #yjtc
ユーザーの地域を考慮した検索入力補助機能の改善の試み #yjtc
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

go 1.8 net/http timeouts

  • 2. ABOUT ME Tetsuya Morimoto twitter: @t2y I like Python, Java and Go! Yahoo Japan Corporation Data & Science Solutions Group Apprentice Infrastructure engineer Mission: OPS → SRE
  • 3. RECENT WORK Qiita [ ] (SRE) Go 1.8 Graceful Shutdown Python 3/21 3/18 1/27
  • 5. MINOR CHANGES Go 1.8 net/http changes from release note “The Server adds configuration options ReadHeaderTimeout and IdleTimeout and documentsWriteTimeout. ”
  • 6. NOTABLE ARTICLES https://blog.cloudflare.com/ The complete guide to Go net/http timeouts So you want to expose Go on the Internet Written by @FiloSottile (FilippoValsorda) “ Back when crypto/tls was slow and net/http young, the general wisdom was to always put Go servers behind a reverse proxy like NGINX. That's not necessary anymore! ”
  • 8. SOCKETTIMEOUTS net.Conn interface SetDeadline (SetReadDeadline/SetWriteDeadline) I/O operation with timeout Let’s Socket Programming! Socket is an API working on transport layer Go TCP Go TCP socket bind listen accept Conn Transport Layer
  • 9. HTTP SERVERTIMEOUTS Application Layer Go1.8 Go1.7 new! ReadHeaderTimeout These images are quoted from Filippo’s article on https://blog.cloudflare.com
  • 10. HTTP SERVERTIMEOUTS net/http: no way of manipulating timeouts in Handler #16100 issued at 2016-06-18 (Go 1.6.x) Go 1.8 introduces ReadHeaderTimeout Reset read deadline after reading the request header Application Layer “ Go 1.8 introduces ReadHeaderTimeout, which only covers up to the request headers. However, there's still no clear way to do reads with timeouts from a Handler. ”
  • 11. HTTP CLIENTTIMEOUTS Application Layer This image is quoted from Filippo’s article on https://blog.cloudflare.com “ Client-side timeouts can be simpler or much more complex, … ”
  • 12. CONTEXT PACKAGE context is standard way the advantage a request will cancel if parent context would cancel ctx, cancel := context.WithCancel(context.TODO()) timer := time.AfterFunc(5*time.Second, func() { cancel() }) req, err := http.NewRequest("GET",“http:// example.com”, nil) if err != nil { log.Fatal(err) } req = req.WithContext(ctx)
  • 13. SUMMARY Timeouts is important for effective/stable Web service. including against malicious attack (DoS/DDoS) Go 1.8 http.Server is enough stable!