[web-devel] Hoogle Advice

Michael Snoyman michael at snoyman.com
Sun Jan 23 17:28:49 CET 2011


On Sun, Jan 23, 2011 at 6:15 PM, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Hi,
>
> I am the author of Hoogle (http://haskell.org/hoogle/), a Haskell API
> search engine, that is usually used through a web interface. I'm not
> an expert on website programming in Haskell, and I'm not a server
> admin by any means. Currently the web side of Hoogle can run in two
> modes - as a CGI binary (as deployed on haskell.org) or with "hoogle
> server" which starts its own server. I wrote both the CGI interface
> (see http://code.haskell.org/hoogle/src/General/Web.hs) and the server
>  (see http://code.haskell.org/hoogle/src/Web/Server.hs) myself. I
> imagine there is something in the web devel community that I should be
> using instead? If so, what is it, and how do I use it? I have a few
> requirements:
>
> * I have to be able to integrate it with haskell.org (which probably
> runs Apache?).
>
> * I also want to be able to run it as a server where the hoogle binary
> runs the server.
>
> * If I could get log/email messages whenever serving a page caused an
> exception, or took longer than a certain threshold, that would be
> great - but isn't necessary.
>
> * I'd like to log all queries run, and in particular how long they
> take, so I can investigate performance issues.
>
> Thanks for any advice you may be able to give,

Hi Neil,

I'm a big fan of your work, especially hlint and Hoogle. I'd be happy
to help you out as much as possible.

There are basically three ways you could interact with an Apache
server from Haskell:

* CGI
* FastCGI
* Reverse HTTP proxy

Essentailly, in a reverse HTTP, you'll have a standalone server
running on some port that never talks to the outside world, and Apache
will proxy all HTTP connections for your application to that server.
FastCGI is similar to CGI, except it allows for long-running
processes, as opposed to spawning a new process for each request.

There are at this point three main web frameworks in Haskell (that I'm
aware of, someone correct me if I'm wrong): Yesod[1], Happstack[2] and
Snap[3]. I'm the author of Yesod, so keep in mind that my opinions
will be biased. Snap only supports running as a standalone HTTP
server, so going with Snap will require reverse HTTP proxy. Happstack
has a FastCGI backend, though I don't know how well maintained it is.
In Yesod, all three options are considered first-class, though CGI
will probably not be very performant. (Yesod also support SCGI, though
I don't know how well Apache support SCGI.)

All of your desired features are easily implemented in Yesod except
the timeout one. I *think* that should be manageable using WAI
middlewares, though it will probably be even easier in the upcoming
Yesod 0.7 if/when we deploy general Yesod middlewares. (And no, I
don't expect any of that to make much sense to someone not involved in
these discussions.)

If you are interested in trying a migration to Yesod, just send me an
email (either privately or on web-devel).

Michael

[1] http://docs.yesodweb.com/
[2] http://happstack.com/index.html
[3] http://snapframework.com/



More information about the web-devel mailing list