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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. Sunday, October 27, 13

    View full-size slide

  8. Demo time!
    Sunday, October 27, 13

    View full-size slide

  9. Python3 & Ruby
    Sunday, October 27, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  17. PHP
    Sunday, October 27, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide