3scale / apisonator

Red Hat 3scale API Management Apisonator backend
https://3scale.net
Apache License 2.0
35 stars 27 forks source link

Perf optimization: load just the limits needed when no_body=true #221

Closed davidor closed 4 years ago

davidor commented 4 years ago

When the no_body option is enabled we just need to load the usage limits that are affected by the metrics included in the usage of the request, that is, the limits defined for those metrics plus any of their ancestors in the metrics hierarchy.

When no_body is disabled, we need to load all the usage limits because we need to include them in the response XML.

We were not distinguishing between both cases. This PR changes the transactor so it only loads the usage limits required for the request. This can reduce a lot the number of keys that we need to fetch from redis when no_body is enabled and the service has many metrics defined.