Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Webcamp Zagreb 2013

Webcamp Zagreb 2013

Slides for a talk "Concurrency" that I gave at Webcamp Zagreb.

Goran Peretin

October 27, 2013
Tweet

More Decks by Goran Peretin

Other Decks in Programming

Transcript

  1. Concurrency
    @gperetin
    Sunday, October 27, 13

    View Slide

  2. Goran Peretin (@gperetin)
    Sunday, October 27, 13

    View Slide

  3. Goran Peretin (@gperetin)
    Sunday, October 27, 13

    View Slide

  4. Goran Peretin (@gperetin)
    Sunday, October 27, 13

    View Slide

  5. Goran Peretin (@gperetin)
    Sunday, October 27, 13

    View Slide

  6. Sadržaj
    Concurrency
    Parallelism
    Problemi/rješenja
    Sunday, October 27, 13

    View Slide

  7. Sunday, October 27, 13

    View Slide

  8. Demo time!
    Sunday, October 27, 13

    View Slide

  9. Python3 & Ruby
    Sunday, October 27, 13

    View Slide

  10. Concurrency
    Izvršavanje više taskova u nekom vremenskom
    periodu.
    Sunday, October 27, 13

    View Slide

  11. Parallelism
    Izvršavanje više taskova istovremeno.
    Sunday, October 27, 13

    View Slide

  12. Concurrency != Parallelism
    Sunday, October 27, 13

    View Slide

  13. Process-based concurrency
    task == proces
    Sunday, October 27, 13

    View Slide

  14. Thread-based concurrency
    task == thread
    Sunday, October 27, 13

    View Slide

  15. GIL (Ruby & Python)
    • Global Interpreter Lock
    • dva threada se ne mogu izvršavati
    istovremeno
    Sunday, October 27, 13

    View Slide

  16. Ruby i Python ne mogu imati thread-based
    parallelism.
    Sunday, October 27, 13

    View Slide

  17. PHP
    Sunday, October 27, 13

    View Slide

  18. PHP
    • PHP nema threadove
    • Nije thread-safe
    • PHP-FPM
    • Apache (mod_php)
    Sunday, October 27, 13

    View Slide

  19. Java & .NET
    Sunday, October 27, 13

    View Slide

  20. Java & .NET
    Sunday, October 27, 13

    View Slide

  21. Problemi?
    • broj procesa i threadova
    • RAM
    Sunday, October 27, 13

    View Slide

  22. Blocking I/O
    OS pauzira thread koji napravi I/O request.
    Za izvršavanje drugog requesta treba nam novi
    thread.
    Sunday, October 27, 13

    View Slide

  23. Rješenja?
    Non-blocking I/O
    Lightweight processes
    Sunday, October 27, 13

    View Slide

  24. Non-blocking I/O
    Twisted, Tornado
    EventMachine
    Node.js
    Sunday, October 27, 13

    View Slide

  25. Lightweight processes
    Erlang (actors)
    Go (goroutines)
    ---
    Python (greenlets)
    Ruby (fibers)
    Sunday, October 27, 13

    View Slide

  26. Što da koristim?
    Sunday, October 27, 13

    View Slide

  27. Hvala!
    Pitanja?
    Sunday, October 27, 13

    View Slide