休息与肥皂.REST 有更好的性能吗? [英] Rest vs. Soap. Has REST a better performance?

查看:47
本文介绍了休息与肥皂.REST 有更好的性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了此处已发布的有关肥皂和休息的一些问题我没有找到我正在寻找的答案.我们有一个使用 Soap Web 服务构建的系统.该系统性能不高,正在讨论中将所有 Soap Web 服务替换为 REST Web 服务.有人认为 Rest 的性能更好.我不知道这是不是真的.(这是我的第一个问题)假设这是真的,使用休息而不是肥皂?(我们是不是丢了什么东西?)

I read some questions already posted here regarding Soap and Rest and I didn't find the answer I am looking for. We have a system which has been built using Soap web services. The system is not very performant and it is under discussion to replace all Soap web services for REST web services. Somebody has argued that Rest has a better performance. I don't know if this is true. (This was my first question) Assuming that this is true, is there any disadvantage using REST instead of Soap? (Are we loosing something?)

提前致谢.

推荐答案

性能是一个广泛的话题.

Performance is broad topic.

如果您指的是服务器的负载,则 REST 的性能要好一些,因为它在 HTTP 之上承担的开销最小.通常 SOAP 带有一堆不同的(生成的)处理程序和解析器.无论如何,性能差异本身并不大,但 RESTful 服务更容易扩展,因为您没有任何服务器端会话.

If you mean the load of the server, REST has a bit better performance because it bears minimal overhead on top of HTTP. Usually SOAP brings with it a stack of different (generated) handlers and parsers. Anyway, the performance difference itself is not that big, but RESTful service is more easy to scale up since you don't have any server side sessions.

如果您指的是网络的性能(即带宽),那么 REST 的性能要好得多.基本上,它只是 HTTP.没有开销.因此,如果您的服务无论如何都运行在 HTTP 之上,那么您将无法比 REST 更精简.此外,如果您使用 JSON(而不是 XML)对您的表示进行编码,您将节省更多字节.

If you mean the performance of the network (i.e. bandwidth), REST has much better performance. Basically, it's just HTTP. No overhead. So, if your service runs on top of HTTP anyway, you can't get much leaner than REST. Furthermore if you encode your representations in JSON (as opposed to XML), you'll save many more bytes.

简而言之,我会说是",您将使用 REST 提高性能.此外,它(在我看来)将使您的界面更容易为您的客户使用.因此,不仅您的服务器变得更精简,客户端也变得更精简.

In short, I would say 'yes', you'll be more performant with REST. Also, it (in my opinion) will make your interface easier to consume for your clients. So, not only your server becomes leaner but the client too.

但是,有几件事需要考虑(因为你问你会失去什么?"):

However, couple of things to consider (since you asked 'what will you lose?'):

RESTful 接口往往更健谈",因此根据您的域和您设计资源的方式,您最终可能会执行更多 HTTP 请求.

RESTful interfaces tend to be a bit more "chatty", so depending on your domain and how you design your resources, you may end up doing more HTTP requests.

SOAP 有非常广泛的工具支持.例如,顾问喜欢它是因为他们可以使用工具来定义接口并生成 wsdl 文件,而开发人员喜欢它是因为他们可以使用另一组工具从该 wsdl 文件生成所有网络代码.此外,作为表示的 XML 具有模式和验证器,这在某些情况下可能是一个关键问题.(JSON 和 REST 确实有类似的东西,但工具支持远远落后)

SOAP has a very wide tool support. For example, consultants love it because they can use tools to define the interface and generate the wsdl file and developers love it because they can use another set of tools to generate all the networking code from that wsdl file. Moreover, XML as representation has schemas and validators, which in some cases may be a key issue. (JSON and REST do have similar stuff coming but the tool support is far behind)

这篇关于休息与肥皂.REST 有更好的性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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