diff --git a/public-site/docs/docs/topic-redis/index.md b/public-site/docs/docs/topic-redis/index.md new file mode 100644 index 00000000..5660cbe6 --- /dev/null +++ b/public-site/docs/docs/topic-redis/index.md @@ -0,0 +1,27 @@ +--- +title: Redis cache +--- + +# Redis cache +Redis (Remote Dictionary Server) is an open-source data structure. It is primarily used as a database, cache, and message broker. + +# Redis Cache Usage for Storing Session IDs + +One common use case for Redis is storing session IDs in web applications. When a user logs into a web application, a session is created with a unique ID. This session ID is often stored in a Redis cache for fast retrieval. It is recommended to use Redis as session store instead of cookie because of knows issues with refreshing the access token and updating the session cookie's Expires attribute. + +# Challenges of Running Redis as a Pod in Radix (in Kubernetes) + +Running Redis in a containerised environment like Kubernetes can have challenges, one of them is pod restart and data loss. +Redis operates in memory, which means its data is volatile. If a Redis pod is restarted due to node failure or pod eviction, all in-memory data, including session IDs, is lost unless persistence is configured. This can force users to log in again, leading to a poor user experience. + +Radix does not implicitly restart pods, configured to use pre-built `image` property when no changes in the `radixconfig.yaml` where applied to such component before deployment, e.g. `image` version or environment variables are changed. However, autoscaling of a cluster or maintenance of a cluster node can restart pods. + +# Using Azure Cache for Redis as an Alternative + +To overcome the limitations of running Redis natively in Kubernetes, a more robust solution is to use https://azure.microsoft.com/en-us/products/cache. Azure Cache for Redis is a fully managed, scalable, and highly available Redis service provided by Microsoft Azure. + +:::tip +It is highly recommend to use a persistent Session Store for production applications, like [Azure Cache for Redis](https://azure.microsoft.com/en-us/products/cache). + +Radix Web Console also uses Azure Cache for Redis to store sessions. +::: \ No newline at end of file diff --git a/public-site/docs/guides/authentication/index.md b/public-site/docs/guides/authentication/index.md index c44896b3..27de694a 100644 --- a/public-site/docs/guides/authentication/index.md +++ b/public-site/docs/guides/authentication/index.md @@ -64,7 +64,7 @@ When OAuth2 is enabled for a component in [`radixconfig.yaml`](/radix-config/ind `scope` is configured to include **offline_access**. With **offline_access** included, the OAuth2 service receives a long lived refresh token that is used to get a new access token as the old one expires. Read more about Microsoft Identity Platform scopes [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes). `setXAuthRequestHeaders` and `setAuthorizationHeader` are set to **true** to include to the upstream request *X-Auth-** headers with claims from the access token, the access token itself, and the *Authorization: Bearer* header with the ID Token. `sessionStoreType` can be set to **redis** instead of using the default of **cookie**. `connectionUrl` defines the address to the Redis server. - It is recommended to use Redis as session store instead of cookie because of [knows issues](#known-issues) with refreshing the access token and updating the session cookie's Expires attribute. + It is recommended to use [Redis](../../docs/topic-redis/index.md) as session store instead of cookie because of [knows issues](#known-issues) with refreshing the access token and updating the session cookie's Expires attribute. The Redis server can be hosted as a Radix component, or an external Redis service like [Azure Cache for Redis](https://azure.microsoft.com/nb-no/services/cache/). In this example, Redis is hosted as a Radix component. - Build the application in Radix and open the Radix Web Console to set REDIS_PASSWORD for the `redis` component, and required secrets for the OAuth service used by the `web` component. diff --git a/public-site/sidebars.ts b/public-site/sidebars.ts index 95109d16..5ae73aa1 100644 --- a/public-site/sidebars.ts +++ b/public-site/sidebars.ts @@ -106,6 +106,7 @@ const sidebars: SidebarsConfig = { 'docs/topic-radix-cli/index', 'docs/topic-code-editor-integration/index', 'docs/topic-dynatrace-int/index', + 'docs/topic-redis/index', ], } ],