Why you Should Care About JSON Efficiency

We recently introduced some new functionality in our products to improve the efficiency of your applications when handling JSON – but we thought it would be useful to explain why it’s important, and why you care!

JSON has opened many doors for developers, making it simpler for apps to exchange data over the web and move beyond the strict and complex documentation formats of the past – such as XML. When Douglas Crockford proposed the JSON format, he was interested in defining an easy way for web applications and JavaScript-based clients to exchange and interact with data. From Doug’s early vision in the JavaScript community, JSON has become the de facto data interchange format across many use cases, and is the backbone of integration for today’s app economy.

There are many reasons why JSON has found favor amongst developers:

  1. Its schema-less data format makes it easy to integrate services
  2. The minimal number of data types offered keeps integration simple
  3. The human readable format makes it easy to understand, integrate and debug
  4. For web developers, it requires little effort to parse the content
  5. You’d be hard pressed to find a language that doesn’t offer full JSON support

Yet there are issues.

Applications have become increasingly complex; demanding large amounts of data, expecting frequent updates to that data, and dealing with the inherent limitations of the internet.

While JSON is the accepted standard these days for transmitting data to & from web-based applications, like many things we’ve accepted, it’s easy to take it for granted and not put much further thought into it. That’s why we have taken up the torch to show how and why you need JSON optimization!

The Problems

  • While better than the heavy-weight markup of XML, the tag structure is still wasteful
  • ASCII-based strings makes it simple, but at the expense of efficiency
  • There is no standard or efficient way of transmitting binary data
  • The HTTP request/response pattern compounds these inefficiencies when applications poll repeatedly for updates

 

The Solution

  • The request/response nature of HTTP means that applications consume resources for data that isn’t changing:

When applications poll the backend for updates they are often receiving data that hasn’t changed since the last time they asked. While not unique to JSON, this integration pattern amplifies the inefficiencies of data integration. Apps shouldn’t need to ask for updates, instead each business event that impacts an interested party should be sent automatically – in real-time.

  • JSON may generate less overhead than its predecessors, but the tags sent in each message are still sent over and over again:

Sending data over the wire has a cost, so the repetition of markup, tags or labels is wasteful. Applications only care about the information contained within these verbose messages, and the server shouldn’t send any more bytes than absolutely necessary.

  • For many applications, exactly the same JSON data is sent repeatedly or when only part of the message content has changed:

Beyond the tags / labels, for many messages (responses), applications receive a raft of data that hasn’t changed from the previous update. Again, the server needs a more efficient way of transmitting updates without saturating the network with data the app already knows.

  • Binary encoding will reduce the data over the wire, optimizing both simple types and raw binary data

Simply put, the convenience of human readable ASCII responses from the server absorb too much bandwidth. With binary encoding of JSON the message size can be greatly reduced – creating marginal benefits for simple data types, but massive improvements when transmitting binary (such is common for IoT).

We’ll be explaining more of details around JSON efficiency in our next eBook – which you’ll see published soon – but hopefully this begins to show why you should care as much as we do.

If you are evaluating realtime messaging solutions, have a look at Diffusion Cloud, the only data-efficient, real-time messaging service delivered via the cloud available at IBM Bluemix or Diffusion 5.7 is available now as a free download.