Site icon MageComp Blog

How to Setup & Use High Performance Redis In Magento 2 Database

How to Setup and use High performance Redis In Magento 2 Database

How to Setup and use High performance Redis In Magento 2 Database

Nowadays, Store owners are adopting the new & improved Magento 2.0 Environment because of its new design, security and optimized performance but still they keep looking for better ways to optimize Magento store. Enabling default cache management will help a bit to improve performance but another great way to boost website performance is to use faster backend cache system.

So, the next question arises is, what is faster & alternative cache system for Magento 2?
Answer is Redis.

What is Redis?
Among available all alternatives, Redis is an open source, in-memory data structure store, used as a database, cache and session storage. It provides very fast backend cache with full cache support that doesn’t require low-level file system cache and stable performance for high traffic Magento stores.

Advantages of Redis:

Also, the requirements of Redis is very simple like.

Setting Up Redis as Cache Storage in Magento 2

Default Magento 2 Supports all Redis pre-requirement out of box so you don’t need to worry more, all you need to do is just add following code to your Magento Root/app/etc/env.php

'cache' =>
 array (
 'frontend' =>
	array (
 	'default' =>
   	array (
     	'backend' => 'Cm_Cache_Backend_Redis',
          'backend_options' =>
       	array (
         	'server' => '127.0.0.1', or ‘localhost’,
         	'port' => '6379',
             'persistent' => 0,
             'database' => '0',
             'force_standalone' => '0',
             'connect_retries' => '10',
             'read_timeout' => '30',
             'automatic_cleaning_factor' => '0',
 	        'compress_data' => '1',
             'compress_tags' => '1',
             'compress_threshold' => '20480',
             'compression_lib' => 'gzip',
     	),
 	),
  ),
),

Setting Up Redis as Session Storage in Magento 2

'session' =>
  array (
	'save' => 'redis',
	'redis' =>
   	array (
    	'host' => '127.0.0.1', or ‘localhost’,
    	'port' => '6379',
    	'password' => '',
    	'timeout' => '5',
        'persistent_identifier' => '',
    	'database' => '1',
        'compression_threshold' => '2048',
    	'compression_library' => 'gzip',
    	'log_level' => '1',
        'max_concurrency' => '6',
        'break_after_frontend' => '5',
        'break_after_adminhtml' => '30',
        'first_lifetime' => '600',
        'bot_first_lifetime' => '60',
   	 'bot_lifetime' => '7200',
        'disable_locking' => '0',
        'min_lifetime' => '60',
        'max_lifetime' => '2592000'
	)
)

By implementing above code, it will successfully install Redis and help you boosting your website performance. Let me know in the comment section if you have any ideas or issuse in implementing this code. I’ll be happy to help you!
Happy Coding!

Exit mobile version