使用OTP /二郎作为Web应用程序的基于组件的架构的一部分 [英] Using OTP/Erlang as a part of the component-based architecture of a web application

查看:214
本文介绍了使用OTP /二郎作为Web应用程序的基于组件的架构的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Erlang / OTP应用程序,做一些业务逻辑。这是写在二郎山主要用于容错,因为我可以很容易地重新启动系统的崩溃组成部分之一(高运行时间是最重要的要求)。
每个组件做某种特定的水货计算。

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 of the system (high uptime is the most important requirement). Each of its components does some sort of specific "parallel" computations.

作为一个工作循环的结果的应用程序产生的值的列表。让我们把这个二郎山/ OTP应用程序中的后端。

As a result of one working cycle the application produces a list of values. Let's call this Erlang/OTP application a "back-end".

这二郎山/ OTP应用程序也将使用PostgreSQL服务器来存储持久性存储的结果和存储需要为其计算(尚未实施)额外的元信息。

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

接下来,我需要一个前端添加到这个二郎山/ OTP应用程序 - 一个简单的基于Web的解决方案,它可以起到一个网络用户:接受来自他计算的请求/她,请后端做的计算,并给用户返回从后端的结果。

Next I need to add a front-end to this Erlang/OTP application - a simple web-based solution which can serve to a web user: accept a request for computations from him/her, ask the back-end to do the computations and give the user back the result from the back-end.

有没有可扩展性的要求,我觉得每天的最大用户数可以不超过1000。

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

所以,我现在的任务是实现一个共同的前端为我的后端二郎/ OTP应用程序(常见的手段我有一个典型的用例:访问该网站,注册,登录,使用应用程序,获得一个漂亮的ajax'y看网页上的结果,注销)。

So my current task now is to implement a common front-end for my back-end Erlang/OTP application (common means I have a typical use case: visit the site, register, log-in, use the app, get the result on a nice ajax'y looking web-page, log-out).

在一边,我知道,code再利用可以节省我很多时间:例如用Ruby on Rails的,我可以得到用户验证,密码存储,AJAX接口和一个免费的很多其他的东西。

On one side, I know that code reuse can save me a lot of time: for example with Ruby on Rails I can get user authentication, password storage, ajax interfaces and a lot of other stuff for free.

在另一边,我不知道设计一个应用程序,它包括一个Erlang / OTP +的PostgreSQL数据库服务器后端和web框架(回报率,Django的,等等)作为前端什么。

On the other side I do not know anything about designing an application which comprises an Erlang/OTP + PostgreSQL db server back-end and a web-framework (RoR, Django, etc) as a front-end.

在我心目中,我很多问题春:应该二郎山/ OTP和Web框架使用相同的PostgreSQL数据库共享的结果?什么是送从web框架到二郎山/ OTP应用程序中的计算请求,并把它找回来的最好方法?我如何监督PostgreSQL服务器 - 它不属于OTP的容错?

I lot of questions spring in my mind: Should Erlang/OTP and the web-framework use the same PostgreSQL database to share the result? What is the best way to send a computation request from the web-framework to the Erlang/OTP application and get it back? How do I supervise the PostgreSQL server - it is not covered by OTP's fault tolerance?

一般来说,我有几个异构的软件组件和我想从他们建立了一个工作系统('首席'组件是二郎山/ OTP应用程序)。

Generally speaking, I have a few heterogeneous software components and I want to build a working system from them (the 'chief' component is the Erlang/OTP application).

我在哪里应该完成这个任务开始?你能给我任何意见或暗示读哪些资源?

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

P.S。我曾尝试阅读并跟着链接,但不明白了。

P.S. I have tried to read this and followed the links, but did not understand much.

UPD:我知道芝加哥的老板和其他二郎网络框架确实存在,但我怀疑任何人有这样一个成熟的环境,充满活力的社区和不同的插件和库一样的巨大变化例如Ruby on Rails的,Django的或任何基于PHP的MVC框架。对?

UPD: I know that 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 different plugins and libraries like for example Ruby on Rails, Django or any PHP-based MVC framework. Right?

UPD2:也许我要细说了更深层次的:我还需要前端尽可能维护。在二郎山这样做就意味着我可能面临的问题找到合适的开发人员来维护它;在回报率,Django的,等等。这样做就意味着我可以很容易地找到工作的力量来维持前端和成长吧。

UPD2: Maybe I have to elaborate on this deeper: I also need the front-end to be as maintainable as possible. Doing it in Erlang means that I might face problems finding the right developers to maintain it; doing it in RoR,Django, etc. means I can easily find work force to maintain the front-end and to grow it.

推荐答案

首先,有一个Erlang PostGreySQL客户在这里: https://github.com/wg/epgsql 。另一件事是,你可能想看看的 ZOTONIC 。它是一种CMS用Erlang编写的,但它是一个Web框架,以及。它的特点之一是,它已经集成PostGreySQL数据库非常好,所以后面Zotoniuc所有二郎应用将受益于此。 MVC开发或事件驱动的Web应用程序时,这是非常不错的。搜索结果另外,你可能要检查出的 氮Web框架 和< b> 芝加哥老板 这也是二郎Web应用程序的Web框架。使用氮气,雅司病和Mnesia的一整套我亲自开发的Erlang的Web应用程序。一个非常好的好处是,你可以有这背后的技术堆栈数很多二郎应用。雅司病的Web服务器,其的 Appmods 动态内容服务的能力 (所以 RESTFUL 我可以向你保证),它已经授权我们的JavaScript驱动前端Web应用程序与这些惊人的简单和美丽,提供从一堆几个二郎应用服务。搜索结果

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.

如果你想有一个快速的Web前端,与Ajaxy / HTML5特性一样,那么快点,快点!抢你的自我在 氮Web框架 。既然你是一个Erlang程序员已经,这将是对你这么快。有了模板,你可以写HTML4.X / HTML5模板,或使用的 网页制作/ Studio软件 为您创造模板(S)。后来的后来,你会表现出氮哪里来的,你二郎神后端结合使用动态产生的 JQuery的 code从二郎code引起的。搜索结果你会发现文档很简单。氮是只是一个Erlang的记录集合,每个记录站立的HTML标签。其他记录用于定义特效和事件,这将是回发到您的二郎山应用。在氮开发Web漂亮界面是如此之快。逸岸,用动态生成的 JQuery的 code,你可以写自己的JavaScript成模板陪全部功能说,利用另一个JavaScript库像的 EXT JS MooTools的 原型JS 。在模板上,你可以指出哪里氮应该呈现动态生成的HTML元素以及JQuery的这些元素从而将AJaxically行为。在这种情况下,模板仅仅意味着一个HTML页面。

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.

结果记住成为其邮件列表的成员,才能找到更多的援助以及不停的问任何更多的问题在这里StackOverflow的。欢迎来到二郎Web开发的世界。有的几个环节,你可能感兴趣的(结果 IEEE皮书在二郎山Web开发 中,结果 Erlang的Web框架 中,结果的 erlydtl - 二郎神像Django的模板实现 中,结果的 ErlyWeb框架 的结果)的成功!
搜索结果


结果
修改
结果现在,你说的是真的。寻找开发者维护这将是一个任务。但是, Zotonic 正如我前面提到的是一个完全成熟的(网络) CMS 一样的Joomla或Word preSS等有了它,你,你自己可以实际管理/维护网站/应用程序。结果
结果但是,您也可以使用下发展Django的,或Ruby on Rails的web前端,但使用JSON格式的数据,以受Mochiweb 从你的Web前端。然后,使用 Mochijson2.erl 附带受Mochiweb,你解析JSON,并将其转化为您的二郎后端请求或方法和参数。这将在两个方向进行,即您请求您的二郎山应用,得到返回的结果,并使其作为JSON数据。搜索结果Mochiweb是这样,可以接口的任何二郎后端与任何Web技术的有力工具使用服务/ REST风格的模型前。其简单,重量轻。其快速,它需要的是你点它来处理哪些方法POST,GET,PUT e.t.c HTTP请求,它会等待结果发送回来。受Mochiweb已经在很多的Erlang系统例如被用于 沙发DB (上最先进的NoSQL数据库管理系统的一个改变我们理解Web的方式和SOA系统)和所有其他的系统,如 Membase的单服务器 大沙发/ Cloudant 等你可以看到有人把受Mochiweb在行动中的此处 那么在这里 最后这里 搜索结果
Django的,扭曲的,PHP或Ruby on Rails的框架,使JSON请求,并期望从二郎返回JSON响应端由受Mochiweb供电。 Erlang的网络后端的另一个伟大的RESTful接口是 Misultin ,它甚至还支持网络套接字,有时恐怕是最快/或最敏感的Erlang HTTP库:)搜索结果
根据我的经验,我有PHP大师,大师的JavaScript工作e.t.c.但我们发现更便宜的发展,只要我们把我们的Web服务器
雅司病 以<一个HREF =htt​​p://en.wikipedia.org/wiki/Service-oriented_architecture相对=nofollow>服务导向模式使用来自两个方向的JSON请求和响应。在这种情况下,我们DONOT失去Erlang的可用性和容错能力和方式,您可以通过使用的 JSONP 这是由所有的JavaScript和/或前Web框架的支持。我强烈建议你把受Mochiweb或Misultin在前面的二郎山后端,并有选择哪种曾经的Web框架,使得使用JSON格式(甚至XML请求,您将会解析使用 erlsom ,下载它的 此处 )。我希望你得到什么想建议。开通!


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!!!

这篇关于使用OTP /二郎作为Web应用程序的基于组件的架构的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆