0

I'm running a Java websocket server on an AWS server. To dispatch a message to clients (in my case, another AWS server I own in a different region), I use either of the following:

// this
javax.websocket.Session.getAsyncRemote().sendText("")
// or this
javax.websocket.Session.getBasicRemote().sendText("")

They both take about 400us to dispatch a small string to a single client, even when the total throughout of messages is very low and so there's no bottlenecking.

This is a big problem especially during high throughput times because bottlenecking becomes an issue.

Firstly, am I doing something wrong to incur such a long send time or is this to be expected? Secondly, how to mitigate this and build something that can send a high throughput of messages?

Jase
  • 1,025
  • 1
  • 9
  • 34
  • Question answered here already https://stackoverflow.com/questions/34700358/websocket-slow-java-and-javascript? – Rakshith Venkatesh May 07 '20 at 07:04
  • @RakshithVenkatesh Yeah I appreciate that, and I'll probably implement something similar, but how do websites distribute 10s of messages per second to 1000s of clients if it takes 400us per message per client? – Jase May 07 '20 at 07:16

0 Answers0