Description
-
I have a springboot application that acts as a websocket server using stomp. The embedded server is tomcat. I am using spring boot version 3.2.9 and springframework version 6.1.14.
-
I also have a springboot client application that starts 5000 threads. Each thread opens a websocket connection with the server. The client is also using stomp.
-
My server machine has 62G ram. As websocket connections are being opened, the memory consumption in the server rises. At 5000 connections, I reach 20G memory usage (I configured my server app to run with -Xmx30g heap size to prevent server failure).
When I allow less memory, the server throws OutOfMemoryError. -
I saved a heap dump when reaching OOM error. Opened it with Eclipse MAT and saw that the dominant object is org.apache.tomcat.websocket.server.WsFrameServer.
-
So tomcat as a suspect, I changed my server application to use jetty instead of tomcat.
Results: The same server application with jetty instead of tomcat uses a total of 1g ram for 5000 connected websocket clients, plus I made each client send a message to the server every 5 sec. The problem does not exist with jetty.
So is tomcat really a problem using stomp/ws, or is it the combination of my springboot version plus stomp?