Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

k8s/istio - What's the alternative to HTTP caching between services while Envoy doesn't support it?

I'm looking for a fast HTTP response of cacheable data between services in Kubernetes.

Since my apps are already container-native, I don't want to code in my application the logic of caching, neither via cache lib. The apps are focused mainly on business logic.

I've searched how to configure caching between services and didn't find any Istio configuration to do that, only an issue in the Envoy repository Support HTTP caching and these ongoing related PRs: #7198, #9878, also this talk and this design spec.

On the issue page, in the first comment, someone mentions they are using Nginx as a proxy to cache some API calls. But I don't know if it is the right choice.

Is there a simpler alternative to achieve HTTP caching in the mesh?

like image 770
ethanxyz_0 Avatar asked Sep 01 '25 10:09

ethanxyz_0


2 Answers

Recently we developed a solution using istio&golang to cache service to service communications.

The solution called as "reverse proxy sidecar cache".

Basically you deploy another container in your pod (which is cache container). And you configure routing rules to your pod via istio's VirtualServices. The requests you specify in VirtualService goes to your cache container first, it checks cache storage and returns response if data exists otherwise proxies request to application container.

Overall design looks like:

enter image description here

For example here is an istio VirtualService yaml which routes all get requests to cache container (runs on 9191 port):

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: foo
spec:
  gateways:
  - foo-gateway
  hosts:
  - foo
  http:
  - match:
    - method:
        exact: GET
    route:
    - destination:
        host: foo
        port:
          number: 9191
  - route:
    - destination:
        host: foo
        port:
          number: 8080

Here you can find the article we wrote about it: https://medium.com/trendyol-tech/trendyol-platform-team-caching-service-to-service-communications-on-kubernetes-istio-82327589b935

Here is the project repository: https://github.com/Trendyol/sidecache

like image 93
Emre Savcı Avatar answered Sep 03 '25 01:09

Emre Savcı


The Envoy team has merged the related PRs, but it seems it's not fully usable at the time (with redis, e.g).
There is a SimpleHttpCache, but it is not production ready: #9860

Presentation: https://www.youtube.com/watch?v=uIgYxp-SbBw

like image 29
ethanxyz_0 Avatar answered Sep 03 '25 00:09

ethanxyz_0