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

Introduce caching of ResteasyUriInfo.InitData #4563

Closed
wants to merge 1 commit into from

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Oct 15, 2019

This is done because the computation of the data is expensive

Relates to: #4345
Depends on: resteasy/resteasy#2184
Depends on: RESTEasy 4.4.0.Final (still unreleased)

@geoand
Copy link
Contributor Author

geoand commented Oct 15, 2019

@asoldano, @Sanne this is what I had in mind based on our discussion in #4345.

WDYT?

@@ -114,6 +136,19 @@ private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput
if (!vertxRequest.getAsyncContext().isSuspended()) {
try {
vertxResponse.finish();
// the reason we only cache successful responses is to ensure that a torrent of erroneous URLs
// doesn't fill up the cache and cause a DoS
Copy link
Member

Choose a reason for hiding this comment

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

I think you should cache unsuccesfull responses as well, especially if we go for having a proper cache.

DDoS are caused by the system being overwhelmed; hitting the "bad response cache" would be the best way to avoid it as the cache would help fighting load.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree 💯%. If we have a proper cache than all this nastiness can go away.

// we don't want the cache to grow unbounded since values path params could potentially be infinite
// and if left unchecked would take up all memory if the application is up for long enough
if (resteasyUriInfoInitDataMap.size() > resteasyUriInfoCacheMaxSize) {
resteasyUriInfoInitDataMap.clear(); // this is super lame and should probably be revisited
Copy link
Member

Choose a reason for hiding this comment

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

yes it's dangerous. See my other comments on the design discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we have the RESTEasy part of the PR in which puts in the necessary hooks, we can absolutely improve this based on what you mention about the existence or not of Caffeine.
Note that the way I have done the RESTEasy PR (and as of course you have seen from looking at this PR), the caching itself is handled exclusively in Quarkus so we can probably get as creative as we like.

@geoand geoand force-pushed the resteasyuriinfo-cache branch 2 times, most recently from 22e607a to 74a1e1f Compare October 15, 2019 15:55
@Sanne
Copy link
Member

Sanne commented Oct 29, 2019

@geoand what's the status of this? I guess it might be too late but I'd still love to get some improvements in this area.

@geoand
Copy link
Contributor Author

geoand commented Oct 29, 2019

@Sanne I can rebase onto master ready for merging if we feel it should be added.

@geoand
Copy link
Contributor Author

geoand commented Oct 29, 2019

I didn't do it so far because this wasn't critical, but it won't be a problem to update it (it's a temporary solution anyway until we have a better "cache")

@Sanne
Copy link
Member

Sanne commented Oct 29, 2019

@geoand yes please do :) And ping me for review, I can quickly run some perf tests.

@geoand
Copy link
Contributor Author

geoand commented Oct 29, 2019

@Sanne can you give it a shot and see if it gives you any significant improvement?

@gsmet
Copy link
Member

gsmet commented Oct 29, 2019

I'm cancelling the build for this one.

@geoand
Copy link
Contributor Author

geoand commented Oct 29, 2019

Sure, no problem

@Sanne
Copy link
Member

Sanne commented Oct 29, 2019

@geoand my results are being puzzling so far. I'll need to repeat the runs and gather some more data.

@geoand
Copy link
Contributor Author

geoand commented Oct 29, 2019

OK, thanks for keeping me up to date

@geoand
Copy link
Contributor Author

geoand commented Nov 6, 2019

@Sanne were you able to see if this change actually had much of an effect?

@Sanne
Copy link
Member

Sanne commented Nov 6, 2019

It actually made performance a little worse :-) But I haven't been able to check why though... I will try diagnosing this today, as the patch looks sensible but maybe we're missing something.

@geoand
Copy link
Contributor Author

geoand commented Nov 6, 2019

Interesting! If you find anything let me know so we can see how we can improve the situation.

Thanks!

@Sanne
Copy link
Member

Sanne commented Nov 6, 2019

Sure, I will. We need some luck for me to be able to focus on this long enough though, I'm using it as a "fun task" to do between priority tasks ;)

@geoand
Copy link
Contributor Author

geoand commented Nov 6, 2019

I see :)

@gastaldi
Copy link
Contributor

gastaldi commented May 2, 2020

@geoand Is this PR still being worked on or can it be safely closed?

@geoand
Copy link
Contributor Author

geoand commented May 2, 2020

Let's close it

@geoand geoand closed this May 2, 2020
@gsmet gsmet added the triage/invalid This doesn't seem right label May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants