jetty.project
jetty.project copied to clipboard
Improve ConnectionStatistics to report
Jetty version 9.4.x
Description
ConnectionStatistics gathers statistics from the connections only when they are closed.
This is not optimal for benchmarks that perform a run, but then keep connections open.
It would be great if ConnectionStatistics (or perhaps another class, say DynamicConnectionStatistics) had a mode where upon an API call (e.g. DynamicConnectionStatistics.collect()) would run through the open connections and gather the statistics from them.
Hi @sbordet ,
Please correct me if I am wrong.
This task entails either adding a collect() method in ConnectionStatistics class or creating a new class DynamicConnectionStatistics which will have a collect() method that will gather statistics from the open connections.
@rk1165 I think ConnectionStatistics works well for its use case and so I think we should not touch it.
This issue is another use case, somehow similar to what is covered by ConnectionStatistics, but different.
Let's say I start some benchmark that opens conn1 and conn2.
Both connections are recorded by the new statistics class.
Then the benchmark ends, but the connections remain open.
I would like to collect the statistics about those connections so far (something that ConnectionStatistics only does when the connections are closed).
Say for example that conn1 received 29 bytes and conn2 received 41 bytes.
The new statistics class should report the total number of received bytes as 29+41=70 bytes.
Then I want to "reset" this new class, and perform another benchmark run, using the existing conn1 and conn2.
Then benchmark ends as above.
At this point, conn1 will report 61 bytes and conn2 will report 83 bytes.
The new statistics class, however, should report only the delta since it was last reset, i.e. (61-29)+(83-41)=74 bytes, or equivalently (61+83)-(29+41) -- it's easier to work on the totals than per-connection.
However, we should take into account the case where conn1 gets closed during a benchmark run.
Its totals should be recorded (from the close event), and if a new connection is created, taken into account when the benchmark ends.
This class would be useful in benchmarks, but also via JMX to give more detailed information about the system also for currently open connections, not only for past connections that have been closed.
Fairly easy to implement for bytes sent/received, perhaps less for counts/rates.
@rk1165 regardless of if it is in ConnectionStatistics or a new class, you are correct, this requires a semantic that will gather statistics from open connections. More over it will have to remember the individual totals for each connection so that it doesn't "collect" the same bytes twice.
There is a cost associated with this of keeping a dynamic list of all open connections.... which unfortunately is somewhat contrary to this being used in benchmarking.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
See also what EventsHandler offers to avoid duplications, and also the work for #13360.