Slide 1

Slide 1 text

Go for speed

Slide 2

Slide 2 text

Nick Bruun github.com/nickbruun @nickbruun bruun.co CTO @ Iconfinder Fairly carnivorous

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

Trouble in icon paradise

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

41 ms average response time from Django application during peak hours

Slide 12

Slide 12 text

~2,000 ms wasted per search

Slide 13

Slide 13 text

Perceivably slower

Slide 14

Slide 14 text

The internals

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Icon ID Icon version ID Raster size https://www.iconfinder.com/icons/298255/677266/128/raster https://cdn0.iconfinder.com/data/icons/seo-smart-pack/128/ grey_new_seo2-43-128.png Public raster URL Protected raster URL

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Constant

Slide 19

Slide 19 text

Signing requests

Slide 20

Slide 20 text

https://www.iconfinder.com/icons/298255/677266/128/raster?token=…

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

we know if the user has access right now When returning the link,

Slide 23

Slide 23 text

we know if the user has access right now When returning the link,

Slide 24

Slide 24 text

We’re okay with “right now” being an approximation

Slide 25

Slide 25 text

Time limited token

Slide 26

Slide 26 text

= "---"

Slide 27

Slide 27 text

= "---" = hmac_sha1(, )

Slide 28

Slide 28 text

= "---" = hmac_sha1(, ) = "--base64()"

Slide 29

Slide 29 text

But, who checks the token?

Slide 30

Slide 30 text

Enter Go The World’s least Google-able language… from Google

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Why Go?

Slide 33

Slide 33 text

Networked service

Slide 34

Slide 34 text

Highly concurrent ~3,000 requests/second from 100 connections/core

Slide 35

Slide 35 text

Low memory footprint 14.09 MiB after 21 days

Slide 36

Slide 36 text

Low CPU usage

Slide 37

Slide 37 text

Static binary Cross-compilation = deployment heaven

Slide 38

Slide 38 text

Less decisions to make

Slide 39

Slide 39 text

Caveats

Slide 40

Slide 40 text

Structured logging

Slide 41

Slide 41 text

DIY

Slide 42

Slide 42 text

Mature runtime != Mature language

Slide 43

Slide 43 text

Conciseness 608 lines of code

Slide 44

Slide 44 text

The end result

Slide 45

Slide 45 text

1.2 ms average response time at peak hours

Slide 46

Slide 46 text

0.1 % CPU usage at peak hours

Slide 47

Slide 47 text

Go is awesome

Slide 48

Slide 48 text

Go is awesome for simple services

Slide 49

Slide 49 text

Go is a trade-off

Slide 50

Slide 50 text

Go is a trade-off – choose wisely

Slide 51

Slide 51 text

return