Redis Support with ISPConfig

,

Redis is an in-memory database and is therefore stored in memory. The queries of such a database are much faster than queries of a database stored on the hard disk. With Redis it is possible to get even more performance out of a website. For example, you can save the sessions of a website in Redis, which has a very positive effect on the loading time.

To save the PHP sessions into a Redis instance you just have to create a Redis instance for the website in ISPConfig and then add the “Session Save Handler” for Redis to the php.ini settings. After that you might have to change the configuration of your CMS or store system.

Possible settings for a Redis instance

The Redis instance set up and secured for a web page is permanently connected to the web page and can have the following values:

  • Max. 10 databases
  • Max. Database size: 50% of the available memory on the server is available.
  • Individual MaxMemory Policy to decide how Redis behaves when memory is full.
  • Automatic allocation of a port
  • Automatic assignment of a password
  • Access to log files

Set up Redis for a website

Under Sites open the menu “Redis Databases” and click on the button “Create a new Redis-Instance”.

Select the appropriate website and give the instance a name. Additionally you can set the maximum number of databases and the total size of the instance.
The size is limited to a maximum of 50% of the working memory. If you enter “-1” here, the maximum value is automatically taken. Please note that other services on your server also need memory.

Redis Policies

Under Redis policy you can define different rules how the Redis database reacts when its memory is exhausted.

  • noeviction return errors when the memory limit was reached and the client is trying to execute commands that could result in more memory to be used (most write commands, but DEL and a few more exceptions).
  • allkeys-lru evict keys by trying to remove the less recently used (LRU) keys first, in order to make space for the new data added.
  • volatile-lru evict keys by trying to remove the less recently used (LRU) keys first, but only among keys that have an expire set, in order to make space for the new data added.
  • allkeys-random evict keys randomly in order to make space for the new data added.
  • volatile-random evict keys randomly in order to make space for the new data added, but only evict keys with an expire set.
  • volatile-ttl evict keys with an expire set, and try to evict keys with a shorter time to live (TTL) first, in order to make space for the new data added.

Edit Redis instance

If you have created a Redis instance, you can for example change the policy and the database size at any time. You only have to open the corresponding instance in ISPConfig.

Create PHP directive

If you want PHP to use the Redis database as session storage, you have to enter as in the individual php.ini settings. You can use ISPConfig for this – if nothing else is set, PHP will use the database 0 of the Redis instance for session storage.

In ISPConfig open the website and select the tab “Options”. Under “Custom php.ini settings” you only have to click on “[Redis Session Save Handler]”. Now the database 0 of the Redis instance is entered for PHP sessions.

More

Redis Documentation