A look at a use case for Go at Iconfinder, which shaved ~40 ms off asset load times.
Go for speed
View Slide
Nick Bruungithub.com/nickbruun@nickbruunbruun.coCTO @ IconfinderFairly carnivorous
Trouble in icon paradise
41 msaverage response time from Django applicationduring peak hours
~2,000 mswasted per search
Perceivably slower
The internals
Icon IDIcon version IDRaster sizehttps://www.iconfinder.com/icons/298255/677266/128/rasterhttps://cdn0.iconfinder.com/data/icons/seo-smart-pack/128/grey_new_seo2-43-128.pngPublic raster URLProtected raster URL
Constant
Signing requests
https://www.iconfinder.com/icons/298255/677266/128/raster?token=…
we know if the user has access right nowWhen returning the link,
We’re okay with “right now”being an approximation
Time limited token
= "---"
= "---" = hmac_sha1(, )
= "---" = hmac_sha1(, ) = "--base64()"
But, who checks the token?
Enter GoThe World’s least Google-able language… from Google
Why Go?
Networked service
Highly concurrent~3,000 requests/second from 100 connections/core
Low memory footprint14.09 MiB after 21 days
Low CPU usage
Static binaryCross-compilation = deployment heaven
Less decisions to make
Caveats
Structured logging
DIY
Mature runtime!=Mature language
Conciseness608 lines of code
The end result
1.2 msaverage response time at peak hours
0.1 %CPU usage at peak hours
Go is awesome
Go is awesome for simple services
Go is a trade-off
Go is a trade-off – choose wisely
return