How many messages per second can WebSocket send and receive?

Matt Kuenzel
2 min readJul 26, 2020

This is a report on a simple test I did to answer the question: How many messages can be sent or received between two Java programs running on two separate machines. The short answer is about 20,000.

The two machines were a MacBook Pro (13-inch, 2017) and an AWS EC2 instance of type ta2-large. The Mac has 4 processors and the EC2 instance has 2 processors.

The Mac repeatedly sent messages and then received acknowledgements. The EC2 instance received those messages and sent acknowledgements. The processing on each side was limited to a lookup to associate acks with messages.

At a rate of about 22,000–25,000 per second the Mac started to lose messages and Activity Monitor showed it using over 200% processor. At the same time the Linux machine was cruising along at under 10% utilization.

So, if you don’t call to any other machines in your processing of the message you can comfortably handle 10,000 requests per second on a relatively cheap machine. My server costs eight cents US per day which comes to about $60 per month.

If your typical user sends your server 100 requests per day then your single server can serve, ignoring peaks for a moment, about 1,000,000 users! If you want to handle the peaks without changing anything you can pay for a bigger machine, 32 or 64 processors and 32 or 64 GB of RAM.

--

--