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

Use debug level logging to avoid performance impact (#23) #24

Merged
merged 1 commit into from
Apr 28, 2022

Conversation

ericlai616
Copy link
Contributor

What is this PR for?

Resolves #23 by logging debug logs at an appropriate logging level to make server less busy for logging during high traffic rate.

Overview or reasons

It appears that current logs in the FIDO server are mainly for debugging purpose, but they are logged in info level.

As a result, even if info level is configured in logback, they are always logged. When traffic rate is high, the server becomes busy for logging.

On the other hand, some logs passes parameters with manual string construction instead of {} placeholder, so the impact is even larger. (See https://www.slf4j.org/faq.html#logging_performance for details)

Tasks

  • Align all debugging logs to be debug level: log.info -> log.debug
  • Use {} placeholders in log message whenever possible
  • Pass objects directly as message parameters instead of manual string construction like toString or String.format. This can avoid redundant computation when the log is not required for the configured log level.
  • Prepare Base64url encoded strings for logging and share it in multiple debug logs to avoid redundant encoding.
    • Note that the encoding is still performed no matter what log level is. Since changing log level should have significant improvement, this PR keeps this change minimal.

Result

  • The logs are only logged when logback is configured to debug level.

@CLAassistant
Copy link

CLAassistant commented Apr 27, 2022

CLA assistant check
All committers have signed the CLA.

@ericlai616 ericlai616 force-pushed the enhancement/use-debug-log-level branch from 26a21f2 to f6d9f59 Compare April 27, 2022 03:22
@ericlai616
Copy link
Contributor Author

Force pushed the same commit with user email linked to CLA.

@kj84park kj84park self-requested a review April 28, 2022 00:53
Copy link
Member

@kj84park kj84park left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you for your PR!

@kj84park kj84park merged commit 7ad6e86 into line:main Apr 28, 2022
@ericlai616 ericlai616 deleted the enhancement/use-debug-log-level branch April 28, 2022 05:56
@ericlai616 ericlai616 restored the enhancement/use-debug-log-level branch April 28, 2022 05:56
@ericlai616 ericlai616 deleted the enhancement/use-debug-log-level branch April 28, 2022 05:56
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.

Inappropriate logging level affects performance on high traffic
3 participants