SlideShare a Scribd company logo
1 of 23
Download to read offline
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 transportsDaniel 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
 
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 WindowsManuel Lemos
 
All Aboard The Stateful Train
All Aboard The Stateful TrainAll Aboard The Stateful Train
All Aboard The Stateful TrainSmartLogic
 
Resource Prioritization
Resource PrioritizationResource Prioritization
Resource PrioritizationPatrick 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 DownloadEshan Mudwel
 
Java concurrency
Java concurrencyJava concurrency
Java concurrencyfbenault
 

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
 

Similar to 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
 
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 developersNetcetera
 
150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugsNetcetera
 
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 developmentzonathen
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript FrameworksChristian Gaetano
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | IntroductionJohnTaieb
 
(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 UniverseStefano Di Paola
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of TechnologiesChris 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.pdfDarshanaMallick
 
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 PeopleIT 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 Sourcevlcinsky
 

Similar to 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 Netcetera

Payment trend scouting - Kurt Schmid, Netcetera
Payment trend scouting - Kurt Schmid, NetceteraPayment trend scouting - Kurt Schmid, Netcetera
Payment trend scouting - Kurt Schmid, NetceteraNetcetera
 
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, NetceteraBoost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, NetceteraNetcetera
 
Increase conversion, convenience and security in e-commerce checkouts - Silke...
Increase conversion, convenience and security in e-commerce checkouts - Silke...Increase conversion, convenience and security in e-commerce checkouts - Silke...
Increase conversion, convenience and security in e-commerce checkouts - Silke...Netcetera
 
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORMNetcetera
 
Digital Payment in 2020 - Kurt Schmid, Netcetera
Digital Payment in 2020 - Kurt Schmid, NetceteraDigital Payment in 2020 - Kurt Schmid, Netcetera
Digital Payment in 2020 - Kurt Schmid, NetceteraNetcetera
 
AI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
AI First. Erfolgsfaktoren für künstliche Intelligenz im UnternehmenAI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
AI First. Erfolgsfaktoren für künstliche Intelligenz im UnternehmenNetcetera
 
Augmenting Maintenance
Augmenting MaintenanceAugmenting Maintenance
Augmenting MaintenanceNetcetera
 
Front-end up front
Front-end up frontFront-end up front
Front-end up frontNetcetera
 
The future of Prototpying
The future of PrototpyingThe future of Prototpying
The future of PrototpyingNetcetera
 
EMV Secure Remote Commerce (SRC)
EMV Secure Remote Commerce (SRC)EMV Secure Remote Commerce (SRC)
EMV Secure Remote Commerce (SRC)Netcetera
 
Online shopping technology in the fast lane?
Online shopping technology in the fast lane?Online shopping technology in the fast lane?
Online shopping technology in the fast lane?Netcetera
 
Merchant tokenization and EMV® Secure Remote Commerce
Merchant tokenization and EMV® Secure Remote CommerceMerchant tokenization and EMV® Secure Remote Commerce
Merchant tokenization and EMV® Secure Remote CommerceNetcetera
 
Seamless 3-D Secure e-commerce experience
Seamless 3-D Secure e-commerce experienceSeamless 3-D Secure e-commerce experience
Seamless 3-D Secure e-commerce experienceNetcetera
 
Augmenting Health Care
Augmenting Health CareAugmenting Health Care
Augmenting Health CareNetcetera
 
Driving transactional growth with 3-D Secure
Driving transactional growth with 3-D SecureDriving transactional growth with 3-D Secure
Driving transactional growth with 3-D SecureNetcetera
 
Digital Payment Quo Vadis
Digital Payment Quo VadisDigital Payment Quo Vadis
Digital Payment Quo VadisNetcetera
 
EMV® Secure Remote Commerce
EMV® Secure Remote CommerceEMV® Secure Remote Commerce
EMV® Secure Remote CommerceNetcetera
 
Context: The missing ingredient in multilingual software translation
Context: The missing ingredient in multilingual software translationContext: The missing ingredient in multilingual software translation
Context: The missing ingredient in multilingual software translationNetcetera
 
Digital Payments - Netcetera Innovation Summit 2018
Digital Payments - Netcetera Innovation Summit 2018Digital Payments - Netcetera Innovation Summit 2018
Digital Payments - Netcetera Innovation Summit 2018Netcetera
 
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018Netcetera
 

More from Netcetera (20)

Payment trend scouting - Kurt Schmid, Netcetera
Payment trend scouting - Kurt Schmid, NetceteraPayment trend scouting - Kurt Schmid, Netcetera
Payment trend scouting - Kurt Schmid, Netcetera
 
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, NetceteraBoost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
Boost your approved transaction volume - Ana Vuksanovikj Vaneska, Netcetera
 
Increase conversion, convenience and security in e-commerce checkouts - Silke...
Increase conversion, convenience and security in e-commerce checkouts - Silke...Increase conversion, convenience and security in e-commerce checkouts - Silke...
Increase conversion, convenience and security in e-commerce checkouts - Silke...
 
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
3-D Secure 2.0 - Stephan Rüdisüli, Netcetera & Patrick Juffern, INFORM
 
Digital Payment in 2020 - Kurt Schmid, Netcetera
Digital Payment in 2020 - Kurt Schmid, NetceteraDigital Payment in 2020 - Kurt Schmid, Netcetera
Digital Payment in 2020 - Kurt Schmid, Netcetera
 
AI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
AI First. Erfolgsfaktoren für künstliche Intelligenz im UnternehmenAI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
AI First. Erfolgsfaktoren für künstliche Intelligenz im Unternehmen
 
Augmenting Maintenance
Augmenting MaintenanceAugmenting Maintenance
Augmenting Maintenance
 
Front-end up front
Front-end up frontFront-end up front
Front-end up front
 
The future of Prototpying
The future of PrototpyingThe future of Prototpying
The future of Prototpying
 
EMV Secure Remote Commerce (SRC)
EMV Secure Remote Commerce (SRC)EMV Secure Remote Commerce (SRC)
EMV Secure Remote Commerce (SRC)
 
Online shopping technology in the fast lane?
Online shopping technology in the fast lane?Online shopping technology in the fast lane?
Online shopping technology in the fast lane?
 
Merchant tokenization and EMV® Secure Remote Commerce
Merchant tokenization and EMV® Secure Remote CommerceMerchant tokenization and EMV® Secure Remote Commerce
Merchant tokenization and EMV® Secure Remote Commerce
 
Seamless 3-D Secure e-commerce experience
Seamless 3-D Secure e-commerce experienceSeamless 3-D Secure e-commerce experience
Seamless 3-D Secure e-commerce experience
 
Augmenting Health Care
Augmenting Health CareAugmenting Health Care
Augmenting Health Care
 
Driving transactional growth with 3-D Secure
Driving transactional growth with 3-D SecureDriving transactional growth with 3-D Secure
Driving transactional growth with 3-D Secure
 
Digital Payment Quo Vadis
Digital Payment Quo VadisDigital Payment Quo Vadis
Digital Payment Quo Vadis
 
EMV® Secure Remote Commerce
EMV® Secure Remote CommerceEMV® Secure Remote Commerce
EMV® Secure Remote Commerce
 
Context: The missing ingredient in multilingual software translation
Context: The missing ingredient in multilingual software translationContext: The missing ingredient in multilingual software translation
Context: The missing ingredient in multilingual software translation
 
Digital Payments - Netcetera Innovation Summit 2018
Digital Payments - Netcetera Innovation Summit 2018Digital Payments - Netcetera Innovation Summit 2018
Digital Payments - Netcetera Innovation Summit 2018
 
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
"Whats up and new at Netcetera?" - Netcetera Innovation Summit 2018
 

Recently uploaded

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

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)