Slide 1

Slide 1 text

Go @ Skimlinks Blood, sweat and code.

Slide 2

Slide 2 text

Who is this guy anyway? Richard Johnson @rjohnsondev github.com/rjohnsondev Lead Engineer, Skimlinks

Slide 3

Slide 3 text

Skimlinks ● I joined almost 2 years ago ● We had poor server utilisation! ○ Memory constrained PHP under apache prefork ● Wanted to move onto something else ○ Cue language war ○ Cue Bake-off: http://blog.skimlinks.com/2012/03/15/api-programming-language-bake-off/

Slide 4

Slide 4 text

● Go sucked. ○ Why? ■ Early revision? ■ I coded it wrong? ● Scala rocked ○ Why? ■ JVM? ■ I probably coded it wrong ● We chose Python & Tornado. ● ... and I never looked at Go again. Results....

Slide 5

Slide 5 text

Enter Skimwords! ● Acquired NLP tech from a startup in the US ● Mostly written in C (!) ● During review I noticed a potential algorithm improvement! ○ Mocked it up in my own time using Go ■ Needed to be fast & low-level (replacing C) ■ No concurrency requirements (unlike APIs) ○ Results were so compelling I presented them to management ● We halved our Skimwords server costs.

Slide 6

Slide 6 text

But still challenges... ● The C code was complex, brittle and difficult ● Business requirements: ○ Better phrase generation with different "engines" ■ Hired a new NLP & AI wizard (Ian) ○ Formalise assessment of phrases & matching ● Everything was pointing to us needing to split up our system into smaller components

Slide 7

Slide 7 text

... so we did ● Re-implemented logical components in Go ● ZMQ over IPC as communication layer ○ Decent Go bindings (for ZMQ == 2.2) ● JSON & go types as protocol ○ Lovely native marshalling ● Still needed some external C libraries ○ C? Go? CGo... well... go! ○ Snowball stemmer ○ Judy Arrays

Slide 8

Slide 8 text

also ... ● We run everything under supervisord ○ Just really convenient ● RPM packaged binaries ○ Single, portable binaries FTW! ● Puppet based deploys ● EC2 cloud infrastructure ● It just works!

Slide 9

Slide 9 text

... ● BTW, I created a little vim compiler plugin...

Slide 10

Slide 10 text

A couple of months later... ● 30% speed increase ● Fixed a lot of difficult C heisenbugs ● Better precision ● QA gave it the all clear ● Turned it on for 10% of traffic. ○ Disaster!!!! ○ After about 3 mins, stack would freeze for about 3 seconds, causing requests to timeout and upstream services to become overloaded.

Slide 11

Slide 11 text

WTF??!!!!????* ● Our product index contained about 50 million objects & 14GB RAM ● Go 1.0 garbage collection ○ Mark & Sweep all objects ○ STOPS THE WORLD! ● Moved objects into C with CGo ○ No more sweeps ○ Reduced memory usage by about 3GB ● Stopped using runtime.SetFinalizer ○ Freeing memory as we went made things less jerky

Slide 12

Slide 12 text

Disaster! (part 2) ● We increased our index size by a third. ● Started getting errors: "out of memory" ● Oh, Go programs can't be > 16GB ○ Oh, right, fine.... hang on, wat??? ● Started running patched Go in production! ○ Really, really, really bad idea. ○ Got away with it (most memory was unmanaged) ● Thankfully, 1.1 was in beta, no memory limit! ○ Started running that, which rapidly evolved to 1.1 ○ Faster as well!

Slide 13

Slide 13 text

Disaster! (part 3) ● Code stopped compiling!! ● Worked fine locally, but not on Jenkins! ● Libraries changed under our feet! ○ "go get" is cute and all, but: ○ Go builds libraries once & keeps locally! ● Easy fixes (thankfully) ● Fork your libraries!!

Slide 14

Slide 14 text

The story at present... ● We've been using Go in production for almost a year (alongside C stack) ● Complete Go (with some python) stack live for 3 months. ● IMHO is Go a production ready language? ○ Yes! Well... Mostly ■ GC still warrants some improvement ■ Most libraries are "hobby" projects, expect to pick up some maintenance effort

Slide 15

Slide 15 text

What's next for us? ● Error tracking and reporting ○ Log4go -> Raven Go -> Sentry ■ Still some issues to resolve with high volumes ○ http://riemann.io/ for stats! ■ Seems to work well, live over UDP on all boxes ● More improvements! ○ Incorporation of user intent values ○ Pluggable & A/B tested product relevance algorithms

Slide 16

Slide 16 text

Other questions? Richard Johnson @rjohnsondev http://github.com/rjohnsondev Lead Engineer, Skimlinks Quick shout-out to http://apiaxle.com/