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

Instantiation of ValidatorFactory leads to performance issues #33

Closed
benjaminknauer opened this issue Sep 23, 2022 · 1 comment · Fixed by #34
Closed

Instantiation of ValidatorFactory leads to performance issues #33

benjaminknauer opened this issue Sep 23, 2022 · 1 comment · Fixed by #34

Comments

@benjaminknauer
Copy link
Contributor

benjaminknauer commented Sep 23, 2022

Hi 👋

My team used your book on clean architecture as reference for implementing new microservices. We absolutely love your book and the architecture approach.

Nevertheless, we want to share a major performance issue we encountered while using your template for the SefValidating abstract class:
During load testing, we noticed that our application used a lot of memory and requests took a long time even under small loads. Using profiling, we noticed that creating a ValidatorFactory during instantiation of every domain object was the problem.
We solved the issue by adding the ValidatorFactory as a static attribute in the abstract class.

Cheers,
Benjamin

public SelfValidating() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
}

benjaminknauer added a commit to benjaminknauer/buckpal that referenced this issue Sep 23, 2022
@thombergs
Copy link
Owner

Good find, thank you.

I was aware that this is not the most performant solution, but didn't think it would have that big of an impact.

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 a pull request may close this issue.

2 participants