Go Language for Ops and Site Reliability Engineering

Gustavo Franco

Site Reliability Engineer, Google

Operations vs Site Reliability Engineering

Operations

Site Reliability Engineering

2

Go Programming Language

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

3

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
4

Programming for SRE and Ops - State of the Union

5

Programming for SRE and Ops - Where do we go?

6

Agenda

7

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

8

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

9

Why Go for Ops and SRE? Standard library examples

pkg.go.dev to your needs beyond the standard library

10

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)
}
11

Why Go for Ops and SRE? Concurrency and Channels

// +build ignore,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
}
12

Go features

Go grows with you - see interfaces and reflection

13

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

14

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
15

Q&A

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

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.)