As a quick recap, I’m building a lightweight server side custom framework which focuses mainly on handling JSON service requests. This, combined with Mnesia, is our MC stack (Model – Controller). The client browser will be fully in charge of the ‘V’iew layer of the app.
(See our post Why Erlang ? for more information).
A stable version of the core has been finished a week ago. In brief, a request hits the server, Nginx proxies it to Mochiweb which starts a new process.
At this point the framework converts the posted data (JSON) to a native Erlang structure. We check if the request contains one or more services and, based on their name (=:= module), we spawn processes accordingly.
As you may have noticed, in order to save some http requests and to use the full power of our server, the client can ask for an array of services.
i.e. : Let’s imagine you are building a screen which is divided into multiple small independent functional parts : your preferences, your status, your personal info, whatever …, you have the choice to wrap all those service calls into one JSON and the framework will happily process those in parallel … fine isn’t?
At this stage of development, and provided that the DB is not fully populated, if I make a comparison with other developments I’ve done using other languages/architectures, my global feeling is : SPEED.
Whenever I find myself in the situation of using a ‘map’ function and depending on the computation weight on each element, I’m parallelizing the operation (pmap).
Coupled with PURE for the rendering at the client side, we aim to end up with a highly responsive application.
The job now is to continue on that track and make the whole thing even more flexible.
One of my concern when choosing Erlang was the lack of libraries compared to other languages such as Ruby. However, I found relatively easy to develop, from scratch, a mail module responsible to dynamically build messages to be send to one or more addresses (via Postfix) and a ‘captcha’ system.
Soon, I will say a little bit more about those two points and will also describe how to quickly set up an Ubuntu server running Erlang and friends.
Stay tuned