难道,而不是来基于二进制的基于HTTP等文本自定义REST协议的好事吗? [英] Is it a good thing for a custom rest protocol to be binary based instead of text based like Http?

查看:172
本文介绍了难道,而不是来基于二进制的基于HTTP等文本自定义REST协议的好事吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你见过一个很好的理由来创建自定义的二进制协议休息而不是使用基本的HTTP REST实现的?

Have you ever seen a good reason to create a custom binary rest protocol instead of using the basic http rest implementation?

我目前工作在.net负责托管和消费服务的面向服务的架构框架。我不希望是基于像远程处理或WCF现有的框架,因为我要执行自定义优化总的灵活性和控制。

I am currently working on a service oriented architecture framework in .Net responsible for hosting and consuming services. I don't want to be based on an existing framework like Remoting or WCF, because I want total flexibility and control for performing custom optimization.

所以在这里我试图找到处理这个SOA架构的最佳协议。我喜欢REST的请求/响应无状态的连接性质和定义资源的URI,但我不喜欢HTTP的基于文本的本质。

So here I am trying to find the best protocol for handling this SOA framework. I like the request/response stateless connection nature of REST and the uri for defining resources, but I dislike the text based nature of HTTP.

下面是我的论据不喜欢HTTP,纠正我,如果我错了:

Here are my arguments for disliking HTTP, correct me if I'm wrong:


  • 首先一个证据,解析文本比分析二进制效率较低。
    我想preFER包含内容长度和二进制内容的固​​定长度的二进制头。

  • First an evidence, parsing text is less efficient than parsing binary. I'd prefer a fixed length binary header containing the content length and a binary content.

其次,不存在对HTTP请求的序列号的概念,所以相关联,其请求的响应的唯一方法是用于发送请求和接收响应的套接字连接。
这意味着只能在同一时间在指定插座一个未决的请求,所以如果一个服务消费者想要并行发送多个请求到一个服务,它需要打开多个套接字服务器。
自定义其余协议可以定义为请求的序列号,所以请求和响应将与序列号代替插座相关联,并有可能在平行送同一插座上的多个请求。
我觉得没有办法做到这一点与标准地HTTP,它可以使用自定义的基于文本的协议来完成,但为什么不让它基于二进制以提高性能。

Second, there is no notion of sequence number for http requests, so the only way of associating a response with its request is the socket connection used to send the request and receiving the response. This means there can only be one pending request at a time for a specified socket, so if a service consumer want to send multiple requests in parallel to a service, it need to open multiple socket to the server. A custom rest protocol could define a sequence number for requests, so request and response would be associated with the sequence number instead of the socket and there could be multiple requests sent in parallel on the same socket. I think there is no way to do this standardly with HTTP, it could be done with a custom text based protocol, but why not make it binary based to gain performance.

要添了几分方面,我国SOA框架并不需要从非净消费者访问,所以我不知道使用.net二进制格式化或其他自定义二进制格式化限制。

To add a little more context, my SOA framework does not need to be accessible from a non .Net consumer, so I have no restriction about using the .Net binary formatter or another custom binary formatter.

所以,我做我想要为一个自定义的二进制休息协议的任何意义吗?如果你觉得我错了,请告诉我你的论点。

So am I making any sense for wanting a custom binary rest protocol? If you think I'm wrong please tell me your arguments.

感谢。

推荐答案

你的数据包的数据可以是任何你喜欢的;是它的XML,明文,JSON或只是一个二进制格式。我认为没有理由强迫这些任何特定的一个在自己(使用什么是最恰当不过了)。

The data of your packets can be whatever you like; be it XML, Plaintext, JSON, or just a binary format. I see no reason to force any specific one of these on yourself (use whatever is most fitting).

不过,说二进制格式时,大多数人听到现场的长度等非常恼人的事情的固定格式。一般来说,如果你是不是从一个数据传输点的绝望,我看不出有任何理由去这样[尽管你可能做的.NET对象的二进制序列化,使他们能够重新实例[或看协议缓冲区lib中.NET]。

Though, when saying 'binary format', most people hear a fixed format of field-lengths and other really annoying things. Generally, if you aren't desperate from a data-transfer point of view, I see no reason to go this way [though you may do a binary serialisation of .net objects so they can be re-instantiated [or look at the 'protocol buffers' lib for .net]].

摘要:好像没事给我。不管你的船浮筒。

Summary: Seems okay to me. Whatever floats your boat.

这篇关于难道,而不是来基于二进制的基于HTTP等文本自定义REST协议的好事吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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