Bug 63362 - GlobalRequestProcessor statistics in MBean does not count Websocket communication
Summary: GlobalRequestProcessor statistics in MBean does not count Websocket communica...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: WebSocket (show other bugs)
Version: 9.0.16
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-18 11:11 UTC by marek.gregor
Modified: 2020-10-15 09:53 UTC (History)
0 users



Attachments
Screenshot from JConsole & Chrome Dev Tools (77.46 KB, image/png)
2019-04-18 11:11 UTC, marek.gregor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marek.gregor 2019-04-18 11:11:57 UTC
Created attachment 36534 [details]
Screenshot from JConsole & Chrome Dev Tools

Websocket communication in web app is not counted to statistics of bytes sent and received - obtainable via MBean: e.g. Catalina:type=GlobalRequestProcessor,name="http-nio-8080", containing attributes bytesReceived, bytesSent.
Please see attachment for details.
Comment 1 Remy Maucherat 2019-04-19 08:13:55 UTC
Yes, this only tracks non upgraded HTTP/1.1 activity at this time.
Comment 2 Mark Thomas 2019-05-15 13:36:18 UTC
What is the request here? Are new statistics required? Are changes to how the existing statistics are calculated required? Specifics would help us to evaluate the request.

The current statistics were implemented when Tomcat only implemented HTTP/1.1 (and 1.0 and 0.9). Now Tomcat supports WebSocket, HTTP/2 and generic HTTP/1/ upgrade.

Do stats need to be broken down by protocol?

Is the 'right' solution something that needs to wait for major refactoring in Tomcat 10? (Or is there something useful we can do now for 9.0.x?)
Comment 3 Remy Maucherat 2019-05-15 13:50:34 UTC
I guess it would have to be counted in the SocketWrapper, but is that kind of metric useful at all these days ? We know/expect it will be some random large amount, and that's all it will say. At the same time, it's slightly annoying to collect.

Access logging should give a much better idea on what's going on.

Personally, I'd rather leave it the way it is now and remove it in Tomcat.next.
Comment 4 marek.gregor 2019-05-15 14:31:52 UTC
Our code has implementation of feeding metrics with sent/received number of bytes from web server. Generally the metrics is important to check amount of data transferred  from/to web application in elegant way - that means we do not need implement counting by ourselves for every API endpoint in our app (HTTP or Websocket). We had migrated our app from Wildfly, which counts Websocket + HTTP communication together correctly, but I understand that this is not feature crucial to be present there. So we are ok also with decision, that the counting will be implemented by ourselves - albeit take the numbers collected by Tomcat is the easier option ;)
Comment 5 Mark Thomas 2020-06-16 16:23:09 UTC
Note: HTTP/2 traffic is also excluded from the GlobalRequestProcessor metrics.
Comment 6 Mark Thomas 2020-06-24 17:33:36 UTC
Working on this. On HTTP/2 at the moment.
Comment 7 Mark Thomas 2020-10-09 17:44:59 UTC
Fixed for HTTP/2 in:
- 10.0.x for 10.0.0-M10 onwards
- 9.0.x for 9.0.40 onwards
- 8.5.x for 8.5.60 onwards

Still thinking about how to tackle WebSocket.
Comment 8 Mark Thomas 2020-10-15 09:53:50 UTC
Support added for WebSocket and generic HTTP upgrade protocols.

Fixed in:
- 10.0.x for 10.0.0-M10 onwards
- 9.0.x for 9.0.40 onwards
- 8.5.x for 8.5.60 onwards