[racket] My toy web app's performance: Racket vs Perl vs Ruby

From: joshua at anwu.org (joshua at anwu.org)
Date: Wed Apr 11 17:03:54 EDT 2012

Racketeers,

I'm new to the language, and loving it.  I'm having trouble getting good performance out of my little toy web app, however.

I wrote this fake billing app to play with some new languages (like Racket) and some other webdev ideas I've had (like client-side
templating with jQuery and mustache).  As such, I have the same JSON api written in Perl, Ruby, and Racket (working on node.js
and Haskell).  Perl runs under Dancer and Starman, ruby under Sinatra and Unicorn, and Racket under nohup and its own included webserver.
All are running on the same machine.  Each connects to a postgres db, executes some queries from a config file, and returns JSON
to the client.

I've been running apache bench against all three, and the performance of Racket vs Perl and Ruby has been... disheartening.  I
compiled the racket code with 'raco exe' before running it, but Perl and Ruby both blow it away.  The racket executable also
seems to grab and hold a lot of memory, even though I told it to be stateless.  It also tends to have failures.

ab -c 20 -n 10000 <uri>


Perl:

Concurrency Level:      20
Time taken for tests:   86.100 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      88150000 bytes
HTML transferred:       86300000 bytes
Requests per second:    116.14 [#/sec] (mean)
Time per request:       172.199 [ms] (mean)
Time per request:       8.610 [ms] (mean, across all concurrent requests)
Transfer rate:          999.82 [Kbytes/sec] received


Ruby:

Concurrency Level:      20
Time taken for tests:   102.914 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      88480000 bytes
HTML transferred:       86050000 bytes
Requests per second:    97.17 [#/sec] (mean)
Time per request:       205.827 [ms] (mean)
Time per request:       10.291 [ms] (mean, across all concurrent requests)
Transfer rate:          839.60 [Kbytes/sec] received


Racket:

Concurrency Level:      20
Time taken for tests:   139.059 seconds
Complete requests:      10000
Failed requests:        687
   (Connect: 0, Receive: 0, Length: 687, Exceptions: 0)
Write errors:           0
Total transferred:      9421469 bytes
HTML transferred:       7100095 bytes
Requests per second:    71.91 [#/sec] (mean)
Time per request:       278.119 [ms] (mean)
Time per request:       13.906 [ms] (mean, across all concurrent requests)
Transfer rate:          66.16 [Kbytes/sec] received


I'm hoping it's just inexperience on my part - maybe my Racket code just sucks.  Or maybe it's that I'm trying to
stay functional and avoid mutation, which I don't bother with in the other two. Anyone interested in looking at
the code and telling me what I'm doing wrong, or could do better?  I would love to use Racket for more serious
projects.

https://github.com/TurtleKitty/CalicoBill


Thanks,
TurtleKitty




Posted on the users mailing list.