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.

36 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. Without places to play (and a strict “all-ages” policy) a lot of these bands would have died and the scene would have been little more than a
    footnote. It is not all over, the latest cell phones
    of modern era are blessed with fascinating features and their capacity to support latest technologies can be commendable.
    Personal reason: A reference to happier times shared by Rick and Ilsa, perfectly times,
    perfect delivered.

  3. 28 oz Delmonte Chunky Diced Zesty Chili Style tomatoes or equivalent.
    Power outlets make sure that you are getting problem free experience even with your old laptops because they may turn dark without power outlets.
    Xanthan gum is currently used to international thickening, suspension, emulsion, stable in in one body.

    Look into my web-site; Dr Peter Osborne Credentials

  4. Hello i am kavin, its my first occasion to commenting anywhere, when i read this paragraph i thought i
    could also create comment due to this sensible piece of writing.

  5. I really like what you guys are up too. Such clever work and
    exposure! Keep up the very good works guys I’ve you guys to my blogroll.

  6. I’ve been exploring for a little bit for any high quality
    articles or blog posts on this kind of space . Exploring in Yahoo I at last stumbled upon this web site.
    Reading this information So i am happy to exhibit that I’ve
    a very excellent uncanny feeling I came upon exactly what I needed.

    I so much indubitably will make sure to don?t overlook this website and provides it a look

  7. high end baby furniture

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

  8. beter dan alle andere vorige betaald SEO Tools mij
    watertje using te leren is hoe om te zoeken engine optimization en ik onmiddellijk bijgewerkt.
    Wat is goed aan deze zaak is dat iedereen kan deel van uitmaken en hun aanpak tot succes maken. Als je de eigenaar van een website en u
    wilt nemen deel een online marketing bedrijf, moet u weten de plaats om goede affiliate programma’s.
    Recht hier, kunt u een van de grootste internet affiliate marketing programma’s in de
    industrie. Om extra bijzonder, clickbank heeft
    meer dan honderd, 000 medewerkers die zijn specialisten om
    te vinden van potentiële klanten op uw affiliateprogramma.

  9. Types of sims can vary between the latest video
    game to accurate cockpit replication, positioned on a hydraulic actuator, managed
    through cutting-edge computer technology. This area has 122 casinos, the largest gambling building concentration in the
    United States. Yellow Yoshi is a good stomper and
    can create a big cloud of dust when he lands. Being a part of
    Boggle online can be a great joy for those who enjoy testing their eyes
    as well as their minds. If they give a good grade for a particular, most
    probably you too will find the game interesting.

  10. You ought to be a part of a contest for one of the greatest
    sites on the internet. I’m going to highly recommend this web site!

    My blog post: arrow storage sheds for sale

  11. You are so cool! I don’t think I have read through a single thing like this before.
    So nice to find somebody with original thoughts on this subject.
    Seriously.. thanks for starting this up. This web
    site is something that’s needed on the internet, someone with a little originality!

  12. Just want to say your article is as amazing.
    The clearness on your submit is just great and i can assume
    you are a professional on this subject. Fine with your permission let me to seize your RSS
    feed to keep up to date with drawing close post. Thanks 1,000,000 and please keep up
    the gratifying work.

  13. With radio and TV mediums, your marketing dollars may buy
    you one or maybe two commercials that periodically hit the airwaves.
    This is a significant feature of promotional products:
    They are a physical asset that continues to promote your brand or message on a continual basis.
    So, in a way, they serve both the utility functions of clothing and promotion.

    Check out my weblog :: digital sublimations Pleasant Ridge Michigan; Lila,

  14. I every time spent my half an hour to read this
    web site’s articles or reviews everyday along with a mug of coffee.

  15. I think that everything said was actually very reasonable.
    However, consider this, what if you added a
    little content? I am not suggesting your content isn’t solid., however what if you
    added something that grabbed folk’s attention? I mean clorophilla.blog

  16. Let me straight away clutch your current feed while i are not able to to uncover your current e mail ongoing weblink or maybe e-newsletter service. Do you have any? Make sure you allow me personally recognize making sure that I may register.. geld verdienen homepage Cheers.

  17. They are affiliated with Wealth magazine and as so frequently happens
    on the web, you can find people that think these guys
    are the anti-christ and others that say their techniques made them a millionaire, changing their lives
    forever. ‘ Bryan, a 37 year old navy enlisted from Michigan, not only dates black women but was married to one.
    Ok now what woman wouldn’t be flattered to be recognized as Scarlett as well as other really intriguing woman.

  18. Spot on with this write-up, I actually believe this
    website needs much more attention. I’ll probably be
    back again to see more, thanks for the info!

  19. Expect a big increase in decision thus a pixel-density of around 330PPI
    must start to see the Samsung come very near the Apple in this department.
    It absolutely wasn’t until two organizations, Bell Laboratories and Samsung, decided to embark on a spectacular contest to
    find out who could be the initial to produce a genuine cell-phone that anymore advance was produced.

  20. Woah! I’m really digging the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s hard to get that “perfect balance” between superb usability and visual appearance.

    I must say you’ve done a superb job with this. Also, the blog loads super fast for me on Opera.
    Excellent Blog!

  21. Agree to this review and we’ll save a mythical creature!

  22. Great post.

    Also visit my webpage … web site (Alejandrina)

  23. I’ve been online on line over 3 hours nowadays, still Irrrve never found just about any useful content similar to your own property. It is really lovely value ample for me.. Link Web Site I believe, in case many world wide web proprietors as well as blog owners manufactured perfectly content material as you performed, the world wide web will probably be considerably more very helpful than before.

  24. hello there and thank you for your info – I’ve certainly picked up
    anything new from right here. I did however
    expertise several technical points using this website, since I experienced to reload
    the website lots of times previous to I could get it to load properly.
    I had been wondering if your web host is OK? Not that I’m complaining,
    but sluggish loading instances times will sometimes affect your placement in google and could damage your high-quality score if advertising and marketing
    with Adwords. Anyway I’m adding this RSS to my e-mail and could look
    out for much more of your respective fascinating content.
    Make sure you update this again soon.

  25. Hi there to every one, the contents present at this site are really amazing for
    people experience, well, keep up the good work fellows.

  26. excellent submit, very informative. I wonder why the opposite experts of this sector do not realize this.
    You should continue your writing. I’m sure, you have
    a huge readers’ base already!

  27. hi! , Is extremely good composing a lot! quantity most people be in contact extra close to your post for America online? I needed an experienced within this method to clear up this difficulty.. Krupp Maybe that is definitely a person! Looking forward to watch you.

  28. Undeniably imagine that that you said. Your favourite reason appeared to be on the net the easiest thing to bear in mind of.
    I say to you, I definitely get irked even as other people think about worries that they just do not recognise
    about. You controlled to hit the nail upon the top as well
    as outlined out the whole thing with no need side-effects , other folks could take a
    signal. Will probably be again to get more.

    Check out my homepage … probiotics for women

  29. Awesome blog! Is your theme custom made or did you
    download it from somewhere? A design like yours with a few simple tweeks would really
    make my blog stand out. Please let me know where you got your design. Kudos

    My blog post – Vegetarian Muscle Building (german-pal-killers.de)

  30. Excellent site you’ve got here.. It’s hard to find good quality writing like yours these days.
    I truly appreciate individuals like you! Take care!!

  31. Thanks for finally talking about > clorophilla.blog

  32. It’s not my first time to pay a quick visit this website, i am browsing this website
    dailly and obtain pleasant information from here daily.

  33. Wonderful blog! I found it while surfing around on Yahoo News.
    Do you have any tips on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there!
    Many thanks

  34. This site was… how do you say it? Relevant!!
    Finally I’ve found something which helped me.
    Appreciate it!

    Feel free to surf to my web site; muscle building
    products (http://www.paparazzi-muenchen.de/)

  35. I am regular reader, how are you everybody? This post posted at this site is genuinely

  36. That’s right, the video chat feature is, naturally, limited to Android phones with high-powered CPUs.
    With these fun-filled apps, Android has won the hearts of many.
    Any device in the modern age, first of all, has to have all that’s possible and then some.

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>