Json 为什么Websocket可以更快地处理更大的消息和更多连接到服务器的用户?
我已经为websocket(+STOMP消息格式)创建了性能测试,并从中得到了奇怪的结果。对于较大的消息,以及更多以相同频率发送消息(大约每秒47条消息)的连接用户,我得到了较小的请求时间。消息大约有120个字节 有一个图表显示了我的结果(每10秒通信添加一个用户(最后添加10个用户)): 只有1个用户: 有针对客户端和服务器的配置: lib:“@stomp/stompjs”:“^5.4.4” 服务器端是WebCoket Stomp spring的默认配置 Maven依赖项:Json 为什么Websocket可以更快地处理更大的消息和更多连接到服务器的用户?,json,performance,websocket,message,stomp,Json,Performance,Websocket,Message,Stomp,我已经为websocket(+STOMP消息格式)创建了性能测试,并从中得到了奇怪的结果。对于较大的消息,以及更多以相同频率发送消息(大约每秒47条消息)的连接用户,我得到了较小的请求时间。消息大约有120个字节 有一个图表显示了我的结果(每10秒通信添加一个用户(最后添加10个用户)): 只有1个用户: 有针对客户端和服务器的配置: lib:“@stomp/stompjs”:“^5.4.4” 服务器端是WebCoket Stomp spring的默认配置 Maven依赖项: <dep
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
发送响应:
@Override
public void sendToUser(String destination, GameObject gameObject, HeaderStatus status,
String userSession, long requestTimestamp) {
this.template.convertAndSendToUser(userSession, destination, gameObject, Map.of(
"requestTimestamp", requestTimestamp,
"status", status
));
}
您使用的是什么消息代理?我使用的是由spring dependency(简单代理)提供的默认内存代理。
@MessageMapping("/send/position")
public void updatePositionForPlayer(Player player, Principal user, @Header("requestTimestamp") Long requestTimestamp) {
....
}
@Override
public void sendToUser(String destination, GameObject gameObject, HeaderStatus status,
String userSession, long requestTimestamp) {
this.template.convertAndSendToUser(userSession, destination, gameObject, Map.of(
"requestTimestamp", requestTimestamp,
"status", status
));
}