直接访问数据库与Web服务 [英] direct access database vs web service

查看:117
本文介绍了直接访问数据库与Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们选择使用直接数据库访问还是使用Web服务时,优点和缺点是什么?

What are the pros and the cons when we have the choice between using direct database access or using web services?

对于应该响应(<0.5秒)且对该Web服务/数据库的调用较少的关键应用程序,您会选择什么?将由另一个团队维护。)

What would be your choice for a critical application that should be responsive (<0.5 sec) and with a low call to this webservice/DB (NB: the web service will be maintained by another team).

推荐答案

直接数据库访问将您紧密地绑定到架构。任何一端的变化都会影响另一端。但是它具有简单且只需较少网络跳数的优点。

Direct database access couples you tightly to the schema. Any changes on either end affects the other. But it's got the virtues of being simple and requiring one less network hop.

Web服务意味着可以通过更高一级的间接访问来实现更好的抽象和更宽松的耦合。 Web服务可以充当数据的单一管理者。当您只使用应用程序时,就可以直接使用数据库,但是如果其他应用程序出现并且需要相同的数据,则有一天他们将需要更改架构的机会增加了。这些更改也会影响您的应用程序。代价是更多的延迟。

A web service means better abstraction and looser coupling via one additional level of indirection. A web service can act as the single steward of the data. You'll get away with going directly against the database when it's just your app, but if other apps come along and require the same data you'll increase the chances that they'll need schema changes some day. Those changes will affect your app as well. The cost is more latency.

Web服务可以是集中授权和安全性的好地方。数据库也可以做到这一点,所以也许很容易。

A web service can be a good place to centralize authorization and security. A database can do this as well, so perhaps it's a wash.

这篇关于直接访问数据库与Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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