[erlang-questions] Cowboy (Erlang) VS Haskell (Warp)

Damian Dobroczyński qoocku@REDACTED
Tue Jun 25 14:05:08 CEST 2013


W dniu 25.06.2013 13:51, BM Kim pisze:
> Hi folks,
>
> First of all, I want to apologise for my poor english skills,
> since english is not my first language, but I'll try my best
> to formulate my quesions as clear as possible.
>
> Second, I've just begun to learn erlang, so if I'm asking
> obvious "noob" questions I apologise for that too in advance...
>
> Anywho, now to my actual question:
>
> I am planning to write a high-performance server application in erlang,
> which will primarily handle HTTP requests. After some reseach with google,
> I narrowed down my choices to cowboy, misultin and mochiweb and decided
> to go with the cowboy library first...
>
> Looking at some tutorials, I've quickly built a small server capable of
> serving static files and was eager to see first benchmark-results...
> I've also built a small Haskell server using Warp library to compare it
> with erlang's cowboy...
>
> But my first impression was, that my cowboy server is much much slower than
> expected when serving static-files and after some research I found a presentation
> of the cowboy's author claiming that cowboy shouldn't be used for serving
> static-files. So I modified the server code, so that it replies to every
> request with in-memory 4Kb binary blob and compared it with my haskell warp
> server serving 4kb static file...
>
> this is my simple cowboy's http handler:
>
> ----------------------------------------------------------------------
>
> blob() ->
>     [<<0:8>> || _ <- lists:seq(1,4096)].

First, try to replace blob/0 function with this:

  blob() -> <<0:(4096*8)>>.

Then, restart the test and report ;)

-- D.

> init({tcp, http}, Req, _Opts) ->
>     {ok, Req, []}.
>
>
> handle(Req, State) ->
>     {ok, Req2} = cowboy_req:reply(200, [], blob(), Req),
>     {ok, Req2, State}.
>
>
> terminate(_Reason, _Req, _State) ->
>     ok.
>
> -----------------------------------------------------------------------
>
> I've tested both cowboy server and warp server with
>
> weighttp -k -c200 -n10000 http://localhost:8888/4kblob.txt
>
> on my i5-2540M thinkpad laptop running ubuntu 12.10.
> Haskell code was compiled via GHC 7.6 and my erlang VM is R16B.
>
>
> ----------------------------------------------------------------------
> Warp:
>
> finished in 0 sec, 279 millisec and 52 microsec, 35835 req/s, 147331 kbyte/s
>
> -----------------------------------------------------------------------
>
> -----------------------------------------------------------------------
> Cowboy (serving actually in-memory blob):
>
> finished in 1 sec, 683 millisec and 264 microsec, 5940 req/s, 24447 kbyte/s
> -----------------------------------------------------------------------
>
> I've noticed, that when testing the cowboy-server the cpu usage is so much
> higher than when testing the warp-server...
> What do you guys think could be the problem here? Can't imagine that erlang
> server is that much slower than haskell server...
> I aplogise again, if the question is forumalted chaotic, if you need more
> details just let me know...
>
> I am trying to look into this on my own, but since I am still an erlang noob, some
> helpful tips/advices from the experts will be much much appreciated!!!
>
> Thanks in advance,
>
> --cheers,
> bmk
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list