Tuesday, October 28, 2014

The Internet is running in debug mode

With the rise of the Web, textual encodings like xml/JSON have become very popular. Of course textual message encoding has many advantages from a developer's perspective. What most developers are not aware of, is how expensive encoding and decoding of textual messages really is compared to a well defined binary protocol.

Its common to define a system's behaviour by its protocol. Actually, a protocol messes up two distinct aspects of communication, namely:

  • Encoding of messages
  • Semantics and behavior (request/response, signals, state transition of communication parties ..)

Frequently (not always), these two very distinct aspects are mixed up without need. So we are forced to run the whole internet in "debug mode", as 99% of webservice and webapp communication is done using textual protocols.

The overhead in CPU consumption compared to a well defined binary encoding is factor ~3-5 (JSON) up to >10-20 (XML). The unnecessary waste of bandwith also adds to that greatly (yes you can zip, but this in turn will waste even more CPU).

I haven't calculated the numbers, but this is environmental pollution at big scale. Unnecessary CPU consumption to this extent wastes a lot of energy (global warming anyone ?).

Solution is easy:
  • Standardize on some simple encodings (pure binary, self describing binary ("binary json"), textual)
  • Define the behavioral part of a protocol (exclude encoding)
  • use textual encoding during development, use binary in production.
Man we could save a lot of webserver hardware if only http headers could be binary encoded ..

69 comments:

  1. There go all our pretty logs and quick curl tests and such. Text-protocols allow quick look into what's going on binary protocols don't. As far as I last checked services don't self heel - a human has to jump in. Which might be a reflection of other things going wrong but that is how it is :)

    ReplyDelete
    Replies
    1. I think that's a narrow view. In fact, text is also binary encoded. Its because of standardization on how to read e.g. UTF-8, tools "know" how to decode it. One could standardize on a self-describing binary format and provide a similar tool chain of "pretty printers" without problems (think of it like a "special" charset encoding). However in the first place protocol behaviour must not be mixed up with message encoding

      Delete
    2. """ and provide a similar tool chain of "pretty printers" without problems (think of it like a "special" charset encoding)"""

      This is an even more narrow view. Text formats work with what we already have, here and now. What you propose is replacing for something that's not out there, is not inoperable, and most tools don't know about it.

      First get the tooling you say it's easy to provide "without problems", then ask for the change to binary formats.

      Delete
    3. I'd like to remind you the internet should serve users not developers :). Anyway Http 2 will solve the issues. Took only like 15 years and will take like 10 years until its widely adopted :)

      Delete
  2. I fully agree in your desire to separate protocol handling from that of encoding (format). Doing this is under-appreciated way to both decouple handling, and to allow for more efficient handling, by choosing the most suitable encoding for context. Sometimes this should be a well-known textual format (for inter-operability, flexibility and diagnostics); other times a more compact binary representation makes more sense. Protocols should not unnecessarily limit the choice.

    I am not sure I share your concern on performance aspects: without disputing specific encoding numbers, I just question their significant in big picture. In case of HTTP, for example, decoding of Header values is a miniscule part of handling that even if it was changed to binary encoding, benefits in many cases would not be significant at all. Payload remains as-is, and the real complexity in HTTP comes from managing connections, state, liveness checks and other protocol level aspects.

    ReplyDelete
    Replies
    1. regarding the Http-Header I left out context. E.g. for a low-latency, many client long polling http server, the payload consists of a single sequence number (of last received message), so header parsing indeed adds significant overhead in case there are no pending messages (processing is session lookup+sequence number comparision) for this special case. Another example is DOS-protection. It eats significant processng time to weed out DOS requests from application requests.

      Delete
    2. Ofc in generaö you are right in that "header parsing" is not a good example regarding the big picture...

      Delete
    3. Any in-between component (proxy, reverseproxy) needs to encode and decodes (parse) headers, it's probably f relevance especially for tiny payloads typical for e.g. webservice remote calls

      Delete
  3. My best citation on the mec.symp.group ...The next time i've to write another Json parser/serializer (brrrr Jackson...:() i'll pray that someone listen to you..
    :) thanks Rüdiger

    ReplyDelete
    Replies
    1. You are doing jackson wrong, it helps dealing with json and afaik is pretty fast, it has not invented JSon ..

      Delete
    2. The java binding and the streaming API are not free..in any way.Although Jackson is "pretty" fast it not deliver any zero-copy (AFAIK) ability in the serialisation stage...and produce TONS of garbage.Comparing it with a serious serializer ( hand-made?) and really GC-free is simple. But that's another story...so far if i'll have to send a long why on earth i've to send more than 8 bytes? ^^ P.s. Jackson is not a bad tool per se and i avere with you that is a great help if you don't want to deal directly with Json...

      Delete
    3. Hm .. do you have kind of reusable opensource variant of a zero copy, low garbage json parser ? I'd be interested in something like that, as Jackson doubles some stuff i already do in the serialization layer, such that JSon-Codec is well below what would be possible.

      Delete
    4. Hi Rüdiger,
      I've only custom own-rolled libs that i've developed for my own needs...undocumented too :P
      But TextWire of https://github.com/OpenHFT/Chronicle-Bytes looks very promising...if you'll wait few weeks i've contacted Peter Lawrey to contribute to this repo and maybe there will be a little more docs and example for it :)

      Delete
    5. Wrong repo sorry :P
      I really need a coffee this morning...https://github.com/OpenHFT/Chronicle-Wire

      Delete
    6. Interesting bottom up.approach (many "planned" features though ;) ). In contradiction fast-serialization goes top down providing different wire formats to represent serialized object graphs (binary,json). Maybe i could add a chronicle wire Codec to fst once C-wire is in a more mature state

      Delete
  4. MsgPack is efficient, schema-less, and has a 1:1 mapping with JSON (unlike BSON despite its name).

    ReplyDelete
    Replies
    1. I am aware of msgpack. I even tried to build a codec for fast serialization based on msgpack but somehow lost track. Might be a better alternative to json for actor <=> javascript remoting. Are there any java benchmarks ?

      Delete
  5. I used to push Sun's XDR [1] for this very reason. Client-server apps with binary protocols, too. That's because the web was more inefficient, complex, and insecure in about every area. It was crap. It's main advantages were the networking effect, instant distribution, and widespread compatibility of HTML/JS. We could've just fixed the problems in our native C/S and P2P models but adopted web instead.

    Two other good alternatives from long ago were Juice [2] for applets and Globe [3] for WAN architecture.

    [1] https://en.wikipedia.org/wiki/External_Data_Representation

    [2] http://www.modulaware.com/mdlt69.htm

    [3] http://www.cs.vu.nl/~philip/globe/

    Nick P

    ReplyDelete
    Replies
    1. wow, the globe project looks interesting. Annoyed by lack of abstraction and poor performance of existing distributed application products, I am active in a somewhat similar direction: http://ruedigermoeller.github.io/kontraktor/ . Well its actually mostly JVM bound erm and not that global ;).

      Delete
  6. We use binary protocols from day 1 at Aerospike - that's one of the "small" reasons we massively reduce server counts compared to other databases. You might be surprised how hard it is to fight against an entire industry - hardware companies don't like getting cut out, cloud companies don't like getting cut out, open source companies that charge by node count don't like getting cut out. All of these guys pay lip service to efficiency, then bury technology that is actually more efficient. Flash (SSD) storage is similar - you end up paying a lot less for most use cases compared to DRAM and compared to Rotational, but only a handful of database companies have optimized for Flash.

    ReplyDelete
    Replies
    1. Agree. In addition there is widespread lack of knowledge of what is technically possible. People's gut has adopted to crappy tech. Premature scaleout dominates.

      Delete
  7. It's better to use binary protocol for service to service communication, much more efficient than any text protocol, takes less bandwidth too.

    ReplyDelete
  8. This article is very informative and easy to understand. Thank you for sharing!


    ReplyDelete
  9. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    thesis Writing Service

    ReplyDelete
  10. Devops is not a Tool.Devops Is a Practice, Methodology, Culture or process used in an Organization or Company for fast collaboration, integration and communication between Development and Operational Teams. In order to increase, automate the speed of productivity and delivery with reliability.

    python training in bangalore
    aws training in bangalore
    artificial intelligence training in bangalore
    data science training in bangalore
    machine learning training in bangalore
    hadoop training in bangalore
    devops training in bangalore

    ReplyDelete
  11. Gaining Python certifications will validate your skills and advance your career.
    python certification

    ReplyDelete
  12. Good article about Java. There's a lot of good points here and you explained them very well. www.spectrummobile.com/activate

    ReplyDelete
  13. Good Post
    Yaaron Studios is one of the rapidly growing editing studios in Hyderabad. We are the best Video Editing services in Hyderabad. We provides best graphic works like logo reveals, corporate presentation Etc. And also we gives the best Outdoor/Indoor shoots and Ad Making services.
    video editing studios in hyderabad
    short film editors in hyderabad
    corporate video editing studio in hyderabad
    ad making company in hyderabad

    ReplyDelete
  14. Nice Blog
    "Pressure Vessel Design Course is one of the courses offered by Sanjary Academy in Hyderabad. We have offer professional
    Engineering Course like Piping Design Course,QA / QC Course,document Controller course,pressure Vessel Design Course,
    Welding Inspector Course, Quality Management Course, #Safety officer course."
    Piping Design Course in India­
    Piping Design Course in Hyderabad
    QA / QC Course
    QA / QC Course in india
    QA / QC Course in Hyderabad
    Document Controller course
    Pressure Vessel Design Course
    Welding Inspector Course
    Quality Management Course
    Quality Management Course in india
    Safety officer course

    ReplyDelete
  15. If you are stuck with your online management assignment then in this case you can opt for our Database Management Assignment help. we provide the best assignment assignment help online.
    We also provide Advanced Database Management System help. for students across the globe.
    for more information contact us +16692714848

    ReplyDelete
  16. Students find Nursing Assignment Writing Services as being of great assistance since they are able to seek our custom nursing research writing services and nursing homework assignment help services on time.

    ReplyDelete
  17. Custom psychology research writing services have become very popular among students seeking Psychology Assignment Writing Services and psychology essay writing services.

    ReplyDelete
  18. The Dubai Lands is a Dubai Real Estate company where clients can find all recent projects and off-plan project-related useful information.

    ReplyDelete
  19. great java tips At SynergisticIT we offer the best java bootcamp

    ReplyDelete
  20. Thanks, this is generally helpful.
    Still, I followed step-by-step your method in this Java online training
    Java online course

    ReplyDelete
  21. Besides my C course, I have a job and family, both of which compete to get my time. I couldn't find sufficient time for the challenging C assignments, and these people came in and saved my skin. I must commend them for the genius Programming Assignment Help. Their C Homework Help tutors did the best job and got me shining grades.

    ReplyDelete
  22. I am looking for a Statistics Assignment Help expert for Statistics Homework Help. I have struggled enough with statistics and therefore I just can't do it anymore on my own. . I have come across your post and I think you are the right person to provide me with SPSS homework help. Let me know how much you charge per assignment so that I can hire you today

    ReplyDelete
  23. Matlab Assignment Help helped me to complete my seventh Matlab assignment, which was also the best-performed! It scored 92/100, which I've never scored before on any other assignment/exam in my lifetime. Otherwise, their service was as quick as usual. The delivery was also on time. I'm now requesting to use this same programmer multiple times. He seems the best in Image Processing tasks. Meanwhile, I'll ask for more Matlab Homework Help soon.

    ReplyDelete
  24. I have just come across your post and I believe this is exactly what I am looking for. I want an economics assignment help from a tutor who can guarantee me a top grade. Do you charge per page or does it depend on the
    bulk of the economics homework help being completed? More to that if the work is not good enough do you offer free corrections.

    ReplyDelete
  25. Hi, other than economics assignment help are there other subjects that you cover? I am having several assignments one needs an economics homework help expert and the other one needs a financial expert. If you can guarantee quality work on both then I can hire you to complete them. All I am sure of is that I can hire you for the economics one but the finance one I am not sure.

    ReplyDelete
  26. Me and my classmates took too long to understand Matlab Assignment Help pricing criteria. we're always grateful for unique solutions on their Matlab assignments. Matlab Homework Help experts have the right experience and qualifications to work on any programming student's homework. They help us in our project.

    ReplyDelete
  27. The ardent Programming Homework Help tutor that nailed down my project was very passionate. He answered my Python questions with long, self-explanatory solutions that make it easy for any average student to revise. Moreover, he didn't hesitate to answer other questions, too, even though they weren't part of the exam. If all Python Homework Help experts can be like this then they can trend as the best Programming school ever online.

    ReplyDelete
  28. Hey STATA homework help expert, I need to know if you can conduct the Kappa measurement of agreement. This is what is in my assignment. I can only hire someone for statistics assignment help if they are aware of the kappa measurement of agreement. If you can do it, then reply to me with a few lines of what the kappa measure of agreement is. Let me know also how much you charge for statistics homework help in SAS.

    ReplyDelete
  29. Hey there, I need an Statistics Homework Help expert to help me understand the topic of piecewise regression. In our lectures, the concept seemed very hard, and I could not understand it completely. I need someone who can explain to me in a simpler way that I can understand the topic. he/she should explain to me which is the best model, the best data before the model and how to fit the model using SPSS. If you can deliver quality work then you would be my official Statistics Assignment Help partner.

    ReplyDelete
  30. I don’t have time to look for another expert and therefore I am going to hire you with the hope that I will get qualityeconomics assignment help. .Being aneconomics homework help professor I expect that your solutions are first class. All I want to tell you is that if the solutions are not up to the mark I am going to cancel the project.

    ReplyDelete
  31. That is a huge number of students. Are they from the same country or different countries? I also want your math assignment help. I want to perform in my assignments and since this is what you have been doing for years, I believe you are the right person for me. Let me know how much you charge for your math homework help services.

    ReplyDelete
  32. Hello. Please check the task I have just sent and reply as soon as possible. I want an adjustment assignment done within a period of one week. I have worked with an Accounting Homework Help tutor from your team and therefore I know it’s possible to complete it within that period. Let me know the cost so that I can settle it now as your Accounting Assignment Help experts work on it.

    ReplyDelete
  33. High quality economic Assignment Help at highly competitive rates. Get microeconomics assignments prepared by highly qualified professionals and score high grades on all your assignments.

    ReplyDelete
  34. really infomative and eduvcative article thanks publisher for sharing this info with us furniture flipping secret review
    whatsaup flippzilla

    ReplyDelete
  35. Get in touch with us immediately to get the assignment help on any exposition theme! We don't have any issues in making expositions or some other homework assignments help of any size and organization. cheap assignment help

    ReplyDelete
  36. My Assignment Help Now is a valuable source of getting experts’ help for academic papers. Connecting with the well-qualified professionals helps you to score top grades. Students who have no ideas about how to start their papers, they can search for our superior online assignment help service to compose their documents.

    ReplyDelete


  37. Hey friend, it is very well written article, thank you for the valuable and useful information you provide in this post. Keep up the good work! FYI, please check these depression, stress and anxiety related articles:
    Essay on Neeraj Chopra , The Alchemist book review

    ReplyDelete
  38. Hurrah! Finally I got a weblog from where I be able to actually take valuable facts concerning my study and knowledge. Also visit my website: 바카라사이트

    ReplyDelete
  39. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot. Also visit my website: 바카라사이트

    ReplyDelete
  40. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also Also visit my website: 바카라사이트

    ReplyDelete
  41. You made some respectable factors there. I seemed on the web for the issue and found most people will go along with together with your website. Also visit my website: 바카라

    ReplyDelete
  42. Thank you for posting such a great article! It contains wonderful and helpful posts. Keep up the good work

    ttms login

    ReplyDelete
  43. Gaining gradual knowledge is possible as you know the valid art to achieve the most suitable result. That’s why I stay tuned with your blog to know what is going in the upcoming market. For getting the most suitable answer in your academic paradise, you can go through assertive service of Online Assignment Helper in USA. We will provide you on time solution

    ReplyDelete
  44. Do not waste countless hours on your college assignments anymore. Get Marketing 2016 18th Edition Test Bank and work smart with better results.

    ReplyDelete
  45. The work which is done by Abc assignment help is always best. The work is done accurate and in informative way. They take very less charges for there services. assignment help

    ReplyDelete

  46. I really love this blog post. It is quite informative and also rich in quality informational detail for all types of readers. I am a routine researcher and reader who read different blog posts on a daily basis for the sake of knowledge. So as a part of readers' society, I want to pay my role in increasing the knowledge of other readers and researchers. I recently wrote a piece with the same quality of information on custom builders, you can also read it. This will surely increase the knowledge and the interest of readers who regularly visit your site.

    ReplyDelete