[Haskell-cafe] Light and fast http server

Michael Snoyman michael at snoyman.com
Sat Mar 12 20:04:35 CET 2011

On Sat, Mar 12, 2011 at 9:00 PM, Jeremy Shaw <jeremy at n-heptane.com> wrote:
> On Mar 11, 2011, at 4:39 PM, Victor Oliveira wrote:
>> Hi cafe,
>> There are a lot of http servers in hackage. I didn't have used none.
>> I would like to know if one of them is something closer of the nginx.
>> I need some light and fast. It don't need support all http, just the
>> basics is fine.
>> Suggestions?
> What do you mean by 'the basics'?
> happstack, yesod, and snap are all frameworks for building web applications.
> But it sounds like you are just looking for a web server to server static
> content for the disk? If so, what is the advantage you hope to get by using
> Haskell over nginx ?
> Any of the high-level frameworks can server static content pretty trivially.
> For example in Happstack you would just do:
>> module Main where
>> import Happstack.Server (Browsing(EnableBrowsing), nullConf,
>> serveDirectory, simpleHTTP)
>> main :: IO ()
>> main = simpleHTTP nullConf $ serveDirectory EnableBrowsing [] "."
> To serve files from the current directly.
> If that is all you really need, then I would probably recommend warp +
> wai-app-static,
> http://hackage.haskell.org/package/wai-app-static
> Warp is pretty darn fast. Though, in practice I think you will find that all
> of the frameworks/servers are going to have very similar results for serving
> static files since they all call sendfile() to do the bulk of the transfer.
> If you are looking for other features, then you need to say what those
> features are..
> - jeremy

Minor post-script: if all you need is warp + wai-app-static without
any custom code, then you can just use the warp-static[1] package. I
mostly just use this when testing HTML bundles on my work system and
need to serve from a web server to bypass Javascript-from-file://
issues. In production, if you really just need static file serving, I
would also tend to recommend nginx instead.


[1] http://hackage.haskell.org/package/warp-static

More information about the Haskell-Cafe mailing list