jacobsteve
jacobsteve

Reputation:

Erlang as a backend process

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?

Upvotes: 3

Views: 3183

Answers (5)

Oliver Mason
Oliver Mason

Reputation: 2270

Another option would be to use Nitrogen - this allows an easy integration of Erlang code in web pages, including a fully-fledged webserver, and comet.

Upvotes: 1

Hynek -Pichi- Vychodil
Hynek -Pichi- Vychodil

Reputation: 26121

  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 want cheaper see above.

Upvotes: 6

jldupont
jldupont

Reputation: 96716

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).

Upvotes: 1

Mic
Mic

Reputation: 25154

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

Upvotes: 1

Jeremy Wall
Jeremy Wall

Reputation: 25237

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.

Upvotes: 5

Related Questions