Wednesday, 5 March 2008

Apache + Erlang for dynamic web content

It dawned on me this morning that there is a way of using Apache (or any other web server for that matter) with Erlang to create dynamic web content...

How? Use FUSE. There is an implementation of FUSE for Erlang by the Dukes of Erl, called fuserl. If you haven't heard of FUSE, it's a way to make anything you want look like a file system. By using fuserl, you can make an Mnesia database (just one example) look like a file system. You can map queries to directories, and the files that are "listed" can contain the rows of your tables. But you can structure your filesystem in any way you want!

Take for example YoutubeFS: "YoutubeFS enables you to browse your favorite Youtube videos locally on your desktop without going to the youtube website. Just create a youtube account and add videos to your playlists, favorites list or subscribe to different channels. YoutubeFS then enables you to automatically load these videos to a local folder on your desktop. You can then view these videos (using a browser) as if they are local files."

If you extend this idea, you can imagine that you can point your Apache server to a FUSE filesystem location which generates the "contents" of the file system dynamically. To Apache it looks like it's serving normal files, but behind the scenes you can have a distributed Erlang system generating content for you...

This wouldn't work so well if you actually want to use parameters in your http queries, but then I would use Yaws with an appmod if that's what you need.

P.S. You don't have to use Erlang either, you can write FUSE file systems in many other languages...

No comments: