caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Caml list <caml-list@inria.fr>, web-caml@quatramaran.ens.fr
Subject: Re: [Caml-list] Web Development with OCaml
Date: Sun, 15 Jul 2001 22:19:15 +0200	[thread overview]
Message-ID: <0107152218191B.00523@ice> (raw)
In-Reply-To: <20010715140351.B20044@andrew.cmu.edu>

On Sun, 15 Jul 2001, Ari Heitner wrote:
>[apologies to all, i should let sleepng dogs lie. but hey, i go to cmu,
>where John Harper gives 15-312 exam questions about java braindamage]
>
>> 
>> Second, you (and others) seem to take for granted that a "servlet
>> container" must load servlets dynamically into its own memory image.
>> That's the Java way, but again that's not the only way.  Using
>> separate processes for the HTTP server/servlet container and for the
>> servlets (but not starting a new servlet process on each request like
>> CGI does) might very well work better: I'll bet the performance hit
>> would be insignificant, and you get a clean, well-specified
>> communication protocol between server and servlets.
>
>Aha! the real point.
>
>CGIs roll over when people keep hitting the system, and apache (not fast in
>the first place) croaks as it spawns a new process for every request -- the
>system rapidly has too many processes, and swaps itself to death.

Don't be so unfair. Native-code CGIs are relatively fast. Unix has been
optimized for starting new processes very quickly. Of course, this is only true
if most of the process image is read-only, so the image can be shared by
several processes (my argument doesn't apply to all interpreter languages
which load the code into read-write sections). I have seen expensive SMP
systems that most of their time compile Perl programs. I have also done some
experiments with native-code O'Caml programs called as CGIs, and this is _much_
faster. (I've just done some simple benchmarks: a 500k executable that queries
the state of a daemon and prints it as HTML page, it runs with 40 requests per
second, and the CPU is still 50% idle (I think it's slowed down by the query,
and my benchmark is too stupid). Not bad for a simple technique like CGI.)

Okay, if there are too many processes, the hardware will become too ineffective
(too many cache misses). But this is also true for threads.

>The sane thing to do seems to be to have only a few more processes than
>CPUs, and drive those processes has hard as possible with async io. There's
>no strong reason to make either your httpd or your database process even
>multithreaded...

Most multithreading programs aren't so stupid that they create a new thread for
every request. There is usually a pool of waiting threads that are
activated when new requests arrive. If there are more requests than threads,
the requests must wait.

Because of this, I see no fundamental difference between multi-process and
multi-threaded programs. You can implement the "workers" that wait for requests
both as threads or as processes. However, the communication between threads
is simpler than between processes. (On the other hand, it is possible to
restart hanging processes which is not possible with threads.)

>that aside, using java just to get around switching to a new version of the
>servlet without downing the server is even worse -- just bloody use
>dlopen...

But dlopen is not available for caml (it is not possible to create PIC). I
would suggest to implement the pool of workers as pool of processes (to get
most out of SMP boxes) that can be dynamically changed without breaking the
service. There could be one "master process" knowing which workers are
available and for which tasks they are programmed. The master process assigns
the requests to the workers. (The master process should be as lightweight as
possible, perhaps not even a process.)

Gerd
-- 
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 45             
64293 Darmstadt     EMail:   gerd@gerd-stolpmann.de
Germany                     
----------------------------------------------------------------------------
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-07-15 20:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-10  0:01 Jimmie Houchin
2001-07-10  7:10 ` Jean-Christophe Filliatre
2001-07-10  7:15 ` Tom Hirschowitz
2001-07-10  8:19   ` David Mentre
2001-07-10  9:38   ` Alain Frisch
2001-07-11  5:49     ` Jimmie Houchin
2001-07-11  6:03       ` Alexander V. Voinov
2001-07-11 14:47         ` Jimmie Houchin
2001-07-12  1:58           ` John Max Skaller
2001-07-11  6:19       ` Alain Frisch
2001-07-11  9:09         ` Samuel Heriard Dubreuil
2001-07-11 14:11           ` Jimmie Houchin
2001-07-11 15:35       ` Francois Rouaix
2001-07-11 20:44         ` Gerd Stolpmann
2001-07-12  2:32         ` Jimmie Houchin
2001-07-13  5:37       ` William Chesters
2001-07-13 10:29         ` Alain Frisch
2001-07-13 11:16           ` Vitaly Lugovsky
2001-07-13 14:04             ` Xavier Leroy
2001-07-13 17:08               ` [web-caml] " Vitaly Lugovsky
2001-07-15 18:03               ` Ari Heitner
2001-07-15 20:19                 ` Gerd Stolpmann [this message]
2001-07-16  8:23                 ` wakita
2001-07-17 16:18                 ` John Max Skaller
2001-07-17 18:50                   ` Ari Heitner
2001-07-18 22:24                     ` John Max Skaller
2001-07-13 16:12           ` Lyn A Headley
2001-07-13 17:50             ` William Chesters
2001-07-13 16:51           ` Miles Egan
2001-07-13 18:12           ` Jimmie Houchin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0107152218191B.00523@ice \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=web-caml@quatramaran.ens.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).