Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

HELLO! I’m Ian Kent I work @ONSdigital You can find me at @iankent

Slide 8

Slide 8 text

I’ve written some seriously bad code…

Slide 9

Slide 9 text

I’ve deployed some seriously bad code…

Slide 10

Slide 10 text

Some of that code is still in production

Slide 11

Slide 11 text

Production Ready Go

Slide 12

Slide 12 text

Some Go things
 (that I won’t be talking about) • fmt • vet • lint • test • -race • pprof • vendor • cover

Slide 13

Slide 13 text

Some not-Go things
 (that I also won’t be talking about) • logging • tracing • errors • retries

Slide 14

Slide 14 text

Deploying Go 
 to production 
 is too easy

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

0.1ms 1.4ms

Slide 17

Slide 17 text

My mistakes • Client timeouts • Server timeouts • OS signals • Cancellation

Slide 18

Slide 18 text

Client
 timeouts

Slide 19

Slide 19 text

DefaultClient in net/http doesn’t time out

Slide 20

Slide 20 text

Server
 timeouts

Slide 21

Slide 21 text

ListenAndServe in net/http doesn’t time out

Slide 22

Slide 22 text

A bit more about HTTP servers in Go

Slide 23

Slide 23 text

OS signals

Slide 24

Slide 24 text

A brief overview of OS signals KILL Handled by OS, kills the process STOP, CONT Handled by OS, pauses/resumes the process QUIT Sent by Ctrl + \, core dumps INFO Sent by Ctrl + T, process info PIPE Failed write to file descriptor INT Sent by Ctrl + C TERM Sent by kill

Slide 25

Slide 25 text

Cancellation

Slide 26

Slide 26 text

Cancellation isn’t just for servers

Slide 27

Slide 27 text

Recap • Client timeouts • Server timeouts • OS signals • Cancellation https://bit.ly/production-ready-go

Slide 28

Slide 28 text

Never start a goroutine without knowing how it will stop - Dave Cheney https://bit.ly/dave-cheney-goroutine

Slide 29

Slide 29 text

Never consume resources without knowing how you will free them - Me

Slide 30

Slide 30 text

Further reading • CloudFlare - So you want to expose Go on the internet
 https://bit.ly/cloudflare-expose-go
 • CloudImmunity - 50 shades of Go
 https://bit.ly/cloudimmunity-50-shades-of-go
 • spf13 - 7 common mistakes in Go
 https://bit.ly/spf13-common-mistakes-in-go

Slide 31

Slide 31 text

Thank you