Skip to content

Latest commit

 

History

History
48 lines (40 loc) · 2.87 KB

File metadata and controls

48 lines (40 loc) · 2.87 KB

Sample Benchmark Results

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.

------------------------------------------------------------
Style        Mean (ms)   P95 (ms)   P99 (ms)  Payload (B)
------------------------------------------------------------
REST              2.14       3.41       5.12         1,842
GraphQL           2.87       4.23       6.30         1,842
gRPC              0.91       1.38       1.97           312  binary (Protobuf)
SOAP              4.73       7.09      10.18         5,893
WebSocket         0.38       0.57       0.84         1,842  persistent conn
------------------------------------------------------------

What the numbers mean

Style Key takeaway
REST 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 WebSocket
You need streaming responses (AI, log tails) gRPC (server-streaming) or WebSocket