Go Circuit: Distributing the Go Language and Runtime Petar Maymounkov [email protected]

Problem: DEV–OPS isolation

App complexity vs manual involvement Distribute cloud apps How to describe complex deploy topologies

Elastic apps

Job control Visibility into process ecosystem. Abstract “map” of available hosts.

Provision negotiation

Admin manual included? Yes. Not elastic then.

Cognitive load grows

Universal code format

Every app requires attention

Write once, run on any cluster Provides for cluster-specific operations

Adopt incrementally

Co-habitable, minimal Don’t solve any app problems Just abstract underlying capabilities

Too much humans in the stack. SaaS? NET

APP

APP MON

OS

DPLY CFG

HOST

FAIL BKP RPL

Key operations (like re-shard, replicate, etc.) should be in the app if you want consistency and automation

OS

DPLY CFG

HOST

FAIL BKP RPL

● Generic apps cannot provision hosts or self-deploy remotely ● Frameworks usually suffer: ○ Heavy-weight, cross-integration ○ External technologies (Catch 22)

True division of responsibilities

USER

APP

OPS–ENG Networking Job execution Hardware negotiation & provision

Solution concept

Overview Universal distribution format = Go source Open source executables Control app exposure to libraries Easy source-to-source transform for instrumentation Tiny source footprint for hard apps

OPS vs APP isolation OPS need not understand how app works (black box) OPS controls networking, execution, provisioning, failure response, etc.

Elementary to deploy Compile entire solution into one “smart” binary Deploy sloppily App self-organizes at runtime

Minimal Single System Image (MSSI) APP

SSI Interface OS HOST

Abstraction

Stack Level

Linux

POSIX

Binary

OpenSSI, etc. monolithic

POSIX

OS

Plan9 modular

File Protocol, 9P

Network

Erlang/OTP monolithic

CSP Functional Language

Language

Go Circuit modular minimal

CSP Imperative Language

Language

APP

OS HOST

OS HOST

Goal: Abstract away and standardize capabilities/resources and behaviors (failures) of system. Not: Conceal failures, add scheduling, provide reliability, etc. The circuit is just a tool for building reliable systems efficiently and portably.

Concurrency inside, concurrency outside Non-CSP

CSP

Protocols (DEV stack)

Sync Libraries

Lang

Framework Exec (OPS stack)

Thread Async Libraries

Lang

PROCESS

Comm “THREAD”

Go Language * No cognitive switch * Imperative * Meaningful stack traces * Debug, trace UI unchanged

Concurrent Sequentially-communicating Processes (CSP)

Solution stack

APP

MSSI Circuit Language ≈ Go Process Networking & Authentication Dial, Listen, Spawn, ...

OPS interacts only with CIRCUIT Debug, profile, trace, monitor, ...

CIRCUIT TRANSLATOR RUNTIME DRIVER

DRIVER

DRIVER

OS

OS

OS

HOST

HOST

HOST

OPS ENG

Solution translates language thru net

High-level Linguistic Communication

Low-level Networking ops

APP

APP

APP

CIR

CIR

CIR

DRIVER

DRIVER

DRIVER

OS

OS

OS

HOST

HOST

HOST

package main … import “circuit” … circuit.Spawn(…

package circuit … import “drv/n” import “drv/job” …

Example: Circuit + Docker = SSI Linux Legacy Linux binaries Within containers instrumented with consistent view of whole cluster

P

P

P

P

SSI Linux, POSIX, Plan9

APP

MSSI Circuit Language Process Networking & Authentication Dial, Listen, Spawn, ...

P

CIRCUIT TRANSLATOR RUNTIME DRIVER

DRIVER

DRIVER

OS

OS

OS

HOST

HOST

HOST

OPS ENG

Circuit Programming

Circuitizing a Go app and build Add circuit runtime to any legacy Go program package main import _ “circuit/load” func main() { … }

Build ~/gopath/src/app/cmd$ go build

Go + spawn = distributed Go Circuit

Go slow.host

HOST

PROCESS

WORKER

slow.host

GOROUTINE

GOROUTINE

Spawn Run a function in this process Compute(arg)

Run a function in a new process on a negotiated host Spawn( “locus”, []string{“/db/shard”, “/critical”}, SpawnCompute{}, arg, )

Declare spawn-able functions type SpawnCompute struct{} func (SpawnCompute) Compute(arg Arg) { … }

Anchor file system (side note) Global file system of live workers, arranged by the user $ 4ls /... / /critical /critical/R1a4124aa276f4a4e /db /db/shard /db/shard/R1a4124aa276f4a4e /db/shard/R8efd95a09bcde325

More on this later.

Spawn semantics Returns

RETURN VALUES

WORKER ADDRESS

ERROR

func Spawn( … ) ([]interface{}, n.Addr, error)

Worker dies as soon as function exits ... func (SpawnCompute) Compute(arg Arg) (r1, r2 ReturnType) { … return }

… unless, we defer its death to the end of another goroutine. func (SpawnCompute) Compute(arg Arg) { … ExitAfter(func() { … return }) … return }

Values vs cross-interfaces Communicate by value or cross-interface func Compute(int, Struct, *T, []byte, map[Key]Value, interface{}, X) … type T struct { Cross X Value float64 }

Create a cross-interface to a local receiver x := Ref(r)

Use a cross-interface: call its methods reply = x.Call(“MethodName”, arg1, arg2) // Returns []interface{}

Cross-worker garbage collection Cross-interfaces

Permanent cross-interfaces

func (SpawnCompute) Compute(X) (X, error) { … return Ref(v), nil }

func (SpawnCompute) Compute(XPerm) (XPerm, error) { … return PermRef(v), nil }

Spawn( “host”, nil, SpawnCompute{}, Ref(v), )

Spawn( “host”, nil, SpawnCompute{}, PermRef(v), )

Cross-call semantics Cross-calls are not RPC They return out-of-order, just like Go function calls do var x X // Cross-interface … go func() { ch <– x.Call(“Find”, “needle”) }() … go func() { ch <– x.Call(“Find”, “haystack”) }() … <–ch // Wait for whoever returns first …

Error propagation Retain natural method signature func (s *Server) ServeHTML(url string) (string, error) { … }

Decouple application and system errors at call site var x X // x is a cross-interface to a remote *Server instance … defer recover() // Catch system errors as panics … result := x.Call(“ServerHTML”, url) // Get app errors in return …

Worker services Expose a cross-interface to a worker object Listen(“ingest”, r)

Recall that spawn returns a worker address result, addr, err := Spawn(…)

Dial a worker and obtain an exposed cross-interface x := Dial(addr, “ingest”)

Circuit Architecture

The circuit translates import _ “circuit/load”

Go + Spawn

type S struct { A float64 B []X } func (R) F(s *S, x X) (X, error) { … return Ref(v), nil } … defer recover() result := x.Call(“F”, s1, y)

Network + Spawn Instructions

CIRCUIT

● ● ● ● ● ● ● ●

Reflect on in/out types of F Recurse within composite types to find all cross-interface fields Read input arguments Check type safety Dial remote worker address Encode and send cross-call request Read response or error etc.

Modules decouple. Universal code. OPS

APP DEV USER CODE

use/circuit

import ( “use/circuit” “use/afs” _ “load/petar” ) use/afs

load/petar

sys/lang import ( _ “sys/lang” _ “sys/zafs” )

sys/zafs

import ( “use/n” “use/afs” ) func init() { afs.Bind(…) }

CIRCUIT DEV

Circuit Facilities

Anchor FS + cli tools = debug, profile, … Global file system of live workers, arranged by the user $ 4ls /... / /critical /critical/R1a4124aa276f4a4e /db /db/shard /db/shard/R1a4124aa276f4a4e /db/shard/R8efd95a09bcde325

Kill

Stack traces

$ 4kill /critical/...

$ 4ls /db/shard/… | xargs 4stk

Profile for 30 sec

Monitor worker vitals (mem, cpu, …)

$ 4cpu /critical/… 30

$ 4top /critical/…

The end. Disclaimer. Talk describes soon-to-be-released R2. Skipped Teleport Transport. See github.com/petar/GoTeleport Twitter @gocircuit

gocircuit.org

Appendix

Historical perspective on CSP systems Servers + Hierarchy of exported channels

Cluster Level

Process Level

Plan9

Workers + Crossinterfaces

Interfaces are more general than channels. Channels are interfaces with Send and Receive.

Go Lang Goroutines + Channels

Go Circuit

Go Circuit - GitHub

OPS controls networking, execution, provisioning, failure response, etc. Elementary to deploy. Compile entire solution into one “smart” binary .... Worker services.

142KB Sizes 8 Downloads 230 Views

Recommend Documents

Go kit - GitHub
Go kit services must play nice With existing services. C. (l ... configuration. We'll work With whatever your organization prefers: flags, env vars, conf files - all OK.

Go Quick Reference Go Quick Reference Go Quick Reference - GitHub
Structure - Package package mylib func CallMeFromOutside. Format verbs. Simpler than Cās. MOAR TABLE package anothermain import (. "fmt". ) func main() {.

Getting Started with Go - GitHub
Jul 23, 2015 - The majority of my experience is in PHP. I ventured into Ruby, ... Compiled, Statically Typed, Concurrent, Imperative language. Originally ...

inside enclosure outside enclosure circuit board - GitHub
4A Battery Charger for 12V SLA. 120/240V AC. Input. Output. Charge Voltage. 2. 1. CONN3. 2. 1. CONN1. 2. 1. CONN2. Master Power Swtich inside enclosure.

Anonymous Go-Kart: Specification Report Supervisor - GitHub
May 9, 2011 - [email protected] (83238549). Wim Looman ... Department of Computer and Electrical Engineering. University of ... kart, so that it can be easily controlled by a laptop. The second is to ..... BostonDynamicsTRQ6Sep09.pdf.

Mariokart An Autonomous Go-Kart - GitHub
Mar 9, 2011 - Make a robust platform for future projects ... Nice hardware platform for future years. - Project almost stuck to time ... Automation Software. 45d.

〈q|pic〉: Quantum Circuit Diagrams in LATEX - GitHub
28. 5 qpic and LATEX. 28. 5.1 Include 〈q|pic〉 Diagrams as PDF Graphics in a LATEX File . ... A Python script, which we call1 qpic, parses .... Figure 3: Quantum Fourier transform on three bits: diagram and code. It is worth .... discarded. Line 9

Text Indexing for Go 1 February 2015 - GitHub
Feb 1, 2015 - NewSearchRequest(q) req.Highlight=bleve.NewHighlightWithStyle("html") req.Fields=[]string{"summary","speaker"} res,err:=index.Search(req).

Wake up! It's time for go to bed. - GitHub
Mining and finding out a simple recommendation system or vague relation a. No good way to validate the algorithm b. Nice idea but Too Classic. 2. Make sense ...

Fourth Circuit
5 days ago - plaintiffs' 'claims are of the type Congress intended to be reviewed within this statutory structure.'” Id. (quoting Thunder Basin, 510 U.S. at 212).

Output buffer circuit and integrated semiconductor circuit device with ...
May 16, 2007 - main driver has at least a pair of a ?rst p-channel MOS transistor and a ?rst n-channel MOS transistor for driving a load according to the data, ...

A Circuit Representation Technique for Automated Circuit Design
automated design, analog circuit synthesis, genetic algorithms, circuit .... engineering workstations (1996 Sun Ultra), we present evolved circuit solutions to four.

Circuit Design
what is at the circuit level (Part I) versus what is at the system level (Part II). The foundations ..... Random number generator plus SSD (problem 9.8). ROM (problem ...... TYPE matrix IS ARRAY (0 TO 3) OF STD_LOGIC_VECTOR(7 DOWNTO 0);.

A circuit is constructed with six resistors and two batteries as ... - GitHub
A circuit is constructed with six resistors and two batteries as shown. The battery voltages are V1 = 18 V and V2 = 12 V. The positive terminals are indicated with ...

Go santa go
Journey to Destruction in Steinbeck's Flightand London's To Build a Fire. Notmany people haveto face death in thecold ... Biology pdf 2015.Howdo they do its10e17.Go santa go.Usatop 40 single. charts.American black cop.3.3.5 no install.61) Fortunately

Circuit Theory.pdf
Section 6 3-Phase Power 85. 3-Phase Transmission 85. Section 7 Two Port Networks (Proposed) 87. Two Port Networks 87. Appendices 91. Circuit Functions 91. Phasor Arithmetic 92. Decibels 94. Transform Tables 96. Circuit Elements 99. Resources 99. Refe

Semiconductor integrated circuit
Dec 29, 2011 - layout design When arranging switches in a poWer lines for preventing ..... becomes high, and automatic design of the layout by the CAD.

My go go
Kikiminajmaid.Theadventure of puss boots.The. legend ofzeldatwilight princess. ... go.One piece 607 [email protected] 2013 pdf.SECRETS OF THEBIBLE ...

GitHub
domain = meq.domain(10,20,0,10); cells = meq.cells(domain,num_freq=200, num_time=100); ...... This is now contaminator-free. – Observe the ghosts. Optional ...