[erlang-questions] measuring OS context switches

M. Edward (Ed) Borasky <>
Thu Sep 21 06:39:32 CEST 2006

ke han wrote:
> I am doing a comparative analysis of a webapp with Ruby on Rails vs.  
> Yaws+mysql.  The app being used is the "depot" app from the book  
> Agile Programing in Rails (Pragmatic Programmer).  This app is used  
> in many Rails based tutorials and seems a good one to use since I  
> already have the Rail version complete and it would be hard for the  
> Rails community to say I "cheated" as its their app.
> There is little value in just measuring end-to-end page load times  
> and overall stress testing as it doesn't explain "why" erlang is  
> beating the pants off Rails (obviously I'm making assumptions about  
> the results ;-)).  I want to show ratios of "real work" vs. OS  
> context switches + other internal communications between processes,  
> etc...
> Can anyone give ideas for how to go about measuring such things??  I  
> can litter Rails code with all sorts of wall clock logging and try to  
> put this to use, but this also means I have to dig into lighttpd and  
> mysql to log some of their times as well...there must be some tools  
> or methods I don't know about.  I was hoping to have access to a  
> Solaris server for these tests and use DTrace and other profiling  
> tools Sun crows about, but alas, no interest from Sun (or hosting  
> partners) in providing a box to test on...So I'll be doing this  
> initial analysis on my iMac dual core and maybe a dual proc FreeBSD  
> server.
> If I do this correctly, I should have the sample code and scripts to  
> allow others to try out variations on my tests.  Such as:  Rails: 1  
> lighttpd proc, 20 mongrel/ruby procs, 1 mysql proc (20 connections)  
> on a single CPU vs, variations on multi-core.  The erlang solution  
> could be varied by multi-threaded erlang vs. single threaded and  
> such.  I'm not so interested in measuring context switches between  
> procs within a multi-thread erlang vm as I think my results will be  
> interesting enough to show how much overhead is in the Rails "runtime  
> architecture".
> thanks, ke han
> BTW, Yariv, if you catch this email, I will be using your erlyDB  
> along with some javascript and erlang prototypes I've been working on  
> to make the front end work.
> _______________________________________________
> erlang-questions mailing list
> http://www.erlang.org/mailman/listinfo/erlang-questions

First of all, you'll want some kind of load test driver. There are good 
ones for sale, but I think there are some open source ones that are at 
least usable. Second, you'll want some kind of performance data logging 
and capture on the server. I don't know anything about MacOS or BSD -- I 
do this for a living on Windows and Linux servers. :)

I'm not sure context switches are necessarily something you should 
measure. The fundamental measurements you need to take are transaction 
response times and throughputs, and the number of seconds spent in 
physical processors, physical disks and on the network.

More information about the erlang-questions mailing list