Skip to content

Commit

Permalink
Added info about Redis (#416)
Browse files Browse the repository at this point in the history
* Added info about Redis

* Update public-site/docs/docs/topic-redis/index.md

Co-authored-by: Richard Hagen <[email protected]>

---------

Co-authored-by: Richard Hagen <[email protected]>
  • Loading branch information
satr and Richard87 authored Oct 23, 2024
1 parent d63c8d3 commit fdae13e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions public-site/docs/docs/topic-redis/index.md
Original file line number Diff line number Diff line change
@@ -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.
:::
2 changes: 1 addition & 1 deletion public-site/docs/guides/authentication/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions public-site/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
}
],
Expand Down

0 comments on commit fdae13e

Please sign in to comment.