PhpRedis vs Predis: Comparison on real production data

Avtandil Kikabidze
2 min readFeb 12, 2019

Discussions about performance comparisons between PhpRedis and Predis are pretty old. I decided to measure the performance of the libraries in conjunction with the most popular framework - Laravel.

PhpRedis is a PHP extension for communicating with the Redis storage.

Predis is the alternative for PhpRedis on pure PHP and does not require any additional C extension by default, but it can be optionally paired with phpiredis.

I’ve tested both libraries using the real high-load project code, with ~10K online users.

Testing environment:

OS: Ubuntu 18.04.2 LTS x86_64
CPU: Intel i7–6820HQ (8) @ 3.600GHz
Memory: 32GB
PHP: v7.2.15
Laravel: v5.7.25
MySQL: MySQL v5.7
Redis: v5.0.3
PhpRedis: v4.2.0
Predis: v1.1.1

The script generates cache from the database and stores eloquent models in the Redis.

Laravel by default does not support custom serializers for Redis, but I used the Laravel Lodash package for that.

Results:

Predis (serializer: php)Execution time: 00:05:53.0355
Cache storage used: 936.92MB
— — — — — — — — — — — — — — — — — —
Predis (serializer: igbinary)
Execution time: 00:07:45.2460
Cache storage used: 342.66MB
— — — — — — — — — — — — — — — — —
Predis (serializer: igbinary, with ext-phpiredis)
Execution time: 00:07:51.9046
Cache storage used: 342.66MB
— — — — — — — — — — — — — — — — —
PhpRedis (serializer: php)
Execution time: 00:01:36.9863
Cache storage used: 936.75MB
— — — — — — — — — — — — — — — — —
PhpRedis (serializer: igbinary)
Execution time: 00:01:37.3176
Cache storage used: 342.66MB

Conclusion:

PhpRedis is faster about x6 times. Using igbinary serializer reduces stored data size about 3x times. If Redis installed on separate machines, reducing network traffic is a very significant speedup.

Some related links:

--

--