[ SRE_ARENA ]
DATA SERIALIZATION & FORMATS

Data Serialization: Stop Sending JSON Over the Wire

DOWNLOADING CONCEPT: 1. THE JSON TAX...
  • ↳JSON is amazing for web browsers.
  • ↳It's human-readable, schema-less, and native to JavaScript.
  • ↳However, it is terrible for high-throughput backend microservices.
  • ↳Why? 1.
  • ↳Network Size: Sending {"user_id": 12345, "status": "active"} takes 41 bytes.
  • ↳A massive percentage of your network bandwidth is wasted on string characters like quotes, colons, and curly braces.
  • ↳2. Parsing CPU: The receiving server has to read string characters, figure out where the quotes are, convert the ASCII string '12345' into an actual integer in memory, and allocate heap space.
  • ↳At 10,000 messages a second, JSON parsing can consume 40% of a server's entire CPU!
▲ LIVE INCIDENTA Java consumer reading from Kafka suddenly started throwing NullPointerExceptions and crashing.
sre@arena:~/data-serialization
sre@arena:~$ curl -s http://schema-registry:8081/subjects/orders-value/versions/latest | jq .