microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
372 stars 29 forks source link

Dapr middleware support #53

Open denniszielke opened 2 years ago

denniszielke commented 2 years ago

Dapr middleware is not part of the list of supported dapr components but dapr middleware component definition is accepted. I am particularly interested in the ratelimit and bearer-token middleware. From the logs it seems that the middleware is loaded on all container apps (are all instances sharing the same config?) time="2021-12-02T19:08:05.397778587Z" level=info msg="component loaded. name: ratelimit, type: middleware.http.ratelimit/v1" app_id=js-calc-backend instance=js-calc-backend--a43oz06-65b9689d6d-rlzqb scope=dapr.runtime type=log ver=edge However the deployment of a new container app seems to then fail.

Is there a way to get middleware working or will this be coming in the future?

berndverst commented 1 year ago

At the moment we do not include Middleware components in the Dapr sidecar used by Azure Container Apps.

That being said, I also want to point out a few caveats about the middleware components. Middleware components like all other components must be scoped to the intended apps.

All middleware state (including rate limiting) is local to each sidecar. So with 3 replicas for example each replica's sidecar would have its own independent rate limiting state in the case of the rate limiter middleware component.

On this specific note: Dapr does not have a distributed rate limiter - our rate limiting components are not backed by a centralized store like Redis (which is commonly used for such a purpose). This is not a feature offered by Dapr at this time.

ItalyPaleAle commented 1 year ago

To add to what @berndverst mentioned, enabling a middleware in Dapr is currently a two-step process:

PS: While Bernd is correct that distributed rate limiters aren't available, we are looking into adding that by using an internal actor in one of the next Dapr releases.

berndverst commented 1 year ago

Just opened a proposal that could help make middlewares happen in ACA: https://github.com/dapr/dapr/issues/6660