Re: Ocamlnet2 + fastcgi

Gerd Stolpmann <[email protected]> Tue, 17 Oct 2006 00:36:01 +0200
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <[email protected]>
Am Dienstag, den 17.10.2006, 00:06 +0200 schrieb Grégory Guyomarc'h:
> Hello,
> 
> I am trying to get started with fastcgi and I wish to to use netplex
> for this but I can't seem to figure my way around the example in the
> directory cgi/netcgi2-plex of the distribution. I can run the netplex
> server from the command line but not from apache. I thought this
> example was a port of the ADD fastcgi example in ocamlnet1, but now I
> think I am probably wrong and something must be done before i can use
> it with apache: do i need a standard fastcgi script called from Apache
> that will relay fcgi request to the ADD netplex server I started
> manually ? 

In principle there is no extra relay necessary. Apache can directly talk
to an external fcgi server built with netplex. E.g. if I have

FastCgiExternalServer /home/gerd/public_html/sample.fcgi -host localhost:4444

in my Apache configuration, Apache assumes there were a script
sample.fcgi (although there is no such file), and to invoke this
imagined script, the already running (netplex) server on localhost port
4444 is used. This script would be invoked by an URL
http://localhost/~gerd/sample.fcgi.

It is certainly a bit strange that you must name a file with the
FastCgiExternalServer directive that does not exist. I guess the reason
is to make external servers fully compatible with the style where Apache
starts fcgi scripts.

See 
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html for
documentation.

Of course, you should not try to let Apache start your netplex server.
This won't work, it must already run.

> Another question, Ocamlnet2 seems very promising, however since I know
> so little about programming web apps, i want to be sure I am on the
> right track in choosing netplex (instead of starting from scratch
> because it looks like exactly what I need), I would like to build a
> web apps architectured along the lines below:
> 
> +----------+     +-------------+     +----------+
> |   Page   |---->|  Database   |<----|   Page   |
> | Server 1 |<----| Query Cache |---->| Server 2 |
> +----------+     +-------------+     +----------+
>       |                                  |
>       +-------------+      +-------------+
>                     |      | 
>                  +------------+
>                  |   Query    |
>                  | Dispatcher |
>                  +------------+
>                        ||
>                        ||
>                      Apache
> 
> My web host allows only short-lived fastcgi processes (around 4 or 5
> minutes before it is shut down), 

That sounds as if you cannot change the Apache configuration. Well, in
this case, you'll need the relay.

> so i would like the dispatcher to be that process and the servers to
> keep running even when the dispatcher is shut down. Also i want server
> processes to communicate via SunRPC and limit the use of fastcgi to
> the communication between Apache and the dispatcher, is that in the
> spirit of what can be achievable with netplex?

Yes, this is doable. Netplex can manage several servers at once that can
talk with each other.

Depending on whether you need the relay or not:

WITHOUT RELAY:

The query dispatcher is a fcgi server living inside netplex, and the
other servers are SunRPC servers inside netplex. The query dispatcher
uses SunRPC to call procedures in the other servers.

The question is whether this is reasonable, because in this case you can
easily incorporate all/most functions into the "dispatcher" which is
then actually the content server.

WITH RELAY:

The query dispatcher is a normal fcgi (built without netplex) that uses
SunRPC to call the other servers, and the other servers are inside
netplex.

This is a very reasonable setup.

Hope this answer helps.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
[email protected]          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642