Rick Hightower - Mammatus Technology Inc.
WebSocket
MicroService vs.
REST Microservice
How does the performance of
a REST microservice compare
to a WebSocket
MicorService?
Comparison of Speed
❖ WebSocket is faster and uses
less resources for more calls
❖ REST is slower due to each
connection needing to wait for
a response before it can send
another request
REST/HTTP vs WebSocket
❖ With REST you have to wait for a reply before you can
send another request (over the same connection)
❖ Unless you use pipelining which seems to work better
in benchmarks than the real world
❖ With WebSocket you can stream requests and stream
responses and then marry them together
❖ Still request/reply but WebSocket can send
responses while it is getting other requests
Example uses QBit
❖ QBit supports REST and WebSocket RPC
❖ QBit allows you to stream requests over the wire and
receive responses over the wire. It employs micro-
batching to batch requests and responses into larger
chunks to minimize IO and thread hand-off costs
❖ QBit allows async REST calls and async WebSocket
calls. (As well as internal services based on queues)
wrk Testing tool for
REST/HTTP
❖ To perf test REST code we use wrk
❖ wrk load tester capable of generating significant load
when run on a single multi-core CPU
❖ wrk load tester uses multithreaded and event
notification systems
❖ epoll and kqueue
❖ wrk maximizes the number of HTTP requests per
second
Trade Service
wrk LUA script
Caveats About the Test
❖ We can tweak server a bit and reduce the flush rate or reduce the batch size to get higher
throughput with lower connections
❖ We can also tweak the OS so we can have more ephemeral ports available and then use a lot
more connections
❖ experience tells me that we can get close to 90K TPS or so on a MacBook Pro
❖ We could test from two machines
❖ one of those machines being a Linux server with a tweaked stack
❖ This test has disadvantage of all being run on same machine
❖ but same disadvantage that the WebSocket version will have so it is somewhat fair
❖ We could also employ HTTP pipelining to increase the throughput,
❖ great trick for benchmarks rarely works in production environments with real clients
❖ On commodity Linux server, we can get close to 150K TPS to 200K TPS from experience
WebSocket Test
❖ This will be a bit harder
❖ No tool like wrk to test WebSocket RPC calls so we will
write our own
❖ RPC calls are QBit centric and rely on JSON plus some
custom ASCII protocol
❖ Some overhead in the protocol because we have to
match responses to clients and requests need unique
identifier (as well as the client needing a unique identifier)
To use WebSocket we will need Async interface
to service
WebSocket PERF Test code
WebSocket Perf code
continued
How does the WebSocket
microservice do?
1 Million messages a second.
700K messages for a single WebSocket connection.
7.5x better than REST version.
Overhead
❖ Running code through perf showed it was waiting for IO a lot.
Better IO. Better NIC card. More TCP/IP stack tuning. You can
expect better throughput.
❖ QBit has to marry requests with responses/client id combinations.
There is overhead in doing this. QBit also uses JSON/ASCII
protocol which could be optimized to reduce IO (gzip it or use
message pack).
❖ Custom more efficient streaming can be implemented if needed
(from experience, this is another 2x to 4x)
❖ But in general, WebSocket will do better than HTTP
More Caveats
❖ When using WebSocket, you also need service
discovery, and you need to implement your own failover
❖ You can’t just throw a bunch of microservices behind
a load balancer
❖ QBit integrates with DNS and consul.io to provide
service discovery (also allows you to use push)
Follow up
❖ This slide deck as a blog post:
❖ http://rick-hightower.blogspot.com/2015/12/websocket-microservice-vs-rest.html
❖ The QBit project:
❖ https://github.com/advantageous/qbit
❖ Mammatus Technologies
❖ http://www.mammatustech.com/
❖ Rick Hightower
❖ https://twitter.com/RickHigh
❖ https://www.linkedin.com/in/rickhigh
There is a lot more to QBit
than this
QBit supports reactive stream over
WebSocket
QBit implements Service
Actors
Check out QBit
https://github.com/advantageous/qbit

More Related Content

PDF
Kubernetes at Datadog the very hard way
PDF
Socket Programming In Python
PDF
Replacing iptables with eBPF in Kubernetes with Cilium
PPTX
Introduction to OpenFlow, SDN and NFV
PDF
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
PDF
Intel DPDK Step by Step instructions
PDF
Top 20 ccna interview questions and answers pdf
PDF
How VXLAN works on Linux
Kubernetes at Datadog the very hard way
Socket Programming In Python
Replacing iptables with eBPF in Kubernetes with Cilium
Introduction to OpenFlow, SDN and NFV
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Intel DPDK Step by Step instructions
Top 20 ccna interview questions and answers pdf
How VXLAN works on Linux

What's hot (20)

PDF
Network Programming: Data Plane Development Kit (DPDK)
PDF
DPDK & Layer 4 Packet Processing
PPTX
MP BGP-EVPN 실전기술-1편(개념잡기)
PPTX
SIP: Call Id, Cseq, Via-branch, From & To-tag role play
PDF
Network Security and Visibility through NetFlow
PDF
Build a Deep Learning Video Analytics Framework | SIGGRAPH 2019 Technical Ses...
PPTX
Introduction to WebRTC
PPTX
Dynamic routing protocols (CCNA)
PPTX
Reactive programming
PDF
Real World Applications of MQTT
ODP
Dpdk performance
PDF
DPDK In Depth
PPTX
Session initiation-protocol
PDF
Writing the Container Network Interface(CNI) plugin in golang
PDF
Soal Modul C Cisco Packet Tracer Challenge - IT Networking Support LKS NTB 2017
PPTX
Socket programming in python
PPTX
Open source sdn controllers comparison
PDF
Istio service mesh introduction
PPTX
PPTX
Remote access service
Network Programming: Data Plane Development Kit (DPDK)
DPDK & Layer 4 Packet Processing
MP BGP-EVPN 실전기술-1편(개념잡기)
SIP: Call Id, Cseq, Via-branch, From & To-tag role play
Network Security and Visibility through NetFlow
Build a Deep Learning Video Analytics Framework | SIGGRAPH 2019 Technical Ses...
Introduction to WebRTC
Dynamic routing protocols (CCNA)
Reactive programming
Real World Applications of MQTT
Dpdk performance
DPDK In Depth
Session initiation-protocol
Writing the Container Network Interface(CNI) plugin in golang
Soal Modul C Cisco Packet Tracer Challenge - IT Networking Support LKS NTB 2017
Socket programming in python
Open source sdn controllers comparison
Istio service mesh introduction
Remote access service
Ad

Similar to WebSocket MicroService vs. REST Microservice (20)

PPTX
WebSockets in JEE 7
PPTX
Training Webinar: Enterprise application performance with server push technol...
PDF
NullMQ @ PDX
PDF
API Design and WebSocket
PPTX
Programming WebSockets with Glassfish and Grizzly
PPTX
Websocket vs SSE - Paris.js - 24/06/15
PPTX
PDF
WebSocket in Enterprise Applications 2015
PPTX
Messaging for Real-time WebApps
PDF
An implementation of embedded RESTful Web services.pdf
PDF
Building Next Generation Real-Time Web Applications using Websockets
KEY
Socket.io
PDF
Building real time applications with Symfony2
PPTX
Basic understanding of websocket and and REST API
PPTX
WebSockets-Revolutionizing-Real-Time-Communication.pptx
PPTX
Websocket technology for XPages
KEY
The HTML5 WebSocket API
PDF
WebSocket
PDF
ITSPA May 2013 - WebRTC, TURN, and WebSocket
PPTX
WebRTC Conference and Expo (November 2013) - Signalling Workshop
WebSockets in JEE 7
Training Webinar: Enterprise application performance with server push technol...
NullMQ @ PDX
API Design and WebSocket
Programming WebSockets with Glassfish and Grizzly
Websocket vs SSE - Paris.js - 24/06/15
WebSocket in Enterprise Applications 2015
Messaging for Real-time WebApps
An implementation of embedded RESTful Web services.pdf
Building Next Generation Real-Time Web Applications using Websockets
Socket.io
Building real time applications with Symfony2
Basic understanding of websocket and and REST API
WebSockets-Revolutionizing-Real-Time-Communication.pptx
Websocket technology for XPages
The HTML5 WebSocket API
WebSocket
ITSPA May 2013 - WebRTC, TURN, and WebSocket
WebRTC Conference and Expo (November 2013) - Signalling Workshop
Ad

More from Rick Hightower (20)

PDF
JParse Fast JSON Parser
PDF
Service Mesh Talk for CTO Forum
PPTX
Service Mesh CTO Forum (Draft 3)
PDF
Accelerate Delivery: Business Case for Agile DevOps, CI/CD and Microservices
PPTX
Accelerate Delivery: Business case for Agile DevOps, CI/CD and Microservices
PPTX
Accelerate DevOps/Microservices and Kubernetes
PPTX
Accelerate using DevOps and CI/CD.
PPTX
High-speed, Reactive Microservices 2017
PPTX
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
PPTX
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
PPTX
High-Speed Reactive Microservices - trials and tribulations
PDF
High-Speed Reactive Microservices
PPTX
Netty Notes Part 3 - Channel Pipeline and EventLoops
PPTX
Netty Notes Part 2 - Transports and Buffers
PPTX
Notes on Netty baics
PDF
Consul: Microservice Enabling Microservices and Reactive Programming
PDF
The Java Microservice Library
PPTX
Java JSON Benchmark
PPT
MongoDB quickstart for Java, PHP, and Python developers
PPT
Mongo DB for Java, Python and PHP Developers
JParse Fast JSON Parser
Service Mesh Talk for CTO Forum
Service Mesh CTO Forum (Draft 3)
Accelerate Delivery: Business Case for Agile DevOps, CI/CD and Microservices
Accelerate Delivery: Business case for Agile DevOps, CI/CD and Microservices
Accelerate DevOps/Microservices and Kubernetes
Accelerate using DevOps and CI/CD.
High-speed, Reactive Microservices 2017
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
High-Speed Reactive Microservices - trials and tribulations
High-Speed Reactive Microservices
Netty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 2 - Transports and Buffers
Notes on Netty baics
Consul: Microservice Enabling Microservices and Reactive Programming
The Java Microservice Library
Java JSON Benchmark
MongoDB quickstart for Java, PHP, and Python developers
Mongo DB for Java, Python and PHP Developers

Recently uploaded (20)

PDF
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
PDF
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
PDF
Examining Bias in AI Generated News Content.pdf
PPT
Overviiew on Intellectual property right
PDF
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
PPTX
Presentation - Principles of Instructional Design.pptx
PPTX
CRM(Customer Relationship Managmnet) Presentation
PDF
NewMind AI Journal Monthly Chronicles - August 2025
PPTX
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
PDF
Decision Optimization - From Theory to Practice
PDF
Technical Debt in the AI Coding Era - By Antonio Bianco
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
PDF
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PPTX
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
PDF
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
PDF
State of AI in Business 2025 - MIT NANDA
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
PPTX
maintenance powerrpoint for adaprive and preventive
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
Examining Bias in AI Generated News Content.pdf
Overviiew on Intellectual property right
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
Presentation - Principles of Instructional Design.pptx
CRM(Customer Relationship Managmnet) Presentation
NewMind AI Journal Monthly Chronicles - August 2025
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
Decision Optimization - From Theory to Practice
Technical Debt in the AI Coding Era - By Antonio Bianco
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
Report in SIP_Distance_Learning_Technology_Impact.pptx
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
State of AI in Business 2025 - MIT NANDA
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
maintenance powerrpoint for adaprive and preventive

WebSocket MicroService vs. REST Microservice

  • 1. Rick Hightower - Mammatus Technology Inc. WebSocket MicroService vs. REST Microservice How does the performance of a REST microservice compare to a WebSocket MicorService?
  • 2. Comparison of Speed ❖ WebSocket is faster and uses less resources for more calls ❖ REST is slower due to each connection needing to wait for a response before it can send another request
  • 3. REST/HTTP vs WebSocket ❖ With REST you have to wait for a reply before you can send another request (over the same connection) ❖ Unless you use pipelining which seems to work better in benchmarks than the real world ❖ With WebSocket you can stream requests and stream responses and then marry them together ❖ Still request/reply but WebSocket can send responses while it is getting other requests
  • 4. Example uses QBit ❖ QBit supports REST and WebSocket RPC ❖ QBit allows you to stream requests over the wire and receive responses over the wire. It employs micro- batching to batch requests and responses into larger chunks to minimize IO and thread hand-off costs ❖ QBit allows async REST calls and async WebSocket calls. (As well as internal services based on queues)
  • 5. wrk Testing tool for REST/HTTP ❖ To perf test REST code we use wrk ❖ wrk load tester capable of generating significant load when run on a single multi-core CPU ❖ wrk load tester uses multithreaded and event notification systems ❖ epoll and kqueue ❖ wrk maximizes the number of HTTP requests per second
  • 8. Caveats About the Test ❖ We can tweak server a bit and reduce the flush rate or reduce the batch size to get higher throughput with lower connections ❖ We can also tweak the OS so we can have more ephemeral ports available and then use a lot more connections ❖ experience tells me that we can get close to 90K TPS or so on a MacBook Pro ❖ We could test from two machines ❖ one of those machines being a Linux server with a tweaked stack ❖ This test has disadvantage of all being run on same machine ❖ but same disadvantage that the WebSocket version will have so it is somewhat fair ❖ We could also employ HTTP pipelining to increase the throughput, ❖ great trick for benchmarks rarely works in production environments with real clients ❖ On commodity Linux server, we can get close to 150K TPS to 200K TPS from experience
  • 9. WebSocket Test ❖ This will be a bit harder ❖ No tool like wrk to test WebSocket RPC calls so we will write our own ❖ RPC calls are QBit centric and rely on JSON plus some custom ASCII protocol ❖ Some overhead in the protocol because we have to match responses to clients and requests need unique identifier (as well as the client needing a unique identifier)
  • 10. To use WebSocket we will need Async interface to service
  • 13. How does the WebSocket microservice do? 1 Million messages a second. 700K messages for a single WebSocket connection. 7.5x better than REST version.
  • 14. Overhead ❖ Running code through perf showed it was waiting for IO a lot. Better IO. Better NIC card. More TCP/IP stack tuning. You can expect better throughput. ❖ QBit has to marry requests with responses/client id combinations. There is overhead in doing this. QBit also uses JSON/ASCII protocol which could be optimized to reduce IO (gzip it or use message pack). ❖ Custom more efficient streaming can be implemented if needed (from experience, this is another 2x to 4x) ❖ But in general, WebSocket will do better than HTTP
  • 15. More Caveats ❖ When using WebSocket, you also need service discovery, and you need to implement your own failover ❖ You can’t just throw a bunch of microservices behind a load balancer ❖ QBit integrates with DNS and consul.io to provide service discovery (also allows you to use push)
  • 16. Follow up ❖ This slide deck as a blog post: ❖ http://rick-hightower.blogspot.com/2015/12/websocket-microservice-vs-rest.html ❖ The QBit project: ❖ https://github.com/advantageous/qbit ❖ Mammatus Technologies ❖ http://www.mammatustech.com/ ❖ Rick Hightower ❖ https://twitter.com/RickHigh ❖ https://www.linkedin.com/in/rickhigh
  • 17. There is a lot more to QBit than this
  • 18. QBit supports reactive stream over WebSocket