You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These results were captured on a mid-range laptop (Intel i7, 16 GB RAM, Windows 11)
running all servers and clients on localhost (0 ms network latency).
Your numbers will vary; the relative ordering is what matters.
Solid baseline. JSON text, one request per resource. Fast enough for most web APIs.
GraphQL
Slightly slower than REST due to query parsing overhead. Payload identical here because we fetched all fields — request only id, title and it drops to ~420 bytes (5× smaller).
gRPC
Fastest request-response. Protobuf payload is 5.9× smaller than REST JSON. Multiplexed HTTP/2 means multiple calls share one connection.
SOAP
Slowest and largest. XML envelope adds ~3.2× overhead vs JSON. Latency from XML parsing on both sides. Worth it when you need WS-Security, ACID transactions, or must integrate with legacy enterprise systems.
WebSocket
Lowest per-message latency because connection setup (TCP handshake) happens once. For 100 messages: REST pays handshake cost 100 times; WebSocket pays it once.
Payload Size Breakdown (list of 20 books)
REST JSON 1,842 bytes ████████████████████ baseline
GraphQL (all) 1,842 bytes ████████████████████ same as REST (all fields)
GraphQL (id+title) 418 bytes ████ field selection in action
gRPC Protobuf 312 bytes ███ binary encoding
SOAP XML 5,893 bytes ████████████████████████████████████████████████████████████
When to use each
Scenario
Recommended style
Public-facing web/mobile API
REST
Mobile app that needs to minimize data usage
GraphQL
Internal microservice-to-microservice
gRPC
Integrating with a bank, insurance, or government API
SOAP
Live chat, stock ticker, multiplayer game, notifications