开发者

Frontend architecture

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.

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.

I think UI logic is all frontend should do. And some limitations sho开发者_开发技巧uld be applied to codebase which is executed here:

  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:

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

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

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?


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.


Sounds fine to me, and you have the option of sucking info out of the (java?) BL both at the server-side and client-side (via AJAX).

I think UI logic is all frontend should do.

Yep - you're definately thinking straight :)


You can go with the below architecture.

  1. You can go with any of the JS framework like Angular 4 or ReactJS as both has server side rendering. This will work for Single/Multiple Application as well.
  2. Define the RestFul API with PHP where all business logics will be there. The API should be hosted in different server.
  3. To make API secured you can have OAuth authentication.
  4. If you use PHP, I suggest to use stored procedure instead of hard coded SQL queries or any ORM.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜