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

查看:31
本文介绍了直接访问数据库与 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 秒)并且对该网络服务/数据库调用较少的关键应用程序,您会选择什么(注意:网络服务将由另一个团队维护).

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天全站免登陆