Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

using HTTP::Daemon instead of Apache

by schweini (Friar)
on Feb 03, 2004 at 23:20 UTC ( #326350=perlquestion: print w/ replies, xml ) Need Help??
schweini has asked for the wisdom of the Perl Monks concerning the following question:

Hello, again...

Has anybody any experience with using HTTP::Daemon instead of Apache for web-based intranet-Apps?

I'm not using a lot (or any, IIRC) of the more advanced features of Apache anyhow, and since perl has to be installed anyhow on our servers, i thought that this would make deployment easier, and may even get mod_perl-y performance (since most of mod_perl's performance boost is due to the embedded perl interpreter, which HTTP:Daemon obviously would provide 'out of the box' via do(), i figured).
It just seems to me that running a full-flegged Apache(2) only for executing a couple of CGIs and serving some static files is a bit of an overkill (and resource drain).
so, has anybody tried this, or does anyone know any obvious problems with this approach (performance, resources, configurations, overlooked difficulty of implementation)?

thanks for any pointers,

-schweini

Comment on using HTTP::Daemon instead of Apache
Download Code
Re: using HTTP::Daemon instead of Apache
by borisz (Canon) on Feb 03, 2004 at 23:32 UTC
    I have a similar system with a lot of HTTP::Daemon servers and they work great. I whould do it again.
    Boris
Re: using HTTP::Daemon instead of Apache
by tachyon (Chancellor) on Feb 03, 2004 at 23:56 UTC

    On Linux and average modperl apache process has a memory footprint of 2-5MB. A trivial Perl process has a memory footprint of 5MB++. A typical functional Perl daemon will consume 10MB without worries and often 20MB. Explain how this is more efficient? Have a look with top as YMMV.

    cheers

    tachyon

      On Linux and average modperl apache process has a memory footprint of 2-5MB

      I am not sure what you mean by "average," but I've found mine will range anywhere between 10MB and 30MB (this is for rather involved apps for bioinformatics).

      I've often seen 12-17MB cited as the expected range for "typical" webapps.

        Sorry I was referring to the C based httpd part not the Perl side. As noted a trivial perl script is 4-5MB and this is addidtive to the base. I have seen the same figures as you.

        cheers

        tachyon

      Ok, here is a little test prog with HTTP::Daemon it has a smaller memfootprint than any of my apache servers and serves about 800 requests/sec for a "hello world" example. Here is the output of ab followed by the script for your tests at home.
      ~/httpd/bin/ab -c 10 -n 500 http://peggy:9876/hello This is ApacheBench, Version 1.3d <$Revision: 1.69 $> apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustec +h.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apa +che.org/ Benchmarking peggy (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Finished 500 requests Server Software: libwww-perl-daemon/1.26 Server Hostname: peggy Server Port: 9876 Document Path: /hello Document Length: 12 bytes Concurrency Level: 10 Time taken for tests: 0.621 seconds Complete requests: 500 Failed requests: 0 Broken pipe errors: 0 Total transferred: 73500 bytes HTML transferred: 6000 bytes Requests per second: 805.15 [#/sec] (mean) Time per request: 12.42 [ms] (mean) Time per request: 1.24 [ms] (mean, across all concurrent request +s) Transfer rate: 118.36 [Kbytes/sec] received
      #!/usr/bin/perl use bytes; use HTTP::Daemon; use HTTP::Status; $SIG{PIPE} = 'IGNORE'; my $res = HTTP::Response->new(RC_OK); $res->content("Hello World\n"); $res->content_type('text/plain'); $|++; my $d = HTTP::Daemon->new( LocalPort => 9876, ReuseAddr => 1 ) || die; print "Please contact me at: <URL:", $d->url, ">\n"; for ( 1 .. 20 ) { my $pid = fork; next if $pid; next unless defined $pid; do { flock $d, 2; my $c = $d->accept; flock $d, 8; my $oldfh = select($c); $|++; select($oldfh); while ( my $r = $c->get_request ) { if ( $r->method eq 'GET' ) { #and $r->url->path eq "/hello" ) { $c->send_response($res); } else { $c->send_error(RC_FORBIDDEN); } } $c->close; undef($c); } while (1); exit 0; } while (1) { waitpid( -1, 0 ) }
      Boris
      Maybe less efficient in memory foot print, but possibly more efficient in time for implementation and maintenance. :)

      Play that funky music white boy..
Re: using HTTP::Daemon instead of Apache
by sri (Vicar) on Feb 04, 2004 at 00:15 UTC
    Apache/mod_perl is definitely faster, and would serve much more clients in less time.

    Mod_Perl's performance is not just a result of the persistent Perl Interpreter, it also benefits a lot from the Apache server doing all the network and parsing stuff.
    In fact all modules using Perl sockets are much slower than anything written in C.

    Listen to tachyon about the memory footprint.

    But if you don't need that performance boost and like HTTP::Daemon, just use it. ;)
Re: using HTTP::Daemon instead of Apache
by biosysadmin (Deacon) on Feb 04, 2004 at 02:23 UTC
    If ease of deployment really matters to you, use HTTP::Daemon. Running a full-fledged Apache for a couple of CGI's and static files may be more resource efficient in the end, but using HTTP::Daemon sounds like it could save a lot of your time over the long term, because you won't have to deal with maintaining Apache.

    :)
Re: using HTTP::Daemon instead of Apache
by perrin (Chancellor) on Feb 04, 2004 at 02:24 UTC
    If you just want a small and efficient server for CGI and static pages, you'd be better off using this.
Re: using HTTP::Daemon instead of Apache
by toma (Vicar) on Feb 04, 2004 at 09:03 UTC
    I use Apache and mod_perl for the server side apps. I wouldn't use HTTP::Daemon on the server side, because it is slow and doesn't have the administration features that I really need.

    One of our apps needed a little web server on the desktop, so for that we used HTTP::Daemon. This allows us to deploy a simple, more portable configuration to a large number of users. It's multiplatform, also.

    The biggest difficulty with Apache is the learning curve for doing complicated things. Apache tries to make simple things simple. Like just about everything else, it's not quite as good as perl in this regard.

    Apache has a modular architecture and can be built for low resource usage. 750K for an httpd process is not unusual. For CPU usage apache should be much lower.

    It should work perfectly the first time! - toma
Re: using HTTP::Daemon instead of Apache
by strat (Canon) on Feb 04, 2004 at 09:38 UTC
    Some time ago, I played around with a little chatwebserver which uses HTTP::Daemon. In the last months, I didn't have time to continue it because there is a lot to code for Perl-Community.de, so it is still alpha-code. You can download the last version from my homepage -> Downloads -> 3. Strat's Chatwebserver.

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Re: using HTTP::Daemon instead of Apache
by shotgunefx (Parson) on Feb 04, 2004 at 11:53 UTC
    For general serving needs I would definitely stick with Apache.

    I've got a few custom web servers that utilize HTTP::Daemon. I've been quite happy with the results. They deal with specific types of http requests and nothing else. Separating them from Apache gives me a lot of latitude as far as installation and configuration. Looking at my instances, they have a much smaller footprint than my Apache (which is on the lean side to begin with.) It's also trivial to install them elsewhere in case of emergencies (like the phone company cutting through a fiber and taking out most of the connectivity in Boston)

    -Lee

    "To be civilized is to deny one's nature."
•Re: using HTTP::Daemon instead of Apache
by merlyn (Sage) on Feb 04, 2004 at 18:35 UTC
Re: using HTTP::Daemon instead of Apache
by zby (Vicar) on Feb 10, 2004 at 14:38 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://326350]
Approved by Plankton
Front-paged by Plankton
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2014-07-30 09:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls