Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.
/ concurrency Public archive

Shows simple examples of increasing concurrency levels with Elixir

Notifications You must be signed in to change notification settings

abletech/concurrency

Repository files navigation

Concurrency

Shows simple examples of increasing concurrency levels with Elixir.

Getting Started

  1. Install a Docker client such as Docker for Mac.
  2. git clone [email protected]:AbleTech/concurrency.git
  3. cd concurrency
  4. cp .container-sample.env .container.env
  5. cp .envrc-sample .envrc
  6. docker-compose up -d
  7. docker-compose exec elixir bash

Examples

You need to have completed the Getting Started steps, and should have a bash shell prompt within the Elixir container. Each of these examples process the 100,000 address records stored within the addresses table.

SequentialFunctions

Queries the addresses table, streams the records and looks for longest/shortest/etc addresses. Performs each of the searches sequentially.

Command: time mix run -e Concurrency.Functions.SequentialFunctions.run

Time: about 5 secs

ConcurrentFunctions

Queries the addresses table, streams the records and looks for longest/shortest/etc addresses. Performs each of the searches concurrently.

Command: time mix run -e Concurrency.Functions.ConcurrentFunctions.run

Time: about 3 secs

SequentialProcessor

Queries the addresses table, loads all the records, and then processes each line sequentially.

Command: time mix run -e Concurrency.Processor.SequentialProcessor.run

Time: about 3 mins

SequentialStreamProcessor

Queries the addresses table, streams the records, and processes each line sequentially.

Command: time mix run -e Concurrency.Processor.SequentialStreamProcessor.run

Time: about 2 mins

ConcurrentProcessor

Queries the addresses table, loads all the records, and then processes each line concurrently.

Command: time mix run -e Concurrency.Processor.ConcurrentProcessor.run

Time: about 1 mins

Timing

Use the time command to compare execution times. For example:

time mix run -e Concurrency.Functions.ConcurrentFunctions.run

real	0m2.898s
user	0m4.050s
sys	0m0.860s

This example shows that the execution time was approx 2.9 seconds, but the amount of consumed CPU time was closer to 4 seconds.

About

Shows simple examples of increasing concurrency levels with Elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published