PhpRedis vs Predis: Comparison on real production data

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:

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:

--

--

Software Engineer, IT Evangelist, Geek, Romantic..

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store