About Predis and benchmarks: why a pure-PHP Redis client anyway?

As some of you might know I’m the author and maintainer of Predis, a pure-PHP client library for Redis. When I started this project back in mid-2009 Redis was a very young yet promising NoSQL key-value store with only three client libraries available for PHP (one of which was a C-based extension that eventually led to phpredis) offering support only for the Redis commands implemented at that time, and plagued by many bugs. Fast forward to date, and both Predis and phpredis are now the two most used, stable and up-to-date clients in PHP-land among the bunch available. Although it’s mostly a one-man project, I’m very proud of the work behind its development and thankful for the contributions received from the community.

So why am I writing this blog post? To cut it straight to the point, I think there’s sometimes a little misconception about the very reason for which Predis exists nowadays and Aleksey’s recent blog post is offering me a good opportunity to clarify things a bit. Don’t get me wrong he made various valid points, but what has actually caught my attention and prompted me to write this post is the very introduction:

As some of you may know, I’m crazy about speed. So when I saw that people were happily using Predis as their choice of PHP client for Redis, I was a bit confused.

Why use a client written in PHP for something that should be ‘fast’ like Redis?

That kind of defeats the purpose - unless you don’t really care about response times and scalability. 

Predis was initially developed to fill the lack for a decent client library but turned into a more comprehensive solution allowing for maximum extensibility. In a sense, you may think of this library not only as a mere client for Redis but as a sort of framework (pass me the buzzword) with various building blocks that developers can leverage to create abstractions for features based upon Redis and expose them through a consistent interface. In my opinion a great example of such extensibility is the abstraction used to support Lua scripts exposing them as if they were common Redis operations such as GET or SET (and it works when using client-side sharding or master/slave replication too). Some parts were also reused to build a fully-asynchronous version of the client!

Obviously there’s a price to pay for everything and, in our case, that price is a penalty in raw speed compared to a C-based extension due to the undeniable greater overhead of a pure-PHP implementation. You can mitigate part of this overhead by using PHP >= 5.4 (faster at method dispatching), an opcode cache (you should do that anyway on production servers) or even plugging in phpiredis for faster protocol (de)serialization, but in the end you are optimizing your stack on a single-server basis. You can have 5, 10, 100 servers hitting Redis for distributed operations: that’s where Redis shines the best and that’s why it’s considered blazing fast. In such distributed scenarios, when one or more Redis instances are running on remote hosts, you will soon notice that most of the difference in speed is lost due to network round-trip times so you will be left for the most part with the inherent overhead of compiling the source code (or loading the cached opcodes) of Predis on each request. We’ve always been clear on what to expect out of Predis in this case and this is the reason why we have a FAQ about performances shipped along with the library. It’s a matter of trade offs: you sacrifice a low overhead for the sake of flexibility.

But then again, is it possible to use Predis when you also need decent overall performances or scalability? Depending on your definition of “decent performances” in the context of your application and provided a correct setup and architecture, yes. I personally know of a few high-load web sites using Predis, each one with a different reason behind their choice. Sure, if you don’t need fancy features and you only have one server performing requests against Redis running on the localhost then you would probably prefer to stick with phpredis thanks to its lower overhead, but that doesn’t mean being able to scale. Is Predis better than phpredis, or the other way around? Simply put, they are two solutions to the same problem and both have their different strong and weak points. In the end you are the one to decide based on your needs but, more importantly and as Aleksey concluded, don’t base your decisions on assumptions. And, I’d just like to add, not even on general benchmarks.


Puoi scrivere un commento oppure inviare un trackback dal tuo sito.

31 commenti a “About Predis and benchmarks: why a pure-PHP Redis client anyway?”

  1. Totally agree – performance isn’t an absolute quality, but rather is derived from your requirements. BTW – Predis is a great Redis client, thanks for creating it!

  2. I’m not that much of a online reader to be honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your website
    to come back down the road. All the best

  3. Wow! At last I got a webpage from where I know how to really get helpful facts regarding my
    study and knowledge.

    My page; windows and doors replacement palo alto

  4. Hello mates, how is the whole thing, and what you would like to say on the topic of this paragraph,
    in my view its genuinely awesome in support of me.

    Feel free to visitt my blog post :: test x180 ignite alpha

  5. google come shinhala new movis

    clorophilla.blog » About Predis and benchmarks: why a pure-PHP Redis client anyway?

  6. Cover Photo

    clorophilla.blog » About Predis and benchmarks: why a pure-PHP Redis client anyway?

  7. The farm encryption key subsequently, is stored in the Configuration Database.
    com is also easier to use than the vast majority of other solutions.

    You may use one password for all accounts but that isnt very safe.

    Visit my page … digital playground password

  8. Every weekend i used to go to see this website, as
    i want enjoyment, since this this website conations truly fastidious funny information too.

  9. I know this site provides quality based articles or reviews and other information, is there any other web page
    which gives these information in quality?

    Here is my website :: tjäna pengar på roulette
    (freespinsdirekt.se)

  10. dui lawyers

    clorophilla.blog » About Predis and benchmarks: why a pure-PHP Redis client anyway?

  11. I wɑs very pleased to find thiѕ website. I need tο to thank you for your time for tɦis particulɑrly wߋnderful
    read!! I definitely liked every bit of it and i also have you bookmarked to check out new stuff on your site.

  12. Hello there! This is my first visit to your blog!
    We are a team of volunteers and starting a new project in a
    community in the same niche. Your blog provided us valuable information to work on. You have
    done a extraordinary job!

  13. I was pretty pleased to find this website. I want
    to to thank you for ones time just for this fantastic read!!
    I definitely savored every bit of it and I have you book-marked to check out new stuff on your site.

  14. You’re so interesting! I do not suppose I have read something like thi before.
    So good to discover somebody with genuine thoughts on this
    subject. Seriously.. many thanks ffor starting this up.
    This web siite is something that is needed oon thee
    web, someone with a little originality!

    Feel free to surf too my site – sign shops in toronto

  15. modern furniture yahoo answers

    clorophilla.blog » About Predis and benchmarks: why a pure-PHP Redis client anyway?

  16. I read this paragraph fully on the topic of the comparison of newest
    and earlier technologies, it’s remarkable article.

  17. Incredible story there. What occurred after? Good luck!

  18. Amazing blog! Do you have any suggestions for aspiring writers?
    I’m hoping to start my own blog soon but I’m a little lost on everything.

    Would you recommend starting with a free platform like WordPress or go for a paid
    option? There are so many choices out there that I’m completely
    confused .. Any tips? Kudos!

    my blog: generateur fut 15

  19. free hosting

    clorophilla.blog » About Predis and benchmarks: why a pure-PHP Redis client anyway?

  20. precious hairs

    clorophilla.blog » PHP

  21. For most recent news you have to go to see internet and on web
    I found this web page as a finest web site for latest updates.

  22. I blog frequently and I genuinely thank you for your content.

    This great article has really peaked my interest.
    I will bookmark your website and keep checking for new information about once a week.
    I opted in for your RSS feed as well.

  23. Gravatar
    Tatewaki ha detto:

    Hi big oxygen sucker!!! keep in mind to turn off your pc during the nightime otherwise you could die from the higher amount of carbon dioxide in the air. It’s true!!!1! somebody told me but i can’t remember who :O
    I’m here in this boring post just to add some backgroud noise and I’m writing in english because it’s cool and give me the opportunity to show off in front of my fans, anyway … back to us …i heard from crichan and she asked me to give you her regards :)
    Join us on facebook Dani …. pretty pleeeeaaaseeeeeeeeee :P

  24. Gravatar
    Crichan ha detto:

    Torna su azzurra, sta casa aspett’atté!

  25. best DUI Attorney Milwaukee

    clorophilla.blog » About Predis and benchmarks: why a pure-PHP Redis client anyway?

  26. alli shortage

    clorophilla.blog » PHP

  27. Great blog! Do you have any tips and hints for aspiring writers?
    I’m hoping to start my own website soon but I’m a liittle
    lost on everything. Would you recommend starting with a free platform like WordPress or go
    blender for smoothies and juicing [Royal]
    a paid option? There are so many options out there that
    I’m completely confused .. Any recommendations? Thank you!

  28. this url

    clorophilla.blog » About Predis and benchmarks: why a pure-PHP Redis client anyway?

  29. When some one searches forr his required thing, therefore he/she needs
    to be available that in detail, therefore that thing is maintained
    over here.

    Have a ook at my blog; website

  30. •Speed up: If you have created a speedy choice of providing the CASC test then you certainly should put together since achievable.
    Decrease usually takes many forms, but listed here are the
    four most common. Whilst you are in college, take one more
    computer associated area.

  31. Thank for another wonderful post. The place else could anyone
    get that typ of information in such a perfect approach of
    writing? I have a presentation subsequent week, and I am at the look for such
    information.

    Feel free to surf to mmy weblog :: m88

Lascia un commento

Puoi utilizzare i seguenti tag XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>