Apache Thrift, Google Protocol Buffers, MessagePack, ASN.1 및 Apache Avro의 주요 차이점은 무엇입니까?
이들 모두는 이진 직렬화, RPC 프레임 워크 및 IDL을 제공합니다. 나는 그것들과 특성 (성능, 사용 편의성, 프로그래밍 언어 지원)의 주요 차이점에 관심이 있습니다.
다른 유사한 기술을 알고 있다면 답변으로 언급하십시오.
ASN.1 은 ISO / ISE 표준입니다. 매우 읽기 쉬운 소스 언어와 바이너리 및 사람이 읽을 수있는 다양한 백엔드가 있습니다. 국제 표준 (그리고 오래된 언어)이기 때문에 원어는 약간 부엌처럼 보이지만 (대서양이 약간 젖어있는 것과 거의 같은 방식으로) 매우 잘 지정되어 있으며 상당한 지원을받습니다. . (충분히 파고 FFI에서 사용할 수있는 좋은 C 언어 라이브러리가없는 경우 이름을 지정한 모든 언어의 ASN.1 라이브러리를 찾을 수 있습니다.) 표준화 된 언어이므로 강박 적으로 문서화되고 몇 가지 유용한 자습서도 있습니다.
중고품 은 표준이 아닙니다. 원래 Facebook에서 왔으며 나중에 오픈 소스로 제공되었으며 현재 최상위 Apache 프로젝트입니다. 잘 문서화되지 않았으며 (특히 튜토리얼 수준) 내 (아마도 간단하게) 한 눈에 이전의 다른 노력으로는 아직 수행하지 않은 (아마도 더 나은) 것을 추가하지 않는 것으로 보입니다. 공정하게 말하면, 주요한 비 주류 언어를 포함한 몇 가지 언어가 기본적으로 지원됩니다. IDL도 모호하게 C와 비슷합니다.
프로토콜 버퍼 는 표준이 아닙니다. 더 넓은 커뮤니티에 공개되는 Google 제품입니다. 기본적으로 지원되는 언어 (C ++, Python 및 Java 만 지원) 측면에서 약간 제한적이지만 다른 언어 (높은 가변 품질)에 대한 많은 타사 지원이 있습니다. Google은 Protocol Buffers를 사용하여 거의 모든 작업을 수행하므로 전투 테스트를 거친 전투 강화 프로토콜입니다 (ASN.1만큼 전투 강화되지는 않았지만 Thrift보다 문서가 훨씬 우수하지만 Google 제품은 불안정 할 가능성이 매우 높습니다 (신뢰할 수없는 것이 아니라 끊임없이 변하는 의미). IDL도 C와 비슷합니다.
위의 모든 시스템은 IDL에 정의 된 스키마를 사용하여 대상 언어에 대한 코드를 생성 한 다음 인코딩 및 디코딩에 사용합니다. 아브로는 그렇지 않습니다. Avro의 타이핑은 동적이며 스키마 데이터는 런타임에 인코딩 및 디코딩에 직접 사용됩니다 (이는 처리에 명백한 비용이 있지만, 동적 언어에 대한 명백한 이점이 있으며 태그 유형이 필요하지 않은 등). . 이 스키마는 JSON을 사용하므로 이미 JSON 라이브러리가있는 경우 새로운 언어로 Avro를 지원하기가 조금 더 쉽습니다. 다시 말하지만, 대부분의 휠 재개발 프로토콜 설명 시스템과 마찬가지로 Avro도 표준화되지 않았습니다.
개인적으로, 나는 그것과의 사랑 / 증오 관계에도 불구하고 실제로 RPC 스택을 가지고 있지는 않지만 대부분의 RPC 및 메시지 전송 목적으로 ASN.1을 사용할 것입니다. 충분히 간단합니다).
우리는 방금 serializers에 대한 내부 연구를했는데, 여기에 몇 가지 결과가 있습니다 (나중에 참조 할 것입니다!)
중고품 = 직렬화 + RPC 스택
가장 큰 차이점은 Thrift는 단순한 직렬화 프로토콜이 아니라 현대 SOAP 스택과 같은 완전한 RPC 스택입니다. 그래서 직렬화 후 개체가 있었다 (하지만 의무) TCP / IP를 통해 컴퓨터간에 전송 될 수있다. SOAP에서 사용 가능한 서비스 (원격 메소드) 및 예상 인수 / 객체를 완전히 설명하는 WSDL 문서로 시작했습니다. 이러한 객체는 XML을 통해 전송되었습니다. Thrift에서 .thrift 파일은 사용 가능한 메소드, 예상 매개 변수 오브젝트 및 오브젝트가 사용 가능한 직렬화 기 중 하나를 통해 직렬화됩니다 ( Compact Protocol
효율적인 2 진 프로토콜을 사용하여 프로덕션에서 가장 많이 사용됨 ).
ASN.1 = 그랜드 아빠
ASN.1은 80 년대 텔레콤 사람들에 의해 설계되었으며 CompSci 사람들로부터 나온 최신 시리얼 라이저들에 비해 라이브러리 지원이 제한되어 있기 때문에 사용하기에 불편 합니다. DER (바이너리) 인코딩과 PEM (아스키) 인코딩의 두 가지 변형이 있습니다. 둘 다 빠르지 만 DER은 두 가지 중 더 빠르고 크기 효율적입니다. 실제로 ASN.1 DER은 30 년 동안 설계된 시리얼 라이저를 쉽게 유지하고 때로는 이길 수 있습니다.그 자체로 잘 설계된 디자인의 증거입니다. Avro가 이길 수있는 매우 작은 프로토콜 버퍼 및 Thrift보다 작습니다. 문제는 지원할 훌륭한 라이브러리가 있으며 현재 Bouncy Castle은 C # / Java에 가장 적합한 것 같습니다. ASN.1은 보안 및 암호화 시스템 분야의 왕이며 사라지지 않을 것이므로 '미래 교정'에 대해 걱정하지 마십시오. 좋은 도서관을 찾으십시오 ...
MessagePack = 팩 중간
나쁘지는 않지만 가장 빠르거나 가장 작거나 가장 잘 지원되는 것은 아닙니다. 선택할 이유가 없습니다.
흔한
그 외에도 그것들은 상당히 비슷합니다. 대부분 기본 TLV: Type-Length-Value
원리의 변형입니다 .
Protocol Buffers (Google originated), Avro (Apache based, used in Hadoop), Thrift (Facebook originated, now Apache project) and ASN.1 (Telecom originated) all involve some level of code generation where you first express your data in a serializer-specific format, then the serializer "compiler" will generate source code for your language via the code-gen
phase. Your app source then uses these code-gen
classes for IO. Note that certain implementations (eg: Microsoft's Avro library or Marc Gavel's ProtoBuf.NET) let you directly decorate your app level POCO/POJO objects and then the library directly uses those decorated classes instead of any code-gen's classes. We've seen this offer a boost performance since it eliminates a object copy stage (from application level POCO/POJO fields to code-gen fields).
몇 가지 결과와 함께 연주 할 라이브 프로젝트
이 프로젝트 ( https://github.com/sidshetye/SerializersCompare )는 C # 세계에서 중요한 시리얼 라이저를 비교합니다. 자바 사람들은 이미 비슷한 것을 가지고 있다 .
1000 iterations per serializer, average times listed
Sorting result by size
Name Bytes Time (ms)
------------------------------------
Avro (cheating) 133 0.0142
Avro 133 0.0568
Avro MSFT 141 0.0051
Thrift (cheating) 148 0.0069
Thrift 148 0.1470
ProtoBuf 155 0.0077
MessagePack 230 0.0296
ServiceStackJSV 258 0.0159
Json.NET BSON 286 0.0381
ServiceStackJson 290 0.0164
Json.NET 290 0.0333
XmlSerializer 571 0.1025
Binary Formatter 748 0.0344
Options: (T)est, (R)esults, s(O)rt order, (S)erializer output, (D)eserializer output (in JSON form), (E)xit
Serialized via ASN.1 DER encoding to 148 bytes in 0.0674ms (hacked experiment!)
성능 측면에서 Uber는 최근 엔지니어링 블로그에서 이러한 라이브러리 중 몇 가지를 평가했습니다.
https://eng.uber.com/trip-data-squeeze/
그들을위한 승자? 압축을위한 MessagePack + zlib
우리의 목표는 인코딩 프로토콜과 압축 알고리즘의 조합을 가장 빠른 속도로 가장 컴팩트 한 결과로 찾는 것이 었습니다. 우리는 Uber New York City에서 2,219 개의 의사 랜덤 익명 트립 (텍스트 파일을 JSON으로 입력)에서 인코딩 프로토콜 및 압축 알고리즘 조합을 테스트했습니다.
The lesson here is that your requirements drive which library is right for you. For Uber they couldn't use an IDL based protocol due to the schemaless nature of message passing they have. This eliminated a bunch of options. Also for them it's not only raw encoding/decoding time that comes into play, but the size of data at rest.
Size Results
Speed Results
The one big thing about ASN.1 is, that ist is designed for specification not implementation. Therefore it is very good at hiding/ignoring implementation detail in any "real" programing language.
Its the job of the ASN.1-Compiler to apply Encoding Rules to the asn1-file and generate from both of them executable code. The Encoding Rules might be given in EnCoding Notation (ECN) or might be one of the standardized ones such as BER/DER, PER, XER/EXER. That is ASN.1 is the Types and Structures, the Encoding Rules define the on the wire encoding, and last but not least the Compiler transfers it to your programming language.
The free Compilers support C,C++,C#,Java, and Erlang to my knowledge. The (much to expensive and patent/licenses ridden) commercial compilers are very versatile, usually absolutely up-to-date and support sometimes even more languages, but see their sites (OSS Nokalva, Marben etc.).
It is surprisingly easy to specify an interface between parties of totally different programming cultures (eg. "embedded" people and "server farmers") using this techniques: an asn.1-file, the Encoding rule e.g. BER and an e.g. UML Interaction Diagram. No Worries how it is implemented, let everyone use "their thing"! For me it has worked very well. Btw.: At OSS Nokalva's site you may find at least two free-to-download books about ASN.1 (one by Larmouth the other by Dubuisson).
IMHO most of the other products try only to be yet-another-RPC-stub-generators, pumping a lot of air into the serialization issue. Well, if one needs that, one might be fine. But to me, they look like reinventions of Sun-RPC (from the late 80th), but, hey, that worked fine, too.
Microsoft's Bond (https://github.com/Microsoft/bond) is very impressive with performance, functionalities and documentation. However it does not support many target platforms as of now ( 13th feb 2015 ). I can only assume it is because it is very new. currently it supports python, c# and c++ . It's being used by MS everywhere. I tried it, to me as a c# developer using bond is better than using protobuf, however I have used thrift as well, the only problem I faced was with the documentation, I had to try many things to understand how things are done.
Few resources on Bond are as follows ( https://news.ycombinator.com/item?id=8866694 , https://news.ycombinator.com/item?id=8866848 , https://microsoft.github.io/bond/why_bond.html )
For performance, one data point is jvm-serializers benchmark -- it's quite specific, small messages, but might help if you are on Java platform. I think performance in general will often not be the most important difference. Also: NEVER take authors' words as gospel; many advertised claims are bogus (msgpack site for example has some dubious claims; it may be fast, but information is very sketchy, use case not very realistic).
One big difference is whether a schema must be used (PB, Thrift at least; Avro it may be optional; ASN.1 I think also; MsgPack, not necessarily).
Also: in my opinion it is good to be able to use layered, modular design; that is, RPC layer should not dictate data format, serialization. Unfortunately most candidates do tightly bundle these.
Finally, when choosing data format, nowadays performance does not preclude use of textual formats. There are blazing fast JSON parsers (and pretty fast streaming xml parsers); and when considering interoperability from scripting languages and ease of use, binary formats and protocols may not be the best choice.
'Programing' 카테고리의 다른 글
Markdown을 사용하여 단락에 클래스 이름을 정의 할 수 있습니까? (0) | 2020.07.13 |
---|---|
MVC에 다시 쓴 후 GUI가 작동하지 않음 (0) | 2020.07.13 |
canvas.toDataURL ()을 사용하여 캔버스를 이미지로 저장하는 방법? (0) | 2020.07.13 |
단방향 및 양방향 JPA와 최대 절전 모드 연결의 차이점은 무엇입니까? (0) | 2020.07.13 |
Android 기기에 신뢰할 수있는 CA 인증서를 설치하는 방법은 무엇입니까? (0) | 2020.07.13 |