Let's GO


Scale Backend Service Development in Go




kevin@freshbooks.com

Agenda


  • Current State of FB backend services
  • Scalability Challenges
  • Where Dynamic Languages Fall Short
  • Go: A New Kind of Static Language
  • How Go helps us scale
  • Where to GO from here

Agenda


  • Current State of FB backend services
  • Scalability Challenges
  • Dynamic vs Static
  • How Go helps us scale
  • Where to GO from here

Agenda


  • Current State of FB backend services
  • Scalability Challenges
  • Dynamic vs Static
  • How Go helps us scale
  • Where to GO from here





Scalability Challenges

Performance


Development




  • Larger Code Base
  • Order of Magnitude More Devs

Benefits of Dynamic Languages


  • More Products Faster Initially
  • Expressive , Convenient , "Fun" 

Dynamic Language


Where Do They Fall Short

  • Much harder to reason about code
  • Dynamic type = hard to optimize
  • Interpreted = overhead
  • JIT not always applicable

Dynamic Language


The techniques you use to build a hut is not the same technique you use to build the skyscraper
- Joshua Bloch

GO Static?


"Dark Ages?"
 public static void main(String[] argv)
 protected <T extends CWBaseModel, S extends GridPresenter.Display<T>, Q extends GridPresenter<T, S>> void doBindGridPresenter(final Q p) {
  ...
}

GO Static


Fewer Ceremonies


  • Type inferencing
  • Small set of features

GO Static


Batteries Included


  • Large standard library
    • net/http
    • logging
    • crypto
  • Beloved everyday data structures
    • map
    • slice
  • Built-in concurrency primitives
    • channel
    • goroutine
  • Garbage-collected

GO Static


Interfaces


type Duck interface {
  Quack()
}
type Duckula struct {}
func (d Duckula) Quack() {...}
type Donald struct {}
func (d Donald) Quack() {...}
func QuackTogether(ducks []Duck) {
  for _, duck := range ducks {
    duck.Quack()
  }
}


GO Static


Don't Inherit, Embed


GO Static


Errors Ain't Exceptions


  • Put more thoughts into dealing with errors
  • panic/recover for true exceptions

Scaling Backend Dev


Removes bikeshedding


go fmt

Scaling Backend Dev


Type-Checking and Code Reasoning


  • Explicit Contracts
  • Reveal bugs early
  • Maintainability for large code base & dev team

Scaling Backend Dev


Simple Deployment


  • RVM/Rake?
  • Virtualenv, setuptools, pip, distutils?
  • Move binary to the server, use process mgmt
    • systemd, upstart, supervisord, etc

Scale Backend Dev


Near Metal Performance


  • Compiles to platform-specific MC
    • Interpreter process
    • Shared library loading
    • Virtual machine
  • [chart]

We're Not Alone


  • Google
  • YouTube
  • Docker
  • Heroku
  • SoundCloud
  • Disqus
  • Cloudflare

Where To GO From Here?



let's go

By Kevin Jing Qiu

let's go

  • 941