Technical newsheet
Industrial IoT & MonitoringDevice profile
gRPB-M2M Beats JSON/MQTT on Bytes and Late Commands, Benchmarks Say
gRPB-M2M runs typed gRPC calls as Protobuf frames over MQTT 5: 425-byte sensor readings vs 766 for JSON, zero late commands in crash tests, and a 25-line ACME CSE patch.
By Amara Osei5 min read1,080 words
Features
- Sensor readings measured at 425 bytes with Protobuf vs 766 (JSON) and 580 (CBOR) — 0.56× and 0.74× respectively, steady across four emulated networks.
- Crash/freeze tests: JSON-over-MQTT executed 35–56 commands up to 16 s late; gRPB-M2M executed zero, with ~250 ms fail-fast via MQTT Last Will.
- At 50 sensors, Protobuf and CBOR saturated one core of the CSE and only 60–65% of Protobuf readings got through, vs sub-1.5 s round trips for JSON.
- Released on PyPI under Apache-2.0 as grpb-m2m; evidence from a 90-run, two-hour Raspberry Pi 4 benchmark is on GitHub.
- Topic aliases cut a streamed sample from 162 to about 90 bytes; a vnd.onem2m-res+protobuf media-type proposal to oneM2M is planned.

A sensor reading costs 425 bytes with gRPB-M2M's Protobuf encoding, against 766 bytes for JSON and 580 for CBOR — and in crash tests, the library executed zero late commands where JSON over MQTT executed up to 56, some 16 seconds after issue. Those numbers come from a two-hour benchmark run on a Raspberry Pi 4: 90 runs, 83 completed, every measurement recorded to CSV, under four emulated networks (LAN, Wi-Fi, 4G, and a 1 Mbit/s link with 2% loss via tc netem). The full evidence, including raw results, is on GitHub.
gRPB-M2M ("gRPC + Protobuf for M2M") is published on PyPI under Apache-2.0. It carries typed gRPC calls as Protobuf frames through any MQTT 5 broker, and adds Protobuf as a third serialization for oneM2M primitives (the standard's AE, container, content-instance, subscription and notification objects) next to JSON and CBOR in the ACME CSE (the open-source oneM2M service core), via a roughly 25-line patch.
Why put gRPC on a broker at all?
Plain gRPC needs HTTP/2 and a direct connection from caller to device, which devices behind NAT or on cellular links can't accept — the reason IoT uses MQTT brokers in the first place. gRPB-M2M keeps the .proto file and the code grpcio-tools generates; only two lines change. grpc.server() becomes grpb.MqttServer(...), and grpc.insecure_channel() becomes grpb.MqttChannel(...). Devices are addressed by name, not IP address, and need only an outbound connection to the broker. The developer puts the server half on a Raspberry Pi, the client on a laptop, points both at one broker, and it works with no open ports on the Pi.
Each call is one small Protobuf frame carrying a call ID, a 4-byte method ID, the serialized request, a status code, a timeout and an absolute deadline. Frames ride on topics following oneM2M's MQTT binding (TS-0010) with a pb format segment.
What do the measurements actually show?
The size ratio held steady across all four networks: 0.56× JSON, 0.74× CBOR, measured as exact MQTT packet sizes counted by the library — topics and properties included, not just payloads. Notifications to an alert service shrank to 292 bytes from 582. For 50 sensors reporting every 5 seconds, that's 366 MB per day instead of 662 MB. In every run, 10 of 10 containers read back over plain HTTP/JSON matched exactly what the Protobuf devices wrote; existing oneM2M apps need no changes.
MQTT 5 topic aliases cut a streamed sample from 162 bytes to about 90 by replacing the ~40-byte topic string with a 2-byte number in both directions. Broker-side message expiry drops requests whose timeout has passed without synchronized clocks.
The late-command result is the one the author calls the most important. QoS 1 MQTT did exactly what it promises: it delivered every queued command once a crashed or frozen actuator came back — 35 to 56 commands, up to 16 seconds late, all already recorded as failed by the controller. gRPB-M2M executed none, because servers refuse requests arriving after the caller's absolute deadline. The simulation caught the library itself first: early freeze runs showed a few commands up to 10 seconds late, sitting in the frozen device's network buffer. The fix — an absolute deadline_unix_ms in the frame plus server-side refusal — took the count to zero, with a regression test.
Failure detection improved too. Calls to a crashed device fail fast about 250 ms after the failure via MQTT Last Will, matching gRPC; JSON over MQTT never tells the controller, which waits out every deadline. A frozen (silently disconnected) device is detected after about 7 s via MQTT keepalive — gRPC and JSON never detect it during the outage. The controller spent about 36 s blocked on dead devices, against 70 s for gRPC and JSON. Recovery after a crash: first successful command 0.8–0.9 s after return, versus 2.8 s for gRPC's connection backoff.
Where does it fall short?
The CSE works harder with binary formats. Ten Protobuf sensors used about 28% of a core in ACME, versus 6% for JSON; at 50 sensors (10 requests/s), Protobuf and CBOR both saturated one core, round trips rose to 6–9 s, and only 60–65% of Protobuf readings (77–92% of CBOR) got through, while JSON stayed under 1.5 s. CBOR uses ACME's built-in codec and behaves the same way, so the overhead appears to sit in how the CSE handles binary requests, not in Protobuf encoding itself — which costs only microseconds per message in the codec benchmark.
Streaming throughput is lower on a Pi: 10 sensors topped out at about 109 samples/s on LAN versus 500/s for gRPC, because gRPB-M2M sensors wait for the hub's acknowledgement. At 5 samples/s, delay was 59 ms against gRPC's 4 ms. It never dropped a sample. Absolute deadlines also need roughly synchronized clocks; devices should run NTP, tolerance 500 ms by default, switchable off.
Why not ASN.1?
ASN.1 (ITU-T's mature notation used in 3GPP signalling and X.509 certificates) with UPER packing often produces smaller messages than Protobuf. The authors don't claim to beat it on size and haven't measured it. They chose Protobuf for the surroundings: .proto defines services and remote calls, not just data, and grpcio-tools generates typed stubs in Python, C++, Go, Java, C#, Rust, with nanopb covering microcontrollers. Protobuf schemas also evolve safely by default — old readers skip unknown numbered fields — whereas ASN.1 needs pre-planned extension markers, and packed encodings break every existing decoder otherwise. Protobuf's standard JSON mapping lets the CSE serve the same resource as JSON to HTTP clients; decode(encode(p)) == p holds for every primitive.
What's next, and the adoption question
The roadmap: find and fix the CSE's per-request cost for binary formats; pipelined streaming to lift the ceiling; typed stubs generated for oneM2M resources; TLS, broker authentication, and bidirectional streaming; and a proposal for the application/vnd.onem2m-res+protobuf media type to oneM2M, which currently defines only XML, JSON and CBOR serializations. pip install grpb-m2m; on a Pi, make evidence reproduces every number.
The compliance question is whether oneM2M will accept a fourth serialization — and whether the CSE's binary-request overhead gets fixed before anyone deploys 50-sensor fleets on a Pi.
via hackster.io (Source)
Filed under
- mqtt
- grpc
- protocol-buffers
- onem2m
- raspberry-pi
More from Amara Osei
Show full bio
Senior reporter covering people, launches and day-to-day practice in Instruments, test and measurement at Testbench Report.
127 articles
Application notes
- On-Device AI for IoT Sensors: When Local Inference Finally Makes Sense
- oneM2M Made Indispensable: Swarm Project Ties Robot Swarms to 5G Edge Handover
- Forescout 2025 Report Documents Rising Device Vulnerabilities
- ANCHOR Ships Gap-Free Maritime IoT Over Breaking Links With oneM2M and MEC
- Edge Intelligence Reshapes the IoT Platform Architecture