Go Language for Ops and Site Reliability Engineering

Gustavo Franco

Site Reliability Engineer, Google

Operations vs Site Reliability Engineering

Operations

Site Reliability Engineering

Go Programming Language

"Go is an open source programming environment that makes it easy to build simple,
reliable, and efficient software." -- golang.org

Hello OSCON

package main

import (
    "flag"
    "fmt"
)

var message = flag.String("message", "Hello, OSCON!", "what to say")

func main() {
    flag.Parse()
    fmt.Println(*message)
}
$ go run hello.go -help
Usage of /tmp/go-build212699297/command-line-arguments/_obj/a.out:
  -message="Hello, OSCON!": what to say
exit status 2

Programming for SRE and Ops - State of the Union

Programming for SRE and Ops - Where do we go?

Agenda

Why Go for Ops and SRE? Simple, reliable and efficient

Why Go for Ops and SRE? Simple, reliable and efficient

Why Go for Ops and SRE? Standard library examples

godoc.org to your needs beyond the standard library

Why Go for Ops and SRE? Concurrency via Goroutines

package main

import (
    "fmt"
    "time"
)

func main() {
    go say("ho!", 2*time.Second)  // &
    go say("hey!", 1*time.Second) // &

    // Make main sleep for 4 seconds so goroutines can finish
    time.Sleep(4 * time.Second)
}

// say prints text after sleeping for X secs
func say(text string, secs time.Duration) {
    time.Sleep(secs)
    fmt.Println(text)
}

Why Go for Ops and SRE? Concurrency and Channels

// +build OMIT

package main

import (
	"fmt"
	"time"
)

func main() {
    textChannel := make(chan string)
    words := []string{"ho!", "hey!"}
    secs := []int{2, 1}
    // Create a goroutine per word
    for i, word := range words {
        go say(word, secs[i], textChannel) // &
    }
    // Wait for response via channel N times
    for _ = range words {
        fmt.Println(<-textChannel)
    }
}

// say sends word back via channel after sleeping for X secs
func say(word string, secs int, textChannel chan string) {
    time.Sleep(time.Duration(secs) * time.Second)
    textChannel <- word
}

Go features

Go grows with you - see interfaces and reflection

Go in production at Google

dl.google.com - OSCON talk by Brad Fitzpatrick Friday, 10:00am

vtocc: front-end to MySQL that improves scalability
Whitebox monitoring data from logs to a timeseries database
Command line library for Go

Machine lifecycle management

via App Engine

Go in production outside Google

Unix-like pipelines for Go
Inter host Goroutines
Service orchestration management tool
Containers management tool
Tool for creating identical machine images for multiple platforms

Q&A

Take the tour - [[tour.golang.org]]

Thank you

Gustavo Franco

Site Reliability Engineer, Google

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)