Bill Kelly
10/11/2004 2:37:00 AM
Hi,
From: "Michael Gebhart" <mail@miketech.net>
> I am just thinking about programming a serverapplication with Ruby. The
> application should manage a lot of sockets and should also be
> multithreaded. One year ago I have tried to develop a similar application
> with php. The performance was absolutely bad. No, that was not only my
> fault ;) My question is now: What about the performance of ruby? Is it
> possible to write an application using sockets and threads with ruby, but
> also with a good performance? Normally I am using C/C++ for these things.
> Sure, Ruby will not be as far as C/C++. But the php-scripts were very very
> slow. Has anyone experiences with this?
I've just hacked up a TCP/IP throughput test of sorts,
where you can spawn a server, and as many clients
as you want (each client is a separate OS process.)
The server and clients will blast data at each other
in chunks of a specified byte size, for a specified
number of seconds.
The server prints some stats about the throughput as
each client disconnects.
Dunno if it will be useful to you. One thing of interest
to me is that the chunk-size makes a huge difference.
(I.e. printing 2048 bytes at a time is hugely faster than
printing 64 bytes at a time. I expected some difference,
of course, but not as much as I'm seeing.)
With a server transmit chunk-size of 1024, and a client
transmit chunk-size of 2048... (Arbitrary, just trying
different values)... Servicing 100 clients, each of which
connected for 60 seconds, I get:
80.045 seconds, MB in: 190.75 (2.38 MB/sec), MB out: 30.38 (0.38 MB/sec)
I'm running win2k with a 1.33GHz athlon CPU. The elapsed
time of 80 seconds is because it took awhile to start up
all 100 clients (which each ran for 60 sec.)
Leaving the server chunk-size at 1024 but changing the
client size to 64, I get:
95.728 seconds, MB in: 38.51 (0.40 MB/sec), MB out: 12.15 (0.13 MB/sec)
...And I had trouble even starting 100 client processes
this time... Well, the same kinds of chunk-size differences
are apparent when running even one client... Will have
to try this on Linux ...
Anyway for whatever it's worth ... :)
Regards,
Bill