Reputation: 2030
We want to use spring WebSockets + STOMP + Amazon MQ as a full featured message broker. We were trying to do benchmarking, to find out how many client WebSocket connections single tomcat node can handle. But it appears that we hit Amazon MQ connection limit first. As per the AWS documentation, Amazon MQ has a limit of 1000 connections per node (as far as I understand we can ask support to increase the limit, but I doubt that it can be increased big time). So my questions is:
Am I correct in assuming that for every websocket connection from client to spring/tomcat server, a corresponding connection being opened from server to broker? Is this correct behavior or we're doing something wrong here/missing something?
What can be done here? I mean I don't think this is a good idea to create broker node per every 1000 users..
Upvotes: 4
Views: 1242
Reputation: 5193
According to https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.html your are doing everything right, and it is documented behavior.
Quote from javadoc:
For each new CONNECT message, an independent TCP connection to the broker is opened and used exclusively for all messages from the client that originated the CONNECT message. Messages from the same client are identified through the session id message header. Reversely, when the STOMP broker sends messages back on the TCP connection, those messages are enriched with the session id of the client and sent back downstream through the MessageChannel provided to the constructor.
As for a fix, you can write your own message broker relay, with tcp connection pooling.
Upvotes: 2