Juju - Google Go in a scalable Environment

2,174 views

Published on

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

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,174
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Juju - Google Go in a scalable Environment

  1. 1. Juju ‑ Google Go in a scalable Environment Frank Müller / Oldenburg / Germany
  2. 2. Introduction Frank Müller Born 1965 in Oldenburg Software Development since 1984 Author since 1999 Book about Go in 2011
  3. 3. Well known scenario Wordpress MySQL
  4. 4. Different in clouds Wordpress Wordpress MySQL
  5. 5. Scaling means effort
  6. 6. Juju for provisioning Amazon Web Services OpenStack Local MAAS Microsoft Azure
  7. 7. Create your environment juju init -w juju bootstrap State
  8. 8. Add and relate services State juju deploy cs:precise/wordpress juju deploy cs:precise/mysql juju add-relation wordpress mysql Wordpress MySQL
  9. 9. Add another unit State Wordpress MySQL Wordpress juju add-unit wordpress
  10. 10. Scale! State memcached MySQL Wordpress juju add-unit -n2 wordpress juju deploy memcached juju add-relation wordpress memcached
  11. 11. Also web UI available
  12. 12. Why Google Go?
  13. 13. Architectural insights
  14. 14. State - Watcher - Worker State Provisioner Firewaller Machiner Deployer Uniter Collections Individual Objects Lifecycles Client
  15. 15. Agent Lots of concurrent work State Worker Goroutine Goroutine Worker Goroutine Goroutine
  16. 16. Firewaller State Main Loop Environment Configuration Machines machind Loop Machine Units unitd Loop serviced Loop Ports Exposes
  17. 17. Goroutine control
  18. 18. 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
  19. 19. 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: // ... } } }
  20. 20. 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() }
  21. 21. Interfaces
  22. 22. 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) error Remove(name string) error } type Storage interface { StorageReader StorageWriter }
  23. 23. Like a toolbox Storage EC2 OpenStack MAAS Azure DummyEnviron
  24. 24. 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) }
  25. 25. What else? • extreme fast builds • cross-compilation • binaries are simple to deploy • table-driven tests • benchmarks and race detection • go get always takes tip!
  26. 26. Questions?

×