前端架构 [英] Frontend architecture

查看:134
本文介绍了前端架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我们有非常重量级的前端(前端+后端在一个应用程序实际上)。前端包含所有的逻辑:用户界面,业务逻辑,持久逻辑等。这是非常复杂的,难以维护,因为一些平台问题(它是用PHP编写的),如没有连接池,例如

For now we have very heavyweight frontend (frontend+backend in one application actually). Frontend contains all the logic: UI, business logic, persistence logic and so on. It's very complicated and hard to maintain, because of some platform problems (it's written in PHP) like absence of connection pooling, for example.

所以,我想出了一个主意分离前端和后端。后端可以写一些更方便易平台(我们计划使用Java),并且前端可以继续使用PHP。

So I came up with an idea to separate frontend and backend. Backend can be written in some more convinient platform (we plan to use Java), and frontend can continue use PHP.

我觉得UI逻辑是所有前端应该做的。而一些限制应适用于它在此执行codeBase的:

I think UI logic is all frontend should do. And some limitations should be applied to codebase which is executed here:


  1. 没有直接的数据库调用。 DB电话是难以扩展,难以提供SLA。

  2. 非阻塞集成plotocol到后端。如果前端要求的东西到后端,前端应该能不能对这个请求块。它可以帮助我们在两个方面:

  1. No direct database calls. DB calls are hard to scale and hard to provide SLA.
  2. Nonblocking integration plotocol to backend. If frontend asks something to backend, frontend should be able not to block on this request. It can help us in two ways:

一个。我们可以发送并行请求到后端(并行I / O);

a. we can send parallel requests to backend (parallelize I/O);

乙。我们可以提供的请求(SLA)的超时。有时,最好迅速失败,并不会阻止客户端。

b. we can provide timeout for requests (SLA). Sometimes it's better to fail quickly and do not block client.

因此​​,考虑到上述所有,我觉得对于前端的最佳架构(在我的情况,我不会传播银弹)是一种通信只能在非阻塞的方式REST / SOAP后端UI逻辑。你觉得这个东西是什么?

So, considering all above, I think the best architecture for frontend (in my case, i'm not propagate silver bullet) is UI logic which is communicates only to REST/SOAP backend in nonblocking way. What do you think about this stuff?

推荐答案

您可能要考虑的node.js为您的前端 - 它是新的,但它有一个非常酷的异步(即非阻塞)架构。是否意味着离开PHP的背后,但如果你做了重大改写反正这不会增加太多新的工作。

You may want to look into node.js for your frontend - it's new, but it has a really cool asynchronous (ie nonblocking) architecture. Does mean leaving PHP behind, but if your doing a major rewrite anyway that's not going to add too much new work.

这篇关于前端架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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