PhpRedis vs Predis: Comparison on real production data

PhpRedis vs Predis: Comparison on real production dataAvtandil KikabidzeBlockedUnblockFollowFollowingFeb 12Discussions 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_64CPU: Intel i7–6820HQ (8) @ 3.

600GHzMemory: 32GBPHP: v7.

2.

15Laravel: v5.

7.

25MySQL: MySQL v5.

7Redis: v5.

0.

3PhpRedis: v4.

2.

0Predis: v1.

1.

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

Results:Predis (serializer: php)Execution time: 00:05:53.

0355Cache storage used: 936.

92MB — — — — — — — — — — — — — — — — — — Predis (serializer: igbinary)Execution time: 00:07:45.

2460Cache storage used: 342.

66MB — — — — — — — — — — — — — — — — — — Predis (serializer: igbinary, with ext-phpiredis)Execution time: 00:07:51.

9046Cache storage used: 342.

66MB — — — — — — — — — — — — — — — — — — PhpRedis (serializer: php)Execution time: 00:01:36.

9863Cache storage used: 936.

75MB — — — — — — — — — — — — — — — — — — PhpRedis (serializer: igbinary)Execution time: 00:01:37.

3176Cache storage used: 342.

66MBConclusion: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:https://github.

com/nrk/predis/blob/v1.

1/FAQ.

md#speaking-about-performanceshttps://www.

quora.

com/Redis-How-does-PRedis-compare-with-phpredishttps://www.

alekseykorzun.

com/post/53283070010/benchmarking-memcached-and-redis-clients.

. More details

Leave a Reply