Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Golang
design4concurrency
v0.0.1 GoMAD Apr 2015
Alea Soluciones
@eferro
@jaimegil
Agenda
Example 1
Example 2
Code samples
References
Conclusion
First, an example
As a customer I put sufficient coins into the vending
machine and then press the selection button for coke and
then press ...
Nouns (potential clases):
Customer, coins, vending machine, selection button, coke,
button to vend, robotic arm, pickup tr...
Verbs (methods):
Selection button: push
Vend button: push
Robotic arm: pickup(coke)
cooling system: cool forever
...
OO Solution:
Class, methods
How to implement concurrent behaviours???
OO Solution:
Class, methods
How to implement concurrent behaviours???
Threads, threads pools, locks, debug, debug, debug...
One goroutine for each truly
concurrent activity in the system
Goroutines are not SO processes
Goroutines are not threads
...
One goroutine for each truly concurrent activity in the
system
Handling coins, Putting coins into the slots, Handling sele...
Another example
As a network operator I can check in real time the state of
each home router of our Fiber to the home network
(200,000 rou...
EventProcessor, DBEventSerializer, RouterStateCalculator,
EventProcessorsPool...
One goroutine for each truly concurrent activity in the
system
Receive events from home routers, Dispatch events, compute ...
One goroutine for each truly
concurrent activity in the system
Goroutines are really cheap
Goroutines are really cheap
Gor...
Small mem footprints
Fast creation
Fasts scheduling
Goroutines
Never share memory
Only send messages using channels
Communicate using channels
Code Samples
https://github.com/aleasoluciones/golang_design4concurrency_talk/
Design for concurrency
Don't share memory
Lot of goroutines / they are cheap
Conclusions
References
Go concurrency patterns
https://talks.golang.org/2012/concurrency.slide
Advanced Go concurrency patterns
https:...
Questions???
@eferro
@jaimegil
Thanks !!!
@eferro
@jaimegil
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Golang design4concurrency
Prochain SlideShare
Chargement dans…5
×

Golang design4concurrency

772 vues

Publié le

Design for concurrency using golang

Publié dans : Logiciels
  • Soyez le premier à commenter

Golang design4concurrency

  1. 1. Golang design4concurrency v0.0.1 GoMAD Apr 2015
  2. 2. Alea Soluciones @eferro @jaimegil
  3. 3. Agenda Example 1 Example 2 Code samples References Conclusion
  4. 4. First, an example
  5. 5. As a customer I put sufficient coins into the vending machine and then press the selection button for coke and then press the button to vend and the robotic arm fetches a coke and dumps it into the pickup tray. The coke is nice and cold because the cooling system keeps the air in the vending machine at 50 degrees.
  6. 6. Nouns (potential clases): Customer, coins, vending machine, selection button, coke, button to vend, robotic arm, pickup tray, cooling system...
  7. 7. Verbs (methods): Selection button: push Vend button: push Robotic arm: pickup(coke) cooling system: cool forever ...
  8. 8. OO Solution: Class, methods How to implement concurrent behaviours???
  9. 9. OO Solution: Class, methods How to implement concurrent behaviours??? Threads, threads pools, locks, debug, debug, debug...
  10. 10. One goroutine for each truly concurrent activity in the system Goroutines are not SO processes Goroutines are not threads Goroutines are really cheap
  11. 11. One goroutine for each truly concurrent activity in the system Handling coins, Putting coins into the slots, Handling selections, Cooling the soda, Fetching the coke and putting into the pickup tray....
  12. 12. Another example
  13. 13. As a network operator I can check in real time the state of each home router of our Fiber to the home network (200,000 routers). The home routers send events with each state change to the central system.
  14. 14. EventProcessor, DBEventSerializer, RouterStateCalculator, EventProcessorsPool...
  15. 15. One goroutine for each truly concurrent activity in the system Receive events from home routers, Dispatch events, compute state for a home router... 200,000 routers = min 200,000 goroutines
  16. 16. One goroutine for each truly concurrent activity in the system Goroutines are really cheap Goroutines are really cheap Goroutines are really cheap
  17. 17. Small mem footprints Fast creation Fasts scheduling Goroutines
  18. 18. Never share memory Only send messages using channels Communicate using channels
  19. 19. Code Samples https://github.com/aleasoluciones/golang_design4concurrency_talk/
  20. 20. Design for concurrency Don't share memory Lot of goroutines / they are cheap Conclusions
  21. 21. References Go concurrency patterns https://talks.golang.org/2012/concurrency.slide Advanced Go concurrency patterns https://blog.golang.org/advanced-go-concurrency-patterns @martinjlogan Designing for Actor Based Systems http://blog.erlware.org/designing-for-actor-based-systems/ Golang patterns for serving on-demand, generated content http://blog.gitorious.org/2014/08/11/golang-patterns-for-serving-on-demand-generated-con tent/
  22. 22. Questions??? @eferro @jaimegil
  23. 23. Thanks !!! @eferro @jaimegil

×