frouioui / tagenal

Tagenal is a playground app using Vitess, Redis, Traefik and Jaeger on Kubernetes
https://frouioui.github.io/tagenal/
MIT License
7 stars 0 forks source link

Addition of a cache layer between the APIs and Vitess #40

Closed frouioui closed 3 years ago

frouioui commented 3 years ago

This PR contains the changes required by #38. A Redis Cluster is being implemented. Allowing the APIs to cache the request that are being made to Vitess.

frouioui commented 3 years ago

Some research about how to trace spans with Jaeger all the way to Redis has been done. The package https://godoc.org/github.com/opencensus-integrations/redis seems to contain a nice interface to send contexts.

Moreover, go-redis packages seem to handle cluster, cache, and open tracing natively. The following repo is a library for using Redis cache: https://github.com/go-redis/cache, and https://github.com/go-redis/redis is the usual Redis go package. The library official website shows how to integrate open tracing.

frouioui commented 3 years ago

The cache implementation made in 2e00f6e and e9ad379 allows a great decrease of the overall query time. Cache TTL was setup to 1 minute.

image

As we can see, the first trace does not contain cache. We cached Vitess' response, making the second span go much quicker.

Tracing is not yet implemented all the way to Redis.

frouioui commented 3 years ago

As #41 mentions, tracing all the way to Redis nodes wont be done in this PR.

A more optimal way to use Redis can be done in the redis.go file of both API's server package. A set and get function could take an interface.