help with a multi process http server.
Andre Garzia
soapdog at mac.com
Mon Jan 22 14:25:31 EST 2007
Hello Folks,
I am here experimenting with a new approach to building revolution
based servers. We've been asking for threads or forks for a while but
until the day of such implementation comes, we need to use what we
can. One other language I always liked (to the point that we created
a whole company around it some years ago) was REBOL. I remember from
the blogosphere that someone did a REBOL based webserver with some
nice benchmarks, I decided to check it out because last I remembered,
REBOL was also a single thread language. After checking many sites, I
discovered that they along with other people around are using a
process pool and a scheduler that handles the connections and
redirect them to the next free process on the pool.
I decided to take the same approach, I made a tweeked version of my
RevHTTP server that can be launched from a shell() call so that I can
create a scheduler that can launch some number of processes to make
the pool. I created a simple communicating scheme using wget to make
little semaphores so that each server instance can tell the scheduler
where it is busy or free. So far, so good but there's one problem.
Suppose the scheduler is running 8080 and each server instance in the
pool is running from 8081 onwards. When the client connects to 8080,
the scheduler sends back a redirection response so that the client
refreshes to a different port (of a free instance in the pool). The
problem is that a http client such as a browser will then request
favico and all the links in the html from the same port for it re-
uses data from the connection that yielded that result to fill
missing data in the URL. For example, if you make a link that goes
to /newpage.html, then the server will make it http://yourserver/
newpage.html. If I answered from port 8081, all links in the page
will "inherit" that port and I want all the connections to come to
the scheduler running on a different port.
One approach to solve this is to parse all the response and change
all the html responses to include the correct URLs. This is very
boring and slow for we must cope with href, src, link, rel and all
kinds of css includes and stuff. What I hoped to find was some HTTP
header field that would tell like: "hey this server is acutally
running at port bla bla bla" such as:
host: localhost:8080
despite the fact that that answer came thru 8081. This way the whole
thing would work and maybe we would have a a web server built with
Rev that could see some real world use...
Anyone has two cents?
Andre
More information about the use-livecode
mailing list