Redis part 3 - Sessions benchmark - NVMe SSDs, Redis and MySQL

26.09.2019
extendedLogo

Which form of session storage leads to better performance in online shops? File system, memory or database? In our sessions benchmark, we measured and evaluated the write, read and change operations per second of Redis, NVMe SSDs and MySQL.

Test environment

The tests were carried out on one of our clusters with our current hardware (at the time of the test), such as Intel Xeon Gold 6254. For the test environment, we chose 4 CPU cores to represent the computing power of one of our average clusters. We set the RAM height to the very high value of 32 GB so that all cache files could be stored in the Linux file system cache. In most cases, this is possible with much less RAM.

ComponentsHardware
CPUIntel Xeon Gold 6254 @ 3.10GHz (4 enabled CPU cores)
SSDSamsung SSD PM1725b 3.2TB, PCIe 3.0 x8 NVMe SSD
RAM32 GB DDR4 2933 MHz

Benchmark: sessions

In addition to the application caches, we also wanted to know how the different storage options, i.e. NVMe SSDs (file system), Redis (main memory) and MySQL (database), affect the performance of the session memory.

Unlike the application caches, we could not rely on an established benchmark tool, as no tool exists yet that simulates the behaviour of Magento and Shopware sessions with all the usual backends as appropriately as possible. For this reason, we created our own script, which we published on GitHub.

Since sessions are simply data that are stored individually for each user of online shops, we used random strings with a length of 1,500 characters for testing. We stored these in the file system, in Redis and in MySQL and measured how many write, read and change operations are performed per second. Since delete operations are usually not relevant for sessions, they were not measured. This is because delete operations do not take place while users are sending their requests, but (optimally) take place in the background.

To simulate the behaviour of e-commerce projects, we not only carried out the measurements one after the other (as a single thread), but also in 8 parallel threads (multi-thread), which constantly read, wrote and changed data in the backend. In this way, we were able to simulate the behaviour of single and multiple simultaneous online shop users.

File system

A simple way to save sessions is to create a single file for each session within a specific folder. By default, this type of session storage is configured for PHP and Magento.

Redis

As with the application caches, we have stored the sessions in Redis. Here we have given all sessions an expiry date. This means that old sessions are automatically cleaned up after a while.

MySQL

In addition, we have stored and tested sessions in the MySQL database with the same settings that our clusters receive when delivered, for a performant MySQL operation. The storage of the sessions in MySQL is carried out by Shopware (by default) if no other settings are made.

Results

maxcluster sessions benchmark

Benchmark on write, read and change operations, single and multi-threaded, to compare the behaviour of Redis, NVMe SSDs and MySQL. The higher the bar, the better the result.

A write operation creates a value that does not yet exist and stores it in the backend. This corresponds to the creation of a new session.

A read operation reads such a value. This corresponds to reading a session.

A change operation replaces an existing value with another value. This is equivalent to updating a session through a client interaction.

Our sessions benchmark shows for the single thread that the throughput of write and change operations is very similar between the NVMe SSDs and Redis. In the case of read operations, however, the NVMe SSDs show a significantly higher throughput than Redis. For an online shop, this means that NVMe SSDs perform better than Redis for a single user of the shop. In conclusion, it can be said that online shops with low conversion already benefit from NVMe SSDs alone; there is no great advantage from Redis here.

BUT: As soon as several requests are processed simultaneously, the strength of Redis becomes apparent. In multi-thread, the processing speed increases for all three operations. Comparing the bars of the diagram shows that Redis achieves a 33% higher throughput in read operations than the NVMe SSDs and almost three times higher than MySQL. In write, Redis even processes 41% more operations than the NVMe SSDs and 60% more than MySQL. In the changing operations, the test showed the highest difference, as Redis achieved a throughput 61% higher than the NVMe SSDs and 87% higher than MySQL.

MySQL has the lowest throughput in all operations compared to the other two session stores, both single thread and multi-thread.

Conclusion: Which session memory provides more performance for online shops?

As soon as several visitors fill their shopping baskets at the same time on an online shop and sessions thus have to be saved by several visitors, it is worth using Redis. Our benchmark shows that Redis is faster in all three operations than file system-based storage (NVMe SSDs) or storage in the MySQL database. Therefore, we recommend the implementation of Redis.

Shopware stores the sessions in MySQL by default. Since this method is considerably slower than the other two session storage methods, the integration of Redis would mean an increase in performance for online shops. For Shopware, a Redis integration is therefore worthwhile in any case. However, if this is not desired, we recommend moving the sessions from the database to the file system for individual web servers in order to benefit from our fast NVMe SSDs. We will explain in detail how Redis is integrated into Shopware in the next blog post in this blog series.

Only with small Magento online shops, however, which have no or hardly any parallel access or conversion, is the integration of Redis not worthwhile. The fast NVMe SSDs, which are also part of our architecture, showed higher performance than Redis in the area of single thread sequential access times
.

Shop systemState of delivery of the manufacturerOur recommendation for sessions
Shopware - smallShopMySQLRedis
Shopware - medium to large shopMySQLRedis
Magento 1 - small ShopFile systemNVMe SSDs
Magento 1 - medium to large shopFile systemRedis
Magento 2 - small ShopFile systemNVMe SSDs
Magento 2 - medium to large shopFile systemRedis

Last updated on 09.06.2021 | JH

You have questions, requests, criticism, suggestions or just want to tell us your opinion about our blog? Here you have the opportunity to contact us directly.

Send e-mail