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

Concurrency Basics for Elixir

Concurrency Basics for Elixir

Slides from internal presentation at https://appunite.com

Maciej Kaszubowski

August 02, 2018
Tweet

More Decks by Maciej Kaszubowski

Other Decks in Programming

Transcript

  1. Concurrent Execution (3 functions, 3 threads) Parallel Execution (3 functions,

    3 threads, 2 cores) core 1 core 2 (by default) One erlang scheduler per core
  2. Req1 Req2 Req3 Resp Req1 Resp Req2 Req3 Sequential Concurrent

    Execution time Waiting time Req1 Resp Req2 Req3 Parallel
  3. R1 APP Server DB Server (3 cores) R2 R1 R2

    Time Execution time Waiting time
  4. R1 APP Server DB Server (3 cores) Send resp R2

    R3 R1 R2 R3 Time Execution time Waiting time
  5. R1 APP Server Send resp R2 R3 R1 R2 R3

    Time Execution time Waiting time Almost 100% parallel (almost no synchronisation) DB Server (3 cores)
  6. R1 APP Server Send resp R2 R3 R1 R2 R3

    Time Execution time Waiting time This is not constant DB Server (3 cores)
  7. R1 APP Server Send resp R2 R3 R1 R2 R3

    Time Execution time Waiting time This is not infinite DB Server (3 cores)
  8. R1 APP Server R2 R3 R1 R2 R3 R4 Time

    Execution time Waiting time DB Server (3 cores)
  9. R1 APP Server R2 R3 R1 R2 R3 R4 Time

    Execution time Waiting time DB Server (3 cores)
  10. R1 APP Server R2 R3 R1 R2 R3 R4 R4

    Time Execution time Waiting time DB Server (3 cores)
  11. R1 APP Server R2 R3 R1 R2 R3 R4 R4

    Time Execution time Waiting time DB Server (3 cores)
  12. R1 APP Server R2 R3 R1 R2 R3 R4 R4

    Time Execution time Waiting time DB Server (3 cores)
  13. R1 APP Server Send resp R2 R3 R1 R2 R3

    R4 R4 Time Execution time Waiting time DB Server (3 cores)
  14. R1 APP Server R2 R3 R1 R2 R3 R4 R4

    Time Execution time Waiting time R5 R6 R7 R5 R6 R7 DB Server (3 cores)
  15. Phoenix Request Task 1 Task 2 Task 3 Req 1

    Req 2 Req 3 Remember this?
  16. OS Threads (Garbage Collection) Data Bus Virtual Machines Memory characteristics

    (e.g. processor caches) … Other synchronisation points