SlideShare a Scribd company logo
Go Synchronized
Andrej Vckovski
What I want to transmit

 Go is useful and neat for heavily
concurrent applications
 Webrockets socks!

Go synchronized

2
A small poll

Point your [smartphone] browser to

nca.me/l
Go synchronized

3
nca.me/l

Go synchronized

4
nca.me/l

Go synchronized

5
About go
 Started by Robert Griesemer, Rob Pike and Ken
Thompson in Fall 2007,
Open-sourced 2009, Go 1 March 2012
 Main features

– C/Pascal/Modula-like, garbage collected, no pointer
arithmetics, type safe, very fast compiler
– Simple type system without hierarchies
– Concepts for concurrent programming in the “CSP”-style
– Embeds dependency management
– Today about similar memory/execution-performance as
Java or Node.

Go synchronized

6
Concurrency?
 Separate, potentially simultaneously executed
computations
 Usually somehow interacting
 Candidates to leverage multi-{core|cpu|node}
environments
 Usually but not necessarily correspond to multiple users
 Often on the server side
And hard to make it right
Go synchronized

7
Go and concurrency
Communicating Sequential Processes (CSP) pattern
(C. A. R. Hoare, 1978)
1. Channels
2. Go-routines
3. select-statement

“Do not communicate by sharing memory;
instead, share memory by communicating”
Occam, Erlang, Newsqueak, Limbo, Clojure and many more
Go synchronized

8
Example
package main
import ("fmt"; "time"; "math/rand")
func main() {
table := make(chan string)
for _, player := range [...]string{"alice", "bob"} {
go func(who string) {
num := 0;
for {
ball := <- table;
fmt.Printf("player %s: %sn", who, ball)
table <- fmt.Sprintf("tick-%s-%d",who,num)
time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000)))
num++
}
}(player)
}
table <- "go"
time.Sleep(10 * time.Second)
}

Go synchronized

9
The application:
Very Instant Massive (Audience) Polling
 Presentations
like this one
 TV shows with
added
interactivity
 Pause
entertainment in
a stadium
 Flipped
Classrooms
Go synchronized

© Nhenze

© Chris Lawrence

© Loozrboy

© Jeff Chenqinyi

10
Browser
JS
that
displays
questions
and
allows
voting

System context

go

Browser
JS
that
displays
questions
and
allows
voting

ipoll
server

Presentation Software (e.g., PowerPoint)

JS
Browser
JS
that
displays
questions
and
allows
voting

Go synchronized

Browser that displays
voting results

11
Browser
JS
that
displays
questions
and
allows
voting

WebSockets

go

 Full-duplex conversation
ipoll
over TCP connectionserver
 JS
RFC 6455
 Available in most modern
browsers
 Simple JavaScript binding
JS
 Handshake by HTTP then
,
user-defined messages over
the same socket

Client
(Browser)
HTTP GET Request,
special attributes
HTTP response
“switch protocol”

Browser
that
displays
questions
and
allows
voting

Browser
that
displays
questions
and
allows
voting

Go synchronized

Server

Message

Presentation Software (e.g., PowerPoint)

JS

Message
Message
Browser that displays
voting results
Message

Message
12
Multiplexer
and
Demultiplexer

Browser
that
displays
questions
and
allows
voting

Browser
that
displays
questions
and
allows
voting

Browser
that
displays
questions
and
allows
voting

Go synchronized

ipoll
server

Presentation Software (e.g., PowerPoint)

Browser that displays
voting results

13
Small Demo

Point your smartphone browser to

nca.me/l
Go synchronized

14
Demo: New Question 1

nca.me/l
Go synchronized

15
Demo: New Question 2

nca.me/l
Go synchronized

16
Demo: New Question 3

nca.me/l
Go synchronized

17
WebSocket on server side (go)
func startWebserver() {
// [...]

http.HandleFunc("/svy", surveyHandler)
}

Go

// [...]

func surveyHandler(c http.ResponseWriter, req *http.Request) {
// [...]
go websocket.Handler(func (ws *websocket.Conn) { s.VoterHandler(ws)} ).ServeHTTP(c, req)
// [...]
}
func (s *Survey) VoterHandler(ws *websocket.Conn) {
defer func() {
s.voterChan <- voter{ws, false}
log.Printf("connection closed by client")
ws.Close()
}()
s.voterChan <- voter{ws, true} // notify hub of a new voter
for {
// [...]
len, err := ws.Read(buf)
// [...]
var v vote
err = json.Unmarshal(buf, &v)
if err == nil {
s.voteChan <- v
} else {
// [...]
}
}
synchronized
}

18
Core data massaged at a single place:
The “model” implements an event-loop
func (s *Survey) surveyHub() {
// [...]
t := time.NewTicker(100 * time.Millisecond)
// [...]
for {
select {
case _ = <-t.C: // tick arrived
// [...]
case ctrl := <-s.controlChan: // control message
// [...]
case voter := <-s.voterChan: // voter subscribed
// [...]
case viewer := <-s.viewerChan: // viewer subscribed
// [...]
case admin := <-s.adminChan: // admin subscribed
// [...]
case vote := <-s.voteChan: // a vote arrived
// [...]
}
}
}

19
Conclusions

 Go (or “CSP”-design) has massively
simplified the concurrency challenges
 WebSockets are easy to use and will be
increasingly popular

Go synchronized

20
http://golang.org
Rob Pike on “concurrency is not parallelism”:
http://vimeo.com/49718712
(mascot by Renée French)
Bonus poll

Go synchronized

nca.me/l

22
Thanks for the attention!
andrej.vckovski@netcetera.com
netcetera.com
ipoll.ch
(coming soon)

More Related Content

What's hot

Fscons future transports
Fscons future transportsFscons future transports
Fscons future transports
Daniel Stenberg
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on RailsFramgia Vietnam
 
internet programming and java notes 5th sem mca
internet programming and java notes 5th sem mcainternet programming and java notes 5th sem mca
internet programming and java notes 5th sem mcaRenu Thakur
 
Web Sockets - HTML5
Web Sockets - HTML5Web Sockets - HTML5
Web Sockets - HTML5
Matheus Marabesi
 
What Could Microsoft Do To Make PHP Run Better On Windows
What Could Microsoft Do To Make PHP Run Better On WindowsWhat Could Microsoft Do To Make PHP Run Better On Windows
What Could Microsoft Do To Make PHP Run Better On Windows
Manuel Lemos
 
All Aboard The Stateful Train
All Aboard The Stateful TrainAll Aboard The Stateful Train
All Aboard The Stateful Train
SmartLogic
 
Resource Prioritization
Resource PrioritizationResource Prioritization
Resource Prioritization
Patrick Meenan
 
Ajax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage DownloadAjax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage Download
Eshan Mudwel
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
fbenault
 

What's hot (9)

Fscons future transports
Fscons future transportsFscons future transports
Fscons future transports
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on Rails
 
internet programming and java notes 5th sem mca
internet programming and java notes 5th sem mcainternet programming and java notes 5th sem mca
internet programming and java notes 5th sem mca
 
Web Sockets - HTML5
Web Sockets - HTML5Web Sockets - HTML5
Web Sockets - HTML5
 
What Could Microsoft Do To Make PHP Run Better On Windows
What Could Microsoft Do To Make PHP Run Better On WindowsWhat Could Microsoft Do To Make PHP Run Better On Windows
What Could Microsoft Do To Make PHP Run Better On Windows
 
All Aboard The Stateful Train
All Aboard The Stateful TrainAll Aboard The Stateful Train
All Aboard The Stateful Train
 
Resource Prioritization
Resource PrioritizationResource Prioritization
Resource Prioritization
 
Ajax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage DownloadAjax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage Download
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 

Viewers also liked

Resume_Mounika_Transcriptionist
Resume_Mounika_TranscriptionistResume_Mounika_Transcriptionist
Resume_Mounika_TranscriptionistMounika Doolam
 
便宜又便利的工作室出租
便宜又便利的工作室出租便宜又便利的工作室出租
便宜又便利的工作室出租
收多易迷你倉庫
 
Ab0401 e learning sharon,may,mirnawaty,bi jun,linda
Ab0401  e learning sharon,may,mirnawaty,bi jun,lindaAb0401  e learning sharon,may,mirnawaty,bi jun,linda
Ab0401 e learning sharon,may,mirnawaty,bi jun,lindaNBS
 
Brosjyre - Lindesnes fyr - Norge
Brosjyre - Lindesnes fyr  - NorgeBrosjyre - Lindesnes fyr  - Norge
Brosjyre - Lindesnes fyr - Norge
LindesnesFyr
 
Green Grass ppt template
Green Grass ppt templateGreen Grass ppt template
Green Grass ppt template
teodorszasz
 
You Talking to me? Dwustronna komunikacja w Social Media.
You Talking to me? Dwustronna komunikacja w Social Media.You Talking to me? Dwustronna komunikacja w Social Media.
You Talking to me? Dwustronna komunikacja w Social Media.
Michal Kowalik
 
Textual strategies Plastic Tactics - Kendall R. Philips
Textual strategies Plastic Tactics - Kendall R. PhilipsTextual strategies Plastic Tactics - Kendall R. Philips
Textual strategies Plastic Tactics - Kendall R. Philips
Burak Taşdizen
 
m. fagaras
m. fagarasm. fagaras
m. fagaras
tearox
 
Herpes Healing
Herpes HealingHerpes Healing
Herpes Healingbullandhe
 
Rpp kelas 4 2013
Rpp kelas 4 2013Rpp kelas 4 2013
Rpp kelas 4 2013yudiyunika
 
Recruit presenter 2013
Recruit presenter 2013Recruit presenter 2013
Recruit presenter 2013mwappett
 
Presentacion de andrea internet
Presentacion de andrea internetPresentacion de andrea internet
Presentacion de andrea internet
lmabaldovinon
 
информатика в лицах
информатика в лицахинформатика в лицах
информатика в лицахzupar
 

Viewers also liked (15)

Resume_Mounika_Transcriptionist
Resume_Mounika_TranscriptionistResume_Mounika_Transcriptionist
Resume_Mounika_Transcriptionist
 
便宜又便利的工作室出租
便宜又便利的工作室出租便宜又便利的工作室出租
便宜又便利的工作室出租
 
MY_UPDATED_RESUME
MY_UPDATED_RESUMEMY_UPDATED_RESUME
MY_UPDATED_RESUME
 
Ab0401 e learning sharon,may,mirnawaty,bi jun,linda
Ab0401  e learning sharon,may,mirnawaty,bi jun,lindaAb0401  e learning sharon,may,mirnawaty,bi jun,linda
Ab0401 e learning sharon,may,mirnawaty,bi jun,linda
 
Brosjyre - Lindesnes fyr - Norge
Brosjyre - Lindesnes fyr  - NorgeBrosjyre - Lindesnes fyr  - Norge
Brosjyre - Lindesnes fyr - Norge
 
Green Grass ppt template
Green Grass ppt templateGreen Grass ppt template
Green Grass ppt template
 
You Talking to me? Dwustronna komunikacja w Social Media.
You Talking to me? Dwustronna komunikacja w Social Media.You Talking to me? Dwustronna komunikacja w Social Media.
You Talking to me? Dwustronna komunikacja w Social Media.
 
Textual strategies Plastic Tactics - Kendall R. Philips
Textual strategies Plastic Tactics - Kendall R. PhilipsTextual strategies Plastic Tactics - Kendall R. Philips
Textual strategies Plastic Tactics - Kendall R. Philips
 
MATRIC
MATRICMATRIC
MATRIC
 
m. fagaras
m. fagarasm. fagaras
m. fagaras
 
Herpes Healing
Herpes HealingHerpes Healing
Herpes Healing
 
Rpp kelas 4 2013
Rpp kelas 4 2013Rpp kelas 4 2013
Rpp kelas 4 2013
 
Recruit presenter 2013
Recruit presenter 2013Recruit presenter 2013
Recruit presenter 2013
 
Presentacion de andrea internet
Presentacion de andrea internetPresentacion de andrea internet
Presentacion de andrea internet
 
информатика в лицах
информатика в лицахинформатика в лицах
информатика в лицах
 

Similar to JAZOON'13 - Andrej Vckovski - Go synchronized

LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :)
Sascha Sambale
 
NodeJS
NodeJSNodeJS
Real time web
Real time webReal time web
Real time web
Medhat Dawoud
 
Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the restgeorge.james
 
Beyond Java: Go for Java developers
Beyond Java: Go for Java developersBeyond Java: Go for Java developers
Beyond Java: Go for Java developers
Netcetera
 
150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs
Netcetera
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN StackRob Davarnia
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassSpike Brehm
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
zonathen
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript Frameworks
Christian Gaetano
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
JohnTaieb
 
WEB BROWSER
WEB BROWSERWEB BROWSER
WEB BROWSER
Chanchal Pawar
 
Coffee script throwdown
Coffee script throwdownCoffee script throwdown
Coffee script throwdown
Nicholas McClay
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
Stefano Di Paola
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of Technologies
Chris Mitchell
 
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous  Blocking or synchronous.pdfNode Js Non-blocking or asynchronous  Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
DarshanaMallick
 
Meetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech PeopleMeetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech People
IT Arena
 
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R..."Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
Fwdays
 
Would Mr. Spok choose Open Source
Would Mr. Spok choose Open SourceWould Mr. Spok choose Open Source
Would Mr. Spok choose Open Source
vlcinsky
 

Similar to JAZOON'13 - Andrej Vckovski - Go synchronized (20)

LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :)
 
NodeJS
NodeJSNodeJS
NodeJS
 
Real time web
Real time webReal time web
Real time web
 
Proposal
ProposalProposal
Proposal
 
Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the rest
 
Beyond Java: Go for Java developers
Beyond Java: Go for Java developersBeyond Java: Go for Java developers
Beyond Java: Go for Java developers
 
150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master Class
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript Frameworks
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
 
WEB BROWSER
WEB BROWSERWEB BROWSER
WEB BROWSER
 
Coffee script throwdown
Coffee script throwdownCoffee script throwdown
Coffee script throwdown
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of Technologies
 
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous  Blocking or synchronous.pdfNode Js Non-blocking or asynchronous  Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
 
Meetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech PeopleMeetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech People
 
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R..."Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
 
Would Mr. Spok choose Open Source
Would Mr. Spok choose Open SourceWould Mr. Spok choose Open Source
Would Mr. Spok choose Open Source
 

More from jazoon13

JAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The WorldJAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The World
jazoon13
 
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User StoriesJAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Storiesjazoon13
 
JAZOON'13 - Bartosz Majsak - Git Workshop - Kung Fu
JAZOON'13 - Bartosz Majsak - Git Workshop - Kung FuJAZOON'13 - Bartosz Majsak - Git Workshop - Kung Fu
JAZOON'13 - Bartosz Majsak - Git Workshop - Kung Fu
jazoon13
 
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -EssentialsJAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
jazoon13
 
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScriptJAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
jazoon13
 
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone beforeJAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone beforejazoon13
 
JAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled JavaJAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled Javajazoon13
 
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software DevelopmentJAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Developmentjazoon13
 
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...jazoon13
 
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed TeamsJAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teamsjazoon13
 
JAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop IntegrationJAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop Integrationjazoon13
 
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next GenerationJAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generationjazoon13
 
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In RealtimeJAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
jazoon13
 
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experienceJAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
jazoon13
 
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !jazoon13
 
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling SoftwareJAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Softwarejazoon13
 
JAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great MigrationJAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great Migration
jazoon13
 
JAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git WorkflowsJAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git Workflowsjazoon13
 

More from jazoon13 (18)

JAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The WorldJAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The World
 
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User StoriesJAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
 
JAZOON'13 - Bartosz Majsak - Git Workshop - Kung Fu
JAZOON'13 - Bartosz Majsak - Git Workshop - Kung FuJAZOON'13 - Bartosz Majsak - Git Workshop - Kung Fu
JAZOON'13 - Bartosz Majsak - Git Workshop - Kung Fu
 
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -EssentialsJAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
 
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScriptJAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
 
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone beforeJAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
 
JAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled JavaJAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled Java
 
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software DevelopmentJAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
 
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
 
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed TeamsJAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
 
JAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop IntegrationJAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop Integration
 
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next GenerationJAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
 
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In RealtimeJAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
 
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experienceJAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
 
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
 
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling SoftwareJAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
 
JAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great MigrationJAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great Migration
 
JAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git WorkflowsJAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git Workflows
 

Recently uploaded

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 

Recently uploaded (20)

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 

JAZOON'13 - Andrej Vckovski - Go synchronized

  • 2. What I want to transmit  Go is useful and neat for heavily concurrent applications  Webrockets socks! Go synchronized 2
  • 3. A small poll Point your [smartphone] browser to nca.me/l Go synchronized 3
  • 6. About go  Started by Robert Griesemer, Rob Pike and Ken Thompson in Fall 2007, Open-sourced 2009, Go 1 March 2012  Main features – C/Pascal/Modula-like, garbage collected, no pointer arithmetics, type safe, very fast compiler – Simple type system without hierarchies – Concepts for concurrent programming in the “CSP”-style – Embeds dependency management – Today about similar memory/execution-performance as Java or Node. Go synchronized 6
  • 7. Concurrency?  Separate, potentially simultaneously executed computations  Usually somehow interacting  Candidates to leverage multi-{core|cpu|node} environments  Usually but not necessarily correspond to multiple users  Often on the server side And hard to make it right Go synchronized 7
  • 8. Go and concurrency Communicating Sequential Processes (CSP) pattern (C. A. R. Hoare, 1978) 1. Channels 2. Go-routines 3. select-statement “Do not communicate by sharing memory; instead, share memory by communicating” Occam, Erlang, Newsqueak, Limbo, Clojure and many more Go synchronized 8
  • 9. Example package main import ("fmt"; "time"; "math/rand") func main() { table := make(chan string) for _, player := range [...]string{"alice", "bob"} { go func(who string) { num := 0; for { ball := <- table; fmt.Printf("player %s: %sn", who, ball) table <- fmt.Sprintf("tick-%s-%d",who,num) time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) num++ } }(player) } table <- "go" time.Sleep(10 * time.Second) } Go synchronized 9
  • 10. The application: Very Instant Massive (Audience) Polling  Presentations like this one  TV shows with added interactivity  Pause entertainment in a stadium  Flipped Classrooms Go synchronized © Nhenze © Chris Lawrence © Loozrboy © Jeff Chenqinyi 10
  • 11. Browser JS that displays questions and allows voting System context go Browser JS that displays questions and allows voting ipoll server Presentation Software (e.g., PowerPoint) JS Browser JS that displays questions and allows voting Go synchronized Browser that displays voting results 11
  • 12. Browser JS that displays questions and allows voting WebSockets go  Full-duplex conversation ipoll over TCP connectionserver  JS RFC 6455  Available in most modern browsers  Simple JavaScript binding JS  Handshake by HTTP then , user-defined messages over the same socket Client (Browser) HTTP GET Request, special attributes HTTP response “switch protocol” Browser that displays questions and allows voting Browser that displays questions and allows voting Go synchronized Server Message Presentation Software (e.g., PowerPoint) JS Message Message Browser that displays voting results Message Message 12
  • 14. Small Demo Point your smartphone browser to nca.me/l Go synchronized 14
  • 15. Demo: New Question 1 nca.me/l Go synchronized 15
  • 16. Demo: New Question 2 nca.me/l Go synchronized 16
  • 17. Demo: New Question 3 nca.me/l Go synchronized 17
  • 18. WebSocket on server side (go) func startWebserver() { // [...] http.HandleFunc("/svy", surveyHandler) } Go // [...] func surveyHandler(c http.ResponseWriter, req *http.Request) { // [...] go websocket.Handler(func (ws *websocket.Conn) { s.VoterHandler(ws)} ).ServeHTTP(c, req) // [...] } func (s *Survey) VoterHandler(ws *websocket.Conn) { defer func() { s.voterChan <- voter{ws, false} log.Printf("connection closed by client") ws.Close() }() s.voterChan <- voter{ws, true} // notify hub of a new voter for { // [...] len, err := ws.Read(buf) // [...] var v vote err = json.Unmarshal(buf, &v) if err == nil { s.voteChan <- v } else { // [...] } } synchronized } 18
  • 19. Core data massaged at a single place: The “model” implements an event-loop func (s *Survey) surveyHub() { // [...] t := time.NewTicker(100 * time.Millisecond) // [...] for { select { case _ = <-t.C: // tick arrived // [...] case ctrl := <-s.controlChan: // control message // [...] case voter := <-s.voterChan: // voter subscribed // [...] case viewer := <-s.viewerChan: // viewer subscribed // [...] case admin := <-s.adminChan: // admin subscribed // [...] case vote := <-s.voteChan: // a vote arrived // [...] } } } 19
  • 20. Conclusions  Go (or “CSP”-design) has massively simplified the concurrency challenges  WebSockets are easy to use and will be increasingly popular Go synchronized 20
  • 21. http://golang.org Rob Pike on “concurrency is not parallelism”: http://vimeo.com/49718712 (mascot by Renée French)
  • 23. Thanks for the attention! andrej.vckovski@netcetera.com netcetera.com ipoll.ch (coming soon)