-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][admin][broker] Admin API: stream internal topic stats #22510
base: master
Are you sure you want to change the base?
Conversation
@eolivelli have you had a chance to check if Gzip compression helps with large responses? Pulsar admin client changes: #22464, broker side changes: #21667, #22463 and #22370 . |
@eolivelli do you have any figures to share? How large is the JSON response? How many individuallyDeletedMessages are there? |
@Context HttpServletRequest servletRequest; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a left over, sorry
I have seen those PRs, great stuff, but the problem here is about the serialization happening in some upgredictable place, like this:
|
|
Trying to understand this more deeper. What is the impact of using the default serialization in this case? how does the StreamingOutput based serialization improve the situation? |
@lhotari I guess the default implementation of the jetty is String jsonString = JSON.toJsonString(object);
httpOutput.writeString(jsonString); It will generate the jsonString first and then send it to the client. But by this PR, it doesn't need to generate the jsonString first in the memory, but sends the result to the client directly. So we can reduce heap memory usage and avoid more memory copies. @eolivelli Am I right? |
@dao-jun this doesn't seem to be the case based on the stack trace that Enrico shared. The default solution even without this PR is "streaming". Based on the stack trace, it's using this class to create the JSON response: https://github.com/eclipse-ee4j/jersey/blob/2.41/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/ProviderBase.java#L583-L659 |
Motivation
The JSON may be huge when individuallyDeletedMessages inside ManagedLedgerInternalStats$CursorStats contains many ranges
Modifications
Instead of returning the Object and letting the framework do the encoding, switch to StreamingOutput and perform the JSON encoding manually.
One step further may be to start serving the results as soon as they are available, instead of build the object in memory and then perform the encoding, but this is far more involved
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: eolivelli#25