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.

40 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 do not know if it's just me or if perhaps everybody else encountering issues with your site.
    It looks like some of the text on your posts are running off the screen. Can somebody else please comment
    and let me know if this is happening to them as well?
    This might be a issue with my internet browser because I've had this happen before.

  3. ......nu stiu de unde scoateti voi atatea prostii cand fata asta are 43 de kg...si in plus a avut o sarcina extrauterina si a avortat, dupa multe incercari de a avea o sarcina cu ajutorul medicilor...

  4. You are blessed with the ability to reason…or you would have guzzled the kool aid. The desire to be led and told what to think supercedes the Sheeples need for independence. They shout freedom but move en masse like fish swimming together in a school. And education IS their enemy.

  5. I'm starting a new online website directory and was wondering if I can submit your website? I'm hoping to grow my directory little by little by hand so that it retains high quality. I will make sure and put your website in the correct category and I'll additionally use, "" as your anchor text. Please let me know if this is okay with you by mailing me at:. Appreciate it

  6. Really trustworthy blog. Please keep updating with great posts like this one. I have booked marked your site and am about to email it to a few friends of mine that I know would enjoy reading..

  7. Oie tudo bem miga?Miga que legal, adorei a dica! ultimamente estou usando produtos menos nocivos ao cabelo pq como disse no meu post estou com queda de cabelo mas assim que melhorar vou começar a usar essas belezinhas, adorei a dica! amo tudo sobre coisas de cabelos kkkk!!!!Bjs!!

  8. Oberdan S. Neto disse:A classe artística,está indignada com o sujeito aí.Ele pegou dinheiro público e contratou o Cantor e Compositor,Ivan Lins para fazer um CD para sua mulher.Porra tú ainda vem dizer que é coisa de amarelinhos,pensas que todo mundo é besta.

  9. Vous nous faites excellemment remarquer qu’il ne faut pas confier les projets de lois aux deputes, et que le gouvernement s’en sort très bien, merci. Supprimons donc le simulacre parlementaire, dans ces conditions. Il nous coute cher. Et puis supprimons aussi la moitié du gouvernement, dont personne ne sait ce qu’ils fabriquent au juste.

  10. That is quite fascinating, You happen to be an extremely expert blogger. We have joined your feed and search forward to looking for a lot more of your respective great put up. Also, I’ve shared your site in my sociable networks!

  11. I know what you mean about school counselors, they can just confuse things even further. Some fields you can look to as a backup is Occupational Therapist, Registered Nurse, Speech Language Pathologist, Physical Therapist, Social Worker, or a Respiratory Therapist. These careers are fairly good paying depending on the area you work in.

  12. I suffer from a distoted body image. I know i'm not fat but I HATE summer when the shorts and shorts sleeve clothes come out. A bathing suit sends me over the edge. I do not know why I am like this, who knows maybe it all the TV ads and the expectations of women to always look their best. I am at my best with the turtleneck, jeans and sweat shirts...my comfy clothes.

  13. A PF junta todos os dossiês e escutas telefônicas que tem do governo, mas não prende nimguèm. Nemhum PTralha entre os muitos culpados dos mensalões, sanguessugas... foram presos. A PF guarda todas as provas que tem dos aloprados para chantagear o governo corrupto e seus ministros quando pleiteiam ajuste de salários. E ganham todas!!!

  14. I like the helpful information you provide for your articles.I will bookmark your weblog and take a look at once more right here regularly.I’m quite certain I will learn lots of new stuff proper right here! Good luck for the next!

  15. Eh non, ‘a marche plus. Trop de dégâts collatéraux.Ceci mis à part, et sans vouloir dénier l’intérêt de la discussion sur le Suaire, hum, bon, hein, elle peut se poursuivre Parce que bon, là, nous étions sur des questions de texte et de logique.

  16. J’ai voté pour celui avec les ondes radio. Le concept des guillemets me semble trop quelconque. Le concept du raton-laveur semble un poil incongru. Celui avec les ondes en revanche diffuse la notion de broadcast, donc en phase avec le concept Seesmic.Just IMHO, of course.

  17. Morning Miss Becky,Love your tags, so cute and loverly!Guess I know what you have been upto.........lolPeat pots........they do have such neat texture, and look great all glamed up! Great idea my friend.Hope you are doing well.Love ya, Nellie

  18. I'm not a chesses lover, but this look so yummy and easy, may change my taste bug! Love all your food pics. Have a nice Sunday! Mei

  19. ha sok linket pakolsz bele, a rendszer spamnek érzékeli, így fennakad a szűrÅ‘n. De már rákattintottam az “elfogad” gombra, így publikálódott :)Tetszik / Egyetértek: 0 Az értékeléshez be kell

  20. Mama Mac here, happy to chat about anti-biotics although for a much more scientific conversation look at Martha Herbert’s stuff. She is really concerned about the autism/antibiotic possible link and also the accumulative damage of abx and vaccines together. You may also want to look at Tinus Smits Cease homeopathy if you haven’t already. Lots of parents having good responses from homeopathically clearing the vaccines their child regressed most closely to. Send me a private message on facebook and we can connect. Happy to.

  21. Le Lapsang Souchong est mon thé préféré, je ne l'ai jamais cuisiné mais ta recette a tout pour me plaire. Avec des pêches peut-être? Pour cela il faudrait que l'été soit enfin là...Je te souhaite un bon week-end du 1er mai! Moi je serais dans le Loiret.

  22. Freitag, 02.12.2011Ihr habt Euch gerade dadurch, dass ihr nicht programmieren könnt, eure ganze Plattform versaut!Was soll der scheiß? Werbung ist ja vollkommen OK und nötig, aber zwischen jeden Song?Wenn ich Songs suche und auf play drücke, kommt Werbung. Dann kommt irgendein scheiß Song aus den aktuellen Charts, von alleine! Wenn ich wieder auf meinen gesuchten Song klicke, kommt wieder Werbung und dann wieder irgendein scheißlied!VOLLIDIOTEN!

  23. Yeah?| wonderful elements the following. My partner and i?|l quite delighted to be your posting. Thanks for your time that i’m taking a look onward to touch anyone. Are you going to generously drop us a mail?

  24. aeeeee caralho, hoje serei um dos primeiros a comentar.Meu deus gente, vocês estão de parabéns total, o episódio ficou muito engraçado.Vou mandar o resto por e-mail senão não adianta mandar e-mail hehe.Abraço galera.Ps: Quando precisarem de alguem para gravar, ajudar em alguma coisa, um ouvinte desocupado que adora podcast, pode me chamar, estou disponível. Meu Skype: leobruskiAquele abraço.

  25. If it's Ford with the gas-tank in the back it's prone to immolation.A 3-liter 5-series v-8 is pretty small, might fit the Zed. Makes me wonder what the Mexistan Navy will show-up with, an armored Cigarette boat?

  26. Six Flags. Whoo hoo!!! What a fun place.Great list. I forgot there was a theme this week, but I’ve already started for next week so I won’t forget. Happy TT!

  27. Jincy – thank you for posting this and sharing your lives with us. David and I are honored to get to know you. We’ve never had kids, even tho we’ve been married 30 yrs. However, we have lots of “kids” from over the yrs when we did student ministry. We totally value the NEW family trees that the Lord places us in! Blessings to you and much joy on your journey!

  28. thanks swapusha- u wont belive it but we had been telling her teh baby will come post her brithday so her new query is"My birthday is over...Why is baby not coming out yet??"

  29. ohhh how i love seeing them all again. and it’s always fun to see which favorites we share in common. thank you for capturing our day SO beyond perfectly. <3

  30. Enhorabuena por la nota! Es un placer ver que se te reconocen todos tus años de buen hacer como maestro y, por sobre todo, tus cualidades personales. ¿Para cuándo una muestra de tus fotos en B/N? Nos encantaría ver tus trabajos de San Antonio y los de la Alpujarra. Para las fotos de la naturaleza se necesitan cámaras sensibles; pero la fotografía social requiere que sea el corazón el que tenga sensibilidad para captar las emociones. Un abrazo.

  31. James,Your leverage calculation has at least three basic errors in it.1. You get 28% by subtracting percentages (not a mathematically valid thing to do.)2. You subtract percentages of different things – inflation rate and a leverage ratio. This is just meaningless.3. You take the mortgage percentage and apply it to the down payment not the amount borrowed.Do it in dollar space (e.g. $10K down on a $100K house, $3K ROR, $2K of inflation, 6% on a $90K note,) and you will get a reasonable leverage number.

  32. "I get to hear stuff you don't and when I do, I tell folks to knock it off."I fail to see what this has to do with someone choosing to call themselves "Italian-American", "African-American" etc...

  33. As an Aussie, I couldn’t relate to the people you mentioned but I was totally intrigued about the woman who mooned someone to keep the attention off her ex husband…what was he doing?Can’t say I’ve mooned and the last time I saw one was on a school bus full of 14 year olds All the best with your !!!

  34. Which yr, after years for lobbying with Capitol Incline by way of MyGoodDeed and then the 9/11 network, President Barack Obama fixed to laws a measure passed by Institutions the first, that used to be implementing September 14 for a Country’s Day’s Provider and even Memorial.

  35. My brother suggested I may like this blog. He was
    once entirely right. This publish truly made my day.
    You cann't consider simply how so much time I had spent for this info!
    Thank you!

    Also visit my bllog ... fb video downloader

  36. was de aanleiding het laatste bericht met uitleg hoe je van je WordPress.com blog naar een eigen WordPress.org kunt verhuizen… daar zat natuurlijk een link in naar een van mijn hosting bedrijven als voorbeeld, dus dat

  37. Your style is so unique in comparison to other folks I have
    read stuff from. I appreciate you for posting when you've got the opportunity, Guess I'll just bookmark this web

  38. Taco Gringo. You know how *&^%ed I was when I learned that a “Sancho” wasn’t a real mexican dish?Thanks Taylorville, you prepared me quite well for the world.When I was home taking care of my mom’s estate my brother and I drug my wife, Rita, to Taco Gringo. It was, indeed, still the same. And every bit as good. And every bit as unreal.

  39. Tak Tak ;o)Det holdt altså også hårdt med at få dem malet.Svamp nr.4 er lige på trapperne til at blive færdig, og velkommen til dig Anja ;o)Det er altid dejligt at få nye læsere til og opdage nye blogs.

  40. Excellent blog right here! Also your web site
    so much up fast! What host are you using?
    Can I get your associate link for your host?
    I want my site loaded up as fast as yours lol

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=""> <s> <strike> <strong>