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?