Take the 2-minute tour ×

I'm new to Erlang but I would like to get started with an application which feels applicable to the technology due to the concurrency desires I have.

This picture highlights what i want to do.


Where messages are pulled from a queue and routed to worker processes which have previously been setup as a result of a user making some input a form in a Django app. The setup requires some additional database (preexisting database so I don't want to use ETS/DETS for this bit) lookup which then talks to the message router and creates a relevant process.

My issue comes with given that I may want to ask my Django app in the future for all the workers that need to be setup and task them in the first place, what is the best way to communicate here. I favour HTTP/ json and have read up what little I can find on Mochiweb and MochiJson and I think that would do what I want. I was planning on having a OTP supervisor and application, so would it be sensible to have a seperate mochiweb process which then passes erlang messages to the router?

I have struggled a little with mochiweb due to all the tutorials talking about how you use a script to create a directory structure, which seems to put mochiweb centric to a design - which isn't want I want here, I want a lightweight mochiweb process that does occassional work.

Please tear this apart, all comments welcome.



share|improve this question
All mochiweb tutorials start off with the standard script to create a skeleton application because it saves you from creating a handful of files from scratch. It would be a real chore to teach people how to do that part in every tutorial. The output of this script is very similar to what you'd produce even in an application that does not use mochiweb, it just adds some stuff to ${app}_sup.erl and creates an ${app}_web.erl for you with some example code. –  YOUR ARGUMENT IS VALID Jul 20 '11 at 8:23

1 Answer 1

mochiweb is awesome but I think what you actually want is webmachine. The complete documentation is available here and here. In a nutshell, webmachine is a toolkit for making REST applications, which I think is what you want. It uses mochiweb behind the scenes but hides all of the complex (and undocumented) details. When you create a webmachine project you'll get a complete OTP application and a default resource. From there you'll do something like the following:

  1. Add your own resources (or modify + rename the default one).
  2. Modify the dispatcher so your resources and paths make sense for your app.
  3. Add code to create and monitor your worker processes - probably a gen_server and a supervisor. See this and related articles for ideas. Note you'll want to start both under the main supervisor provided to you when you created your project.
  4. Modify your resources to communicate with your gen_server.

I didn't quite follow everything else you are asking - it may be easier to answer any follow-up questions in comments.

share|improve this answer

Your Answer


