tags:

views:

604

answers:

4

I want to use Erlang for some background processing and stuff for a web app. I read about its concurrency handling and stuff and I have started learning it. What I want to do specifically is a persistent connection with the clients using COMET - with the Erlang process co-ordinating the HTTP client connections.

  1. Do I need a Erlang based web server for this?
  2. For the actual implementation, how does the "spawn"-ing work in Erlang. I downloaded the erlang ebook and read about spawning. In the case for my web based script, when two clients connect to the same Erlang script by making an HTTP request - can I automatically "spawn" new threads for each of them, and do message passing?
+3  A: 
  1. No, you didn't but it is simplest way. You can combine Erlang with libevent to achieve more http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-3/
  2. Yes, spawn new client is cheap, if you wont cheaper see above.
Hynek -Pichi- Vychodil
+2  A: 

I would highly recommend using an erlang based webserver to handle the comet connections. The lightweight processes in erlang are half the benefit of using it for this type of thing.

Most of the erlang webserver frameworks will handle the spawning for you. No need to reimplement it yourself. See nitrogen and mochiweb for examples of really dead simple comet implementations.

Jeremy Wall
A: 

Did you see the page http://beebole.com/erlang ?

It contains:

  • how to setup an Erlang environment(with Mochiweb) on Ubuntu

  • how to install the Nginx web server

  • a video tutorial to build a small web app using Erlang

Mic
A: 

You should investigate 'YAWS' (high performance HTTP server) modules: easy to write, full flexibility. YAWS is easily installed: apt-get install yaws (on Ubuntu at least).

jldupont