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

后端 未结 2 373
南方客
南方客 2021-02-04 16:12

I have an Erlang/OTP application which does some business logic. It is written in Erlang mostly for fault-tolerance, because I can easily restart one of the crashed components o

2条回答
  •  抹茶落季
    2021-02-04 16:34

    First of all, there is an Erlang PostGreySQL Client here: https://github.com/wg/epgsql. Another thing is that you may want to check out ZOTONIC. Its a CMS written in Erlang but it is a Web framework as well. One of its features is that it has integrated PostGreySQL Database very well and so all Erlang applications behind Zotoniuc would benefit from this. It is very good when developing MVC or Event driven Web apps.

    Also, you may want to check out Nitrogen Web Framework and Chicago Boss which are also web frameworks for Erlang Web apps. I have personally developed Erlang web apps using Nitrogen, Yaws and Mnesia as a complete set. One very nice advantage is that you can have several many Erlang Applications behind this technology stack. Yaws web Server with its Appmods and dynamic Content Serving ability (so RESTFUL i can assure you that), it has empowered our JavaScript Driven Frontend Web Apps with such amazing simplicity and beauty, providing Services from a bunch of several Erlang Applications.

    If you want to have a fast Web Front End , with Ajaxy/HTML5 like features , then hurry, quick! and grab your self the Nitrogen Web Framework. Since you are an Erlang Programmer already, this will be so fast for you. With Templating, you can write HTML4.X / HTML5 Templates, or use a Web page Maker/Studio Software to create template(s) for you. Then later, you will show Nitrogen where to come in, binding your Erlang Backends to those nice Pages using Dynamically Generated JQuery Code arising from your Erlang Code.

    You will find the documentation very simple. Nitrogen is just a collection of Erlang Records, with each record standing for an HTML Tag. Other records are used for defining effects and events that will be POST back into your Erlang Application. Developing Web beautiful interfaces in Nitrogen is so fast. Infact, with the dynamically generated JQuery code, you can write your own JavaScript into the Template to accompany the entire functionality say, making use of another JavaScript library like EXT JS, or MooTools or prototype js. Within the template is where you will point out where Nitrogen should render the dynamically generated HTML Elements as well as JQuery which will "AJaxically" act on these elements. A template in this case simply means an HTML Page.


    Remember to become a member of its mailing list to find more assistance as well as keep asking any more questions here on StackOverflow. Welcome to the world of Erlang Web Development. Some several links you may be interested in (
    IEEE Paper on Web Development in Erlang,
    Erlang Web Framework,
    erlydtl - Erlang Django like Templating Implementation,
    ErlyWeb Framework
    ) Success !



    EDIT
    Now, what you say is actually true. Finding Developers to Maintain it would be a task. However, Zotonic as i mentioned earlier is a full fledged (Web) CMS just as Joomla or Word Press e.t.c. With it you, yourself can actually manage/maintain the site/application.

    However, you could also develope the Web front using Django, or Ruby on Rails but create Secure Services using JSON Formatted Data to Mochiweb from your Web front. Then, using Mochijson2.erl which comes with mochiweb, you parse the JSON and translate it into requests or methods and arguments in your Erlang Back-end. This would be done in both directions i.e. you make requests to your Erlang applications, get the returned results and render them as JSON data.

    Mochiweb is the powerful tool that can interface any Erlang Back End with any Web technology at the front using Service/ RESTFul Model. Its simple and light weight. Its fast and all it needs is you to point it to which methods to handle POST, GET, PUT e.t.c HTTP requests and it would wait for the results for sending back. Mochiweb has been used in very many Erlang systems e.g. Couch DB (one of the most advanced NoSQL DBMS changing the way we understand the Web and SOA Systems) and all those other systems such as Membase Single Server, Big Couch / Cloudant, e.t.c. You could see someone putting mochiweb in action here, then here and lastly here.

    Django, Twisted, PHP, or Ruby on Rails frameworks make JSON requests and expect JSON responses from Erlang Back ends powered by Mochiweb. Another great RESTful interface for Erlang Web Back-ends is Misultin, which even supports Web Sockets and is sometimes feared to be the fastest/ or most responsive Erlang HTTP library :)

    In my experience, i have worked with PHP gurus, JavaScript gurus e.t.c. but we find development cheaper whenever we put our Web server as yaws with a Service Oriented Model using JSON requests and responses from both Directions. In this case we donot lose on Erlang's availability and fault tolerance and by the way, you can make many requests to as many distributed Erlang Servers even if they are hidden in different Sub nets of Domains by using JSONP which is supported by all JavaScript and/or Front-web frameworks. I strongly advise you to put Mochiweb or Misultin in-front of your erlang Backend and have which ever Web framework you choose to make requests using JSON Format (or even XML, which you would parse using erlsom , download it here). I hope you do get what am suggesting. Success!!!

提交回复
热议问题