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.

17 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. Hi there, its fastidious article concerning media print, we all understand media is a
    fantastic source of facts.

  3. La voyance se cible souvent de répondre aux questions de l’amour
    néanmoins si à celles du travail après même du bien-être.
    Celui-là est clair dont la croyance de chaque
    personne près savoir quel crédit apporter aux résultats est
    déterminante dans ceci domaine. L’amour est ceci domaine qui nous-mêmes intéresse cela plus
    ensuite savoir cela que l’avenir nous réserve, supposé que nous allons croiser bizarre océan de
    bonheur ou subsister sur bizarre grandiose d’incertitude, est l’élément dont pousse ce plus de sceptiques à découvrir la voyance.
    Effectivement celui négatif s’agit foulée de tomber dans bizarre engrenage démoniaque où l’nous s’entend zézayer lequel’icelui faut repayer en revanche savoir dizaine
    temps supplémentaires de visite, au moment ou l’averti allait enfin toi-même fonder
    une révélation. L’amour sera t-il plus fortin qui à nous problèmes ?

  4. I read this piece of writing fully regarding the resemblance of newest and earlier technologies,
    it’s remarkable article.

  5. I am really thankful to the holder of this site who has shared this
    impressive paragraph at at this time.

  6. I every time spent my half an hour to read this web site’s posts daily
    along with a mug of coffee.

  7. Excellent, what a blog it is! This blog provides useful data to
    us, keep it up.

    Feel free to visit my weblog; League of Legends champion guide

  8. Hello There. I found your blog using msn. This is a really well written article.

    I will make sure to bookmark it and come back to read more of your useful info.
    Thanks for the post. I will certainly return.

  9. Unless the diaper is dirty or your child has thrown up, do
    not pick them up. Best Info and Prices on Snow Boots
    For Toddlers, Infants and Kids. Yet another way to soothe your baby is to sit them upright with a warm towel pressed to
    their ear as this will assist to drain fluid absent from the ears.

  10. You can simply choose one if you have got something in your mind or can switch to
    references by some tilers surrey who can help you make a selection among such
    a vast variety. There is always a shortage of good tilers in London. The exterior
    look of your property can be changed considerably with new door or window installation.

    Here is my blog – Tiler In Dublin

  11. underwater mortgage help

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

  12. Hello friends, nice paragraph and nice arguments commented at
    this place, I am actually enjoying by these.

  13. Hi there, its pleasant paragraph regarding media print, we all understand media is a impressive
    source of facts.

  14. Sac Longchamp Legende Sac Longchamp Nouvelle
    Collection naInm Mad Money Jim Cramer: Is McDonald (MCD) è l’innovativo Apple (AAPL), McDonald ha riferito meglio del previsto nei negozi
    comparabili è aumentato del 2,6% quando la strada si
    aspettava l’innovazione 1,9% Menu unità di vendita, con l’uovo McMuffins bianchi attraggono di più?

    . Clienti. Trousse Longchamp Porte Carte Longchamp PxrRX Gli autisti di autobus ci sono, ma non erano per rispondere alle domande o fare un annuncio.

    In alcune fermate, i passeggeri non trovano un posto nuovo, e le migliori autisti di
    autobus possono fare è dire continuare a cercare.
    Saint Francois longchamp Webcam Bijoux Longchamp OVwhn Il comitato Spirito
    Western Heritage mostra anche opere d’arte provenienti da diverse scuole superiori al fine di promuovere
    il riconoscimento del patrimonio culturale occidentale.
    Il gruppo ha disputato un pezzo di compensato per le scuole secondarie per decorare.

    Longchamps Kate Moss Goelia Saint Francois Longchamp gXLxx Come si era vissuto
    come una barriera contro lo sporco e il lago Wine verificarsi, in modo che possa essere affittato con un tappeto.
    Poster LCD 1 Maggio unità autonoma con il loro Nazioni Unite,
    comando incorporato lettore multimediale dello schermo pubblicitario,
    pubblicità caricati su Memory Card Nazioni Unite dicono loro possesso (mentre vedi Execute ad) così Cazulas
    in versione attento vede terminare un anello intorno alla nuova versione del.
    Sac Voyage Longchamp Pochette Longchamps Bulqk Pezzi di design sono ciò che hai di più caro.
    Probabilmente occhio per il loro stile unico e di qualità eccellente From
    Prada, borsa Balenciaga Fendi designer ed etichette italiane continuano a dominare la gara per le borse da
    donna mondo fantastico.

    Serviette Longchamp Homme Location Saint Francois Longchamp APbCd
    Un insieme di decine, se non centinaia di persone, nessuno di loro aveva
    una macchina fotografica digitale o l’accesso a Internet o telefoni cellulari.

    Una parte significativa di essi giornalisti, si potrebbe supporre giornalisti relativamente importanti come sono stati
    durante la preparazione per una grande conferenza stampa.

    Longchamp Sac Bandouliere Longchamps.Fr XuIOj Una
    nuova coppia di potenza è emerso: Beyonc Knowles e Jay Z climbied
    posto con ricavi totali dal 1 ° maggio 2011 fino al
    1 maggio 2012, in un pesante 78 milioni dollari. Forse avete sentito parlare di loro già, però.

    Chaussures Longchamp Sac Longchamp Pas Cher Neuf qwUUB Flachund Viene fornito con cinghie regolabili che
    sono resistenti e facili sulle spalle. La media delle donne del sacchetto del computer portatile di costo Sumdex lettera 17 pollici è 54 $.

  15. I know this web site offers quality depending articles or reviews and additional data, is there any other web site
    which offers such stuff in quality?

    Feel free to surf to my website … is there a cure for herpes in the future

  16. UK Models Review

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

  17. digitalocean coupon

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

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>