Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@

This only works on bigger nodes, as there needs to be some memory available for rendering pages using PHP too.

To store sessions in Redis, take a look at [the instructions on how to configure this](../../ecommerce-applications/magento-1/how-to-configure-redis-for-magento-1.md) ([Magento 2](../../ecommerce-applications/magento-2/how-to-configure-redis-for-magento-2.md))
To store sessions in Redis, take a look at [the instructions on how to configure this on Magento-1](../../ecommerce-applications/magento-1/how-to-configure-redis-for-magento-1.md) ([Redis on Magento 2](../../ecommerce-applications/magento-2/how-to-configure-redis-for-magento-2.md) )

Check warning on line 128 in docs/best-practices/performance/how-to-optimize-the-performance-of-your-magento-shop.md

View workflow job for this annotation

GitHub Actions / build

'myst' cross-reference target not found: '../../ecommerce-applications/magento2/how-to-configure-valkey-on-magento-2.md' [myst.xref_missing] [myst.xref_missing]
([Valkey on Magento 2](../../ecommerce-applications/magento2/how-to-configure-valkey-on-magento-2.md))


## Image Optimizations (10 mins)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Redis is a caching method which can increase the speed of the backend and fronte

**NB: When you used the [hypernode-importer](../../hypernode-platform/tools/how-to-migrate-your-shop-to-hypernode.md#how-to-migrate-your-shop-to-hypernode) and you were already using Redis you don't have to follow this tutorial.**

Want to know how to configure Redis in Magento 2? Have a look at [this article](../../ecommerce-applications/magento-2/how-to-configure-redis-for-magento-2.md)!
Want to know how to configure Redis or Valkey in Magento 2? Have a look at [Redis on Magento-2](../../ecommerce-applications/magento-2/how-to-configure-redis-for-magento-2.md) or
[Valkey on Magento-2](../../ecommerce-applications/magento-2/how-to-configure-valkey-for-magento-2.md)!

## Setup Redis by Changing your local.xml File

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Redis is a caching method which can increase the speed of the backend and fronte

Want to know how to configure Redis in Magento 1? Have a look at [this article](../../ecommerce-applications/magento-1/how-to-configure-redis-for-magento-1.md)!

Want to know how to configure Valkey in Magento 2? Have a look at [this article](../../ecommerce-applications/magento-2/how-to-configure-valkey-for-magento-2.md)!


## Configure Redis Cache for Magento 2

There are two ways to configure Redis Cache for Magento 2. You can either run a command which automatically updates the `env.php` with the correct details or you can manually change the `env.php` file.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
---
myst:
html_meta:
description: This article explains how to configure Valkey on your Magento 2 shop on Hypernode and how to work with redis-cli or valkey-cli.
title: How to configure Valkey for Magento 2? | Hypernode
redirect_from:
- /ecommerce-applications/magento-2/how-to-configure-valkey-for-magento-2/
---

# How to Enable Valkey for Magento 2

Valkey is a Redis-compatible in-memory store. On Hypernode, **Valkey-8** is available on Debian Bookworm single-node setups. It is not supported on Debian Buster or on Hypernode Clusters. **Redis remains supported.**

> If you previously used Redis, **no action needed** after enabling it ( **see example below** ), existing Magento settings continue to work with Valkey.
>
## Paths

- Logs: `/var/log/valkey/`
- App-scoped directory on Hypernode: `/data/web/valkey/`

---

Valkey is Redis-compatible, so your existing Magento `redis` configuration flags work unchanged.

> **Enable Valkey on supported nodes**
>
> ```console
> $ hypernode-systemctl settings valkey_enabled True
> ```

Take a look at the `livelog` command to check the progress on the update job.

## Redis Tools or Valkey Tools?

> `redis-cli`and `redis-tools` is symlinked to `valkey-cli` and `valkey-tools` when Valkey is enabled. You can use **either**. Examples below show `redis-cli` with an `or valkey-cli` alternative.


# First Time Setup - Redis Not Previously Configured

## Configure Valkey Cache for Magento 2

There are two ways to configure the cache. You can run a command that updates `env.php`, or you can edit it yourself.

## Configure Valkey Cache for Magento 2 Through the Commandline

Use the following command to enable backend caching:

```console
$ cd /data/web/magento2
$ bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=redismaster --cache-backend-redis-db=1
```

Now flush your cache:

```console
$ rm -rf /data/web/magento2/var/cache/*
$ redis-cli flushall
# or
$ valkey-cli flushall
```

## Configure Valkey Full Page Caching for Magento 2

Enable page caching:

```console
$ cd /data/web/magento2
$ bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=redismaster --page-cache-redis-db=2
```

And flush your cache:

```console
$ rm -rf /data/web/magento2/var/cache/*
$ redis-cli flushall
# or
$ valkey-cli flushall
```

## Flush Your Caches

To flush your Magento cache, clear the Valkey database you configured:

```console
$ redis-cli -n 1 flushdb
# or
$ valkey-cli -n 1 flushdb
```

Or alternatively use `n98-magerun2` or the Magento cli tool:

```console
## Flush using n98-magerun2
$ n98-magerun2 cache:flush
## Flush using magento cli
$ cd /data/web/magento2 && bin/magento cache:flush
```

To flush all sessions, caches etc (flush the full instance), use the following command:

```console
$ redis-cli flushall
# or
$ valkey-cli flushall
```

## Changing the Compression Library

It is possible to use the compression library 'Snappy' on Hypernode.

In order to use the compression library Snappy for your Valkey cache you can run the following commands:

```console
$ bin/magento setup:config:set --cache-backend-redis-compression-lib=snappy
$ # If you use Magento's builtin page cache
$ bin/magento setup:config:set --page-cache-redis-compression-lib=snappy
```

## Configure Magento 2 to Use Valkey as the Session Store

You can use Valkey for storing sessions too.

### Configure Magento 2 to Store Sessions in Valkey

Run the following command:

```console
$ cd /data/web/magento2
$ bin/magento setup:config:set --session-save=redis --session-save-redis-host=redismaster --session-save-redis-db=3
```

Now flush your cache:

```console
$ redis-cli flushall
# or
$ valkey-cli flushall
```

### Enable Second Valkey Instance for Sessions

Enable the second instance for sessions:

```console
$ hypernode-systemctl settings redis_persistent_instance True
```

After enabling the second instance change the session port to `6378` and the database to `0`:

```console
$ cd /data/web/magento2
$ bin/magento setup:config:set --session-save-redis-port=6378 --session-save-redis-db=0
```

Furthermore you can add the following line to your crontab to take periodic background snapshots:

```
* * * * * redis-cli -p 6378 bgsave
# or
* * * * * valkey-cli -p 6378 bgsave
```

### Test Whether Your Sessions Are Stored in Valkey

To verify whether your configuration is working properly, first clear your filesystem session store:

```console
$ rm /data/web/public/var/sessions/*
```

Now open the site in your browser and hit `F5` a few times or log in to the admin panel. Then check the configured database:

```console
$ redis-cli -n 0 keys '*'
# or
$ valkey-cli -n 0 keys '*'
```
1 change: 1 addition & 0 deletions documentation_urls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ article: https://support.hypernode.com/en/ecommerce/magento-1/how-to-set-the-ret
article: https://support.hypernode.com/en/ecommerce/magento-1/how-to-set-up-a-staging-environment-for-magento-1/
article: https://support.hypernode.com/en/ecommerce/magento-2/how-to-change-your-magento-2-base-urls/
article: https://support.hypernode.com/en/ecommerce/magento-2/how-to-configure-redis-for-magento-2/
article: https://support.hypernode.com/en/ecommerce/magento-2/how-to-configure-valkey-for-magento-2/
article: https://support.hypernode.com/en/ecommerce/magento-2/how-to-configure-varnish-for-magento-2-x/
article: https://support.hypernode.com/en/ecommerce/magento-2/how-to-create-a-robots-txt-for-magento-2-x/
article: https://support.hypernode.com/en/ecommerce/magento-2/how-to-create-a-sitemap-xml-for-magento-2-x/
Expand Down
Loading