# KEDA HTTP Addon: push-based communication between interceptor and scaler
This document is an extension of [issue #97](https://github.com/kedacore/http-add-on/issues/97) in the KEDA HTTP Addon repository.
In that issue, I suggested that any given interceptor push a notification to the scaler when certain important events happen, most importantly when the app should scale from zero to one.
This push-based communication would likely be similar to how the KEDA [external push scaler](https://keda.sh/docs/2.4/scalers/external-push/) works. In that scheme, KEDA makes regular RPC requests over [gRPC](https://grpc.io) to the external push scaler on a well-known schedule, but the same scaler also can send a signal to KEDA at any time to indicate two things:
1. Whether or not the application is "active" - should be scaled to a nonzero number of replicas or not
2. If the application is "active", that KEDA should in turn request new data from the scaler
This document proposes two things:
- A similar (not necessarily identical) push-based protocol is used between interceptors and the KEDA HTTP Addon external scaler
- The KEDA HTTP Addon external push scaler is modified to push a signal to KEDA after a push event described in the previous bullet is received and the scaler fetches new data from interceptors.
## Interceptor -> Scaler -> KEDA push communication
This document proposes an overhaul of the communication flow from interceptors all the way through to KEDA itself, so this section describes both the changes between interceptors and scaler, and changes between scaler and KEDA itself.
### Changes to scaler -> KEDA communication
Currently, the HTTP Addon's [push communication code](https://github.com/kedacore/http-add-on/blob/e1d421398c30a85c8db654bb245bd578aa375033/scaler/handlers.go#L43-L62) is relatively simple. The scaler simply sends a signal to KEDA every 5ms. In every push, it tells KEDA that the application is active (that behavior will become slightly more intelligent in [#206](https://github.com/kedacore/http-add-on/pull/206)).
With this change, the scaler would not push any signal to KEDA unless an interceptor has pushed a signal to the scaler, and the scaler has fetched fresh metrics data from all interceptors and aggregated it.
KEDA will continue to make periodic requests to the other scaler RPC endpoints as usual.
### Changes to interceptor -> scaler
Currently, the scaler periodically requests metrics from the interceptors, aggregates them, and then furnishes them to KEDA when requested.
This document proposes keeping the same behavior and adding a push component from interceptor to scaler. In the case that the interceptor has zero pending HTTP requests and receives one or more, it will push a notification to the scaler with the host for which the new requests are for. The scaler will use this information in two ways:
1. To push a new notification to KEDA to indicate that the corresponding `ScaledObject` is now "active"
2. To issue a new request for metrics across all interceptors and aggregate the results as normal