Web应用程序的体系结构:1或N API [英] Web apps architecture: 1 or n API

查看:136
本文介绍了Web应用程序的体系结构:1或N API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:
我在考虑Web应用程序的组织。我会分开回(API)前(网站的浏览器):2的应用,2库,2托管。接待会调用API几乎一切。

Background: I'm thinking about web application organisation. I will separate front (web site for browser) from back (API): 2 apps, 2 repository, 2 hosting. Front will call API for almost everything.

所以,如果我有两个单独的域名服务,我的API(例如:学习情境和语境预订),它们之间没有直接的联系,我应该建2 API(带2个库,2构建过程等)?它是建立 N API的一个很好的做法ñ需要或者一个大API?我谈到与TRAFIC大量的Web应用程序。

So, if I have two separate domain services with my API (example: learning context and booking context) with no direct link between them, should I build 2 API (with 2 repository, 2 build process, etc.) ? Is it a good practice to build n APIs for n needs or one "big" API ? I'm speaking about a substantial web app with trafic.

(我希望这个问题不会被关闭不建设性......我认为这是一个具体的情况下,真正的问题,对不起,如果不是,的这个问题以及其他一些关于架构并没有关闭,以便有矿山希望)

(I hope this question will not be closed as not constructive... I think it's a real question for a concrete case, sorry if not. This question and some other about architecture were not closed so there is hope for mine)

推荐答案

这一切都取决于你工作的你有等的应用,它的业务需求,优先级。一般来说,你有几种选择:

It all depends on the application you are working on, its business needs, priorities you have and so on. Generally you have several options:


  • 随时关注一个整体应用系统

  • 随时关注一个整体的应用,但在整个分离独立的模块/包/库域模型

  • 创建分布式架构(比如面向服务架构(SOA)和事件驱动架构(EDA))

一个整体应用

这是最简单,并制定其beggining阶段应用最便宜的方式。你不必担心复杂的架构,复杂的部署和发展的过程。如果没有许多开发商围绕它也工作得更好。

It's the easiest and the cheapest way to develop application on its beggining stage. You don't have to worry about complex architecture, complex deployment and development process. It also works better if there are no many developers around.

一旦应用程序正在成长,这种模式开始出现问题。你不能separatly部署模块,应用程序更易受反模式,面条code /设计(特别是当很多人做这个工作)。 QA过程需要的时间越来越长,这可能使其无法使用CI的基础上。像持续集成/运输/部署方法介绍也很多很多困难。

Once the application is growing up, this model begins to be problematic. You can't deploy modules separatly, the app is more exposed to antipatterns, spaghetti code/design (especially when a lot people working on it). QA process takes more and more time, which may make it unusable on CI basis. Introducing approaches like Continuous Integration/Delivery/Deployment is also much much harder.

在这种方法,你有你所有的API的一个版本库/生成过程中,

Within this approach you have one repo/build process for all your APIs,

一个整体的应用,但分离域模型

在这种方法,你仍然有一个很大的平台,但你连接的第三方基础logicaly单独的模块。例如,您可以提取一个模块,并从它创建一个库。

Within this approach you still have one big platform, but you connect logicaly separate modules on 3rd party basis. For example you may extract one module and create a library from it.

感谢您能够为不同的库引入独立的过程(QA,开发),但你还是要在一次部署整个应用程序。它还可以帮助您避免反模式,但它可能是很难保持跨库向后兼容的应用程序生命周期之内。

Thanks to that you are able to introduce separate processes (QA, dev) for different libraries but you still have to deploy whole application at once. It also helps you avoid antipatterns, but it may be hard to keep backward compatibility across libraries within the application lifespan.

关于你的问题,这样你有单独的API,开发过程和存储库每个式的行动只要你移动其领域逻辑独立的库。

Regarding your question, in this way you have separate API, dev process and repository for each "type of actions" as long as you move its domain logic to separate library.

分布式架构(SOA / EDA)

SOA有很大的利润。您可以介绍每个服务完全不同的流程:开发,QA​​,部署。您可以一次部署只是一个服务。也可以使用不同technolgies用于不同的目的。因为它涉及规模较小的项目QA过程变得更加可靠。您可以服务之间的通信版本(API),这使得他们更加独立。此外,您有更好的abilitly到horizo​​ntaly扩展。

SOA has a lot profits. You can introduce completely different processes for each service: dev, QA, deploying. You can deploy just one service at once. You also can use different technolgies for different purposes. QA process gets more reliable as it involves smaller projects. You can version communication (API) between services which makes them even more independent. Moreover you have better abilitly to scale horizontaly.

在高层建筑的另一方面的复杂性增加。你有更多的不同组成部分,你必须照顾好:服务,安全,服务情迷之间的认证/授权,分布式事务等。如果您的应用程序数据驱动(使用API​​来消费数据的独立前端)和特殊服务不需要传达给对方 - 这可能是没有那么多复杂(但这样的假设是IMO很危险,早晚信你就需要沟通他们)

On the other hand complexity of the high level architecture grows. You have much more different components you have to take care: authentication / authorisation between services, security, service discovering, distributed transactions etc. If your application is data driven (separate frontend which use APIs for consuming data) and particular services don't need to communicate to each other - it may be not as much complicate (but such assumption is IMO quite risky, sooner or letter you will need to communicate them).

在这种方法你有单独的API,有独立的仓库和独立的过程为每个式的行动(我的理解SS单独的域模型/服务)。

In that approach you have separate API, with separate repositories and separate processes for each "type of actions" (which I understand ss separate domain model / services).

正如我在beggining你选择的方式写依赖于applicatoin及其需求。总之,回到你原来的问题,我的建议是保持的API作为独立的,你可以。即使你有一个整体的应用程序,你应该能够版本的API separatly并保持其域逻辑分离。分离存储库和/或过程取决于您选择(例如,在这些之中我前面提到的)的方法。

As I wrote on the beggining the way you choose depends on the applicatoin and its needs. Anyway, back to your original question, my suggestion is to keep APIs as separate as you can. Even if you have one monolithic application you should be able to version APIs separatly and keep their domain logic separate. Separating repositories and/or processes depends on the approach you choose (eg. among these I mentioned before).

如果我错过了你的观点,请描述你所期望的答案更详细的方式。

If I missed your point, please describe in more detailed way what answer do you expect.

最好的!

这篇关于Web应用程序的体系结构:1或N API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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