Skip to content
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 OpenSearch sink performance within the opensearch-java client #1391

Conversation

dlvenable
Copy link
Member

@dlvenable dlvenable commented May 13, 2022

Description

The recent migration to the opensearch-java client (#1381) introduced a performance migration which was caused by how the opensearch-java client serializes JSON data.

This PR introduces a PreSerializedJsonpMapper which will take a serialized JSON byte array and write that directly to the final OutputStream rather than serialize it. This has corrected Data Prepper's throughput to meet what 1.3 had.

Issues Resolved

N/A

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…r which avoids re-serializing bulk documents.

Signed-off-by: David Venable <[email protected]>
@dlvenable dlvenable requested a review from a team as a code owner May 13, 2022 16:19
Copy link
Collaborator

@chenqi0805 chenqi0805 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One minor comment

Function<String, Record> stringModel = jsonString -> new Record(jsonString);
Function<String, Record> stringModel = jsonString -> {
try {
// Normalize the JSON string.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the normalization?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because of the assertions in the tests that assert the number of bytes written. The JSON is pretty formatted. So for Record<String> these are larger strings (and thus more bytes) than Record<Event>. The make the assertions later simpler, I just make all JSON non-pretty and thus the same byte size.

@dlvenable dlvenable merged commit 3158b45 into opensearch-project:main May 13, 2022
@dlvenable dlvenable deleted the opensearch-java-client-performance branch May 24, 2022 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants