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

From: joshua at anwu.org (joshua at anwu.org)
Date: Wed Apr 18 20:55:31 EDT 2012


Ha!  I was just about to write you guys back about this.  I think I found the problem(s).

1) Too many database connections.

I had the max_connections on the postgres pool set to like 60 or something.  The Racket
server would happily accept a bunch of connections, blow up the database with requests,
and then churn while it waited for Postgres to give it 60 answers in parallel.  Turning
the db connections down to 7 seems to have improved responsiveness dramatically.

2) Too little memory

I'm testing on a basic Linode VPS.  The servlet likes to grab a bunch of memory, which
often leads it to start thrashing.

(Another problem was me looking at the mean values rather than the median.  Racket
seems faster on average, but also seems to have more long-tail outliers that drive
up the mean relative to Perl/Starman and Ruby/Unicorn.  Racket often looks better
than the others from the 50% to 90% marks, then worse.  Not sure what this means.)

By altering some configuration, I was able to get the Racket server to return requests
at a speed comparable to Perl or Ruby.  This suggested to me that IO (network or DB)
was the fundamental bottleneck, so I wrote a second set of tests where the servers
do nothing but convert an internal data structure to JSON and send it over the wire,
then ran the tests against localhost.

With the network and database out of the way, Racket beat Perl by a country mile.
It beat up node.js too, though not as badly.

I also found that NVD's scgi module responds faster than serve/servlet - not a huge
surprise, as what it's doing is probably much simpler than saving continuations and
such.  It also seems to use about half the memory.  Great tool for those of use
who don't need the fancier aspects of Racket's built-in server.

Thanks to all for the advice.  I'm happy to say it was my code that sucked.


On Wed, Apr 18, 2012 at 01:06:12PM -0600, Jay McCarthy wrote:
> I'm surprised you don't get any difference with the new version.
> This is very surprising for me. Here are results from my tiny Macbook Air:


Posted on the users mailing list.