26
Juju Google Go in a scalable Environment Frank Müller / Oldenburg / Germany

Juju - Google Go in a scalable Environment

Embed Size (px)

DESCRIPTION

Talk about Ubuntu Juju, a tool for the deployment and configuration of services in clouds and how Go helps to develop it.

Citation preview

Page 1: Juju - Google Go in a scalable Environment

Juju ‑ Google Go in a scalable Environment

Frank Müller / Oldenburg / Germany

Page 2: Juju - Google Go in a scalable Environment

Introduction

Frank Müller

Born 1965 in Oldenburg

SoftwareDevelopment

since 1984

Author since 1999

Book about Go in 2011

Page 3: Juju - Google Go in a scalable Environment

Well known scenario

Wordpress

MySQL

Page 4: Juju - Google Go in a scalable Environment

Different in clouds

Wordpress Wordpress

MySQL

Page 5: Juju - Google Go in a scalable Environment

Scaling means effort

Page 6: Juju - Google Go in a scalable Environment

Juju for provisioning

Amazon Web Services

OpenStack

LocalMAAS

Microsoft Azure

Page 7: Juju - Google Go in a scalable Environment

Create your environment

juju init -wjuju bootstrap

State

Page 8: Juju - Google Go in a scalable Environment

Add and relate services

State

juju deploy cs:precise/wordpressjuju deploy cs:precise/mysqljuju add-relation wordpress mysql

Wordpress

MySQL

Page 9: Juju - Google Go in a scalable Environment

Add another unit

State

Wordpress

MySQL

Wordpress

juju add-unit wordpress

Page 10: Juju - Google Go in a scalable Environment

Scale!

State

memcached

MySQL

Wordpress

juju add-unit -n2 wordpressjuju deploy memcachedjuju add-relation wordpress memcached

Page 11: Juju - Google Go in a scalable Environment

Also web UI available

Page 12: Juju - Google Go in a scalable Environment

Why Google Go?

Page 13: Juju - Google Go in a scalable Environment

Architectural insights

Page 14: Juju - Google Go in a scalable Environment

State - Watcher - Worker

State

Provisioner

Firewaller

Machiner

Deployer

Uniter

CollectionsIndividual ObjectsLifecycles

Client

Page 15: Juju - Google Go in a scalable Environment

Agent

Lots of concurrent work

State

Worker

Goroutine

Goroutine

Worker

Goroutine

Goroutine

Page 16: Juju - Google Go in a scalable Environment

Firewaller

State Main LoopEnvironment Configuration

Machines

machind Loop

Machine Units

unitd Loop

serviced Loop

Ports

Exposes

Page 17: Juju - Google Go in a scalable Environment

Goroutine control

Page 18: Juju - Google Go in a scalable Environment

Monitoring and stopping

• not part of the language spec• launchpad.net/tomb• signals to leave loops• wait until goroutine stopped• leave in case of an error• remember and retrieve that error

Page 19: Juju - Google Go in a scalable Environment

Loops with tomb

// loop processes ...func (t *T) loop() {

defer t.tomb.Done()for {

select {case <-t.tomb.Dying:

// Cleanup ...return

case f := <-t.fooChan:if err := t.foo(f); err != nil {

t.tomb.Kill(err)}

case b := <-t.barChan:// ...

}}

}

Page 20: Juju - Google Go in a scalable Environment

Stop and error handling

// Stop ends the main loop.func (t *T) Stop() error {

t.tomb.Kill(nil)return t.tomb.Wait()

}

// Err retrieves the error in case the backend loop died.func (t *T) Err() error {

return t.tomb.Err()}

Page 21: Juju - Google Go in a scalable Environment

Interfaces

Page 22: Juju - Google Go in a scalable Environment

Define behaviors

type StorageReader interface {Get(name string) (io.ReadCloser, error)List(prefix string) ([]string, error)URL(name) (string, error)

}

type StorageWriter interface {Put(name string, r io.Reader, length int64) errorRemove(name string) error

}

type Storage interface {StorageReaderStorageWriter

}

Page 23: Juju - Google Go in a scalable Environment

Like a toolbox

Storage

EC2

OpenStack

MAAS

Azure

DummyEnviron

Page 24: Juju - Google Go in a scalable Environment

Also help in tests

type Foo interface {DoThis(with That) error

}

type MyFoo struct { ... }

func (m *MyFoo) DoThis(with That) error { ... }

type MockFoo struct { ... }

func (m *MockFoo) DoThis(with That) error { ... }

func Bar(f Foo, t That) error {return f.DoThis(t)

}

Page 25: Juju - Google Go in a scalable Environment

What else?

• extreme fast builds• cross-compilation• binaries are simple to deploy• table-driven tests• benchmarks and race detection• go get always takes tip!

Page 26: Juju - Google Go in a scalable Environment

Questions?