Using OTP / Erlang as part of the web application component architecture

I have an Erlang / OTP application that does some business logic. Erlang is written primarily for troubleshooting, because I can easily restart one of the broken components of the system (the most important requirement is a high uptime). Each of its components performs some specific "parallel" calculations.

As a result of one work cycle, the application creates a list of values. Let me call this Erlang / OTP application "back-end".

This Erlang / OTP application will also use the PostgreSQL server to store the results in persistent storage and to store additional meta-information necessary for its calculation (not yet implemented).

Next, I need to add an interface to this Erlang / OTP application - a simple web solution that can serve a web user: accept a request for calculations from him / her, ask him to do the calculations and return the result from the database to the user.

There is no scalability requirement, I think that the maximum number of users per day can be no more than 1000.

So, now my current task is to implement a common interface for my external Erlang / OTP application (usual means: I have a typical use case: visit the site, register, log in, use the application, get the result on a nice webpage with ajaxia, exit systems).

On the one hand, I know that reusing code can save me a lot of time: for example, with Ruby on Rails I can get user authentication, password storage, ajax interfaces and much more for free.

On the other hand, I do not know anything about developing an application that includes the server server server Erlang / OTP + PostgreSQL and the web framework (RoR, Django, etc.) as an interface.

I have many spring questions: if Erlang / OTP and the web environment use the same PostgreSQL database to share the result? What is the best way to send a calculation request from a web structure to an Erlang / OTP application and return it? How can I control a PostgreSQL server - is it not covered by OTP fault tolerance?

Generally speaking, I have several heterogeneous software components, and I want to create a working system out of them (the "main" component is an Erlang / OTP application).


Where should I start with this task? Can you give me any advice or hint, what resources to read?

PS I tried to read this and followed the links, but did not quite understand.

UPD: I know that the Chicago boss and other Erlang web frameworks do exist, but I doubt that any of them have such a mature environment, vibrant community and huge variability of various plugins and libraries, such as Ruby on Rails, Django or any PHP-based MVC framework. Correctly?

UPD2: Perhaps I need to dwell on this deeper: I also need the interface to be as convenient as possible. Doing this in Erlang means that I may have trouble finding the right developers to maintain it; By doing this in RoR, Django, etc., I can easily find the workforce to support the front-end and its growth.

+8
erlang architecture frontend backend otp
source share
2 answers

First of all, here is the Erlang PostGreySQL client: https://github.com/wg/epgsql . Another thing is that you can check ZOTONIC . Its CMS is written in Erlang, but it is also a web structure. One of its features is that it fully integrated the PostGreySQL database, and therefore all Erlang applications located behind Zotoniuc will benefit from this. This is very good for developing MVC or Event web applications.

You can also check out Nitrogen Web Infrastructure and Chicago Boss , which are also web frames for Erlang web applications. I personally developed Erlang web applications using Nitrogen, Yaws, and Mnesia bundled. One very nice benefit is that you can have multiple Erlang applications behind this technology stack. Yaws web Server with its Appmods and dynamic content ability (so RESTFUL can assure you that), it has provided our JavaScript Driven Frontend Web Apps with such amazing simplicity and beauty, providing services from multiple Erlang applications.

If you want to have a fast web interface with Ajaxy / HTML5 features, then hurry, fast! and capture yourself Nitrogen web structure . Since you are already an Erlang programmer, it will be so fast for you. With Templating, you can create HTML4.X / HTML5 templates or use the Maker / Studio Software web page to create a template for you. Then later you will see “Nitrogen”, where to go, binding your Erlang Backends to those nice pages, using Dynamically Generated JQuery Code derived from your Erlang code.

You will find the documentation very simple. Nitrogen is just a collection of Erlang entries, each entry of which refers to an HTML tag. Other entries are used to identify effects and events that will POST back to your Erlang application. Designing beautiful web interfaces in nitrogen is going so fast. Infact with dynamically generated jQuery code, you can write your own JavaScript in the Template to accompany all the functionality they say using another JavaScript library such as EXT JS , or MooTools or a prototype js . Inside the template, you specify where Nitrogen should display dynamically generated HTML elements, as well as JQuery, which will “AJaxically” affect these elements. The template in this case simply means the HTML page.


Be sure to become a member of your mailing list to find more help, as well as ask more questions here at StackOverflow. Welcome to the world of Erlang Web Development. A few links that may interest you (
IEEE Web Development Document in Erlang , Erlang Web Framework , erlydtl - Erlang Django, How to Implement Templates , ErlyWeb Framework
) Success!



EDIT
Now you are telling the truth. Finding Developers to support this will be a challenge. However, Zotonic , as I mentioned earlier, is a full-fledged (Web) CMS just like Joomla or Word Press, etc. With it, you yourself can manage / maintain the site / application.
However, you can also create a web interface using Django or Ruby on Rails, but create secure services using JSON formatted data for Mochiweb from your web interface. Then, using Mochijson2.erl that comes with mochiweb, you parse JSON and translate it into requests or methods and arguments into your Erlang Back-end. This will be done in both directions, i.e. You make requests to your Erlang applications, get the returned results, and display them as JSON data.

Mochiweb is a powerful tool that can interface with any Erlang Back End with any front-facing web technology using the Service / RESTFul Model. Its simple and light weight. Its fast and all you need to do is specify which methods to access the HTTP requests POST, GET, PUT etc, and it will wait for the results to be sent. Mochiweb is used in so many Erlang systems, for example. Couch DB (one of NoSQL's most advanced DBMSs, changing the way we understand Web and SOA Systems), and all those other systems like Membase Single Server , Big Couch / Cloudant , etc. You could see someone putting mochiweb in action here , and then finally here .

Django, Twisted, PHP, or Ruby on Rails make JSON requests and await JSON responses from Erlang Back running on Mochiweb. Another great RESTful interface for Erlang Web websites is Misultin , which even supports web sockets and sometimes fears being the fastest / most responsive Erlang HTTP library :)

In my experience, I worked with a PHP guru, a JavaScript guru etc, but we find development cheaper whenever we put our web server in yaws with a service-oriented model using JSON requests and responses from both directions. In this case, we do not lose the Erlang availability and fault tolerance, and by the way, you can make many requests to so many distributed Erlang servers, even if they are hidden in different subsets of domains using JSONP , which is supported by all JavaScript and / or Front-web frameworks. I highly recommend that you put Mochiweb or Misultin in front of your erlang Backend and create a web framework that you want to do using the JSON format (or even XML that you will parse using erlsom , download here ), I hope you get what offer. Success!!!
+4
source share

You can also implement your interface in erlang using any available web infrastructure . Running the interface and frontend on separate erlang nodes using erlang RPC to communicate between them.

+1
source share

All Articles