l00ker

l00ker

This popped up in my Google news feed last night…

Concurrency in modern programming languages: Rust vs Go vs Java vs Node.js vs Deno

That first thing that struck me about the article – given the title – is that Erlang and/or Elixir (I would think Elixir should considered a “modern programming language”) weren’t even mentioned, much less, even considered for a benchmark test.

Never the less, after reading through the article(s) (7 in all), I decided to tinker just for fun. Even though the benchmarks seem meaningless (as pointed out in one or more of the comments), I wondered how well Elixir would preform, so I created a simple Elixir app using only Cowboy w/Plug to serve the html file like the other examples in the benchmark tests.

mix new plug_test --sup

# lib/plug_test.ex
defmodule PlugTest do
  import Plug.Conn

  def init(options), do: options

  def call(conn, _opts) do
    Process.sleep(200)

    conn
    |> put_resp_header("connection", "keep-alive")
    |> put_resp_content_type("text/html; charset=utf-8")
    |> send_file(200, "hello.html")
  end
end

# hello.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Hello!</title>
  </head>
  <body>
    <h1>Hello!</h1>
    <p>Hi from Elixir</p>
  </body>
</html>

Notice the Process.sleep(200) in call/2 above. In the code the author wrote for rust, go, etc., he introduces a 2 second sleep every tenth request. I’m currently not aware of a way to do that (?), so I just decided to sleep each request process for 200 ms instead.

Here’s what I got after 2 back-to-back runs of ab -c 100 -n 10000 http://localhost:4000/

Server Software:        Cowboy
Server Hostname:        localhost
Server Port:            4000

Document Path:          /
Document Length:        178 bytes

Concurrency Level:      100
Time taken for tests:   20.483 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4090000 bytes
HTML transferred:       1780000 bytes
Requests per second:    488.20 [#/sec] (mean)
Time per request:       204.833 [ms] (mean)
Time per request:       2.048 [ms] (mean, across all concurrent requests)
Transfer rate:          194.99 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       5
Processing:   200  202   1.1    202     211
Waiting:      200  201   1.0    201     210
Total:        201  202   1.5    202     215

Percentage of the requests served within a certain time (ms)
  50%    202
  66%    202
  75%    203
  80%    203
  90%    204
  95%    205
  98%    206
  99%    209
 100%    215 (longest request)
Server Software:        Cowboy
Server Hostname:        localhost
Server Port:            4000

Document Path:          /
Document Length:        178 bytes

Concurrency Level:      100
Time taken for tests:   20.490 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4090000 bytes
HTML transferred:       1780000 bytes
Requests per second:    488.04 [#/sec] (mean)
Time per request:       204.901 [ms] (mean)
Time per request:       2.049 [ms] (mean, across all concurrent requests)
Transfer rate:          194.93 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       4
Processing:   200  202   1.1    202     211
Waiting:      200  201   0.9    201     211
Total:        201  202   1.3    202     212

Percentage of the requests served within a certain time (ms)
  50%    202
  66%    202
  75%    203
  80%    203
  90%    204
  95%    204
  98%    206
  99%    208
 100%    212 (longest request)

I ran the above benchmarks on my workstation PC with the following specs:

Ubuntu Linux 20.04.1
Intel(R) Core™ i7-4770K CPU @ 3.50GHz w/ 8 cores & 16GB of memory

Erlang: 24.2.1
Elixir: 1.13.2-otp-24

I know the article is almost pointless, but what are your thoughts?

Stuff like this seems to pop up all time as well as the flurry of articles with titles like The Top 10 Backend Programming Languages You Should Know In 2022 etc., that show up near the beginning of the year, most all of which, hardly ever mention Elixir. :frowning:

Showing Posts 1 to 6

kartheek

kartheek

If someone is trying to serve a static hello.html and benchmark it - they should also include nginx, apache in it :smile: .

Real fun is inside the comments section - don’t miss it.

All you demonstrated is that thread sleep works in all languages, and that overhead is significantly smaller than 200ms. You did not really benchmark the various language / server combos.

When you add 2 second delay every 10 requests you make the comparison totally meaningless. You are mesuring delays, not the code.

Reading the file in every loop mesures reading from disk, not actual program performance.

Author’s response - comment1, comment2.


Most of the performance and benchmark articles are pointless. I skim through these kind of articles and enjoy comments section.

l00ker

l00ker OP

Yeah. That’s exactly what I do 99% of the time as well. It’s just that this one was about concurrency, and when I saw how it was being benchmarked, I was mostly curious to see how well the BEAM’s Process.sleep/1 stacked up against all the others! :laughing:


I don’t have an account there or I may have left a comment about Erlang/Elixir with a link to the video of Saša’s awesome talk The Soul of Erlang and Elixir

ityonemo

ityonemo

Check out the code for process.sleep! It’s pretty instructive

kartheek

kartheek

Author updated the article - he has overwritten original images. Some of the context for comments is lost. He should have created 8th article in the series with new changes.

l00ker

l00ker OP

I see someone named Patrice Gauthier finally mentioned Elixir and the BEAM in this comment.

If this person is a member of the Elixir Forum - Thank you! :clap:

dimitarvp

dimitarvp

HAHAHA :003: That really made me laugh for solid half a minute.

I absolutely loved how defensive the author became in the comments: “I wanted to write something like this for a long time and it started dragging on so I just put something out the door”, which is a super weird statement! Not like he was a journalist on a deadline, right? I guess a lot of people are addicted to getting attention on the net, I don’t know.

And he says that on a topic where a ton of people would love more benchmarks, and were curious and were of course bound to rip it apart. Not sure what was he expecting. :man_facepalming:

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
nseaSeb
AcmeScript — Writing JS hooks as if I were still using Elixir I’ve been having fun building a little something over the last few days: Ac...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews