0

Windows / Using XAMPP / PHP version 7.4.11 / php_redis.dll Thread Safe for PHP 7.4 / Redis runs with command prompt

Connecting to Redis in my PHP application with $redis->pconnect('127.0.0.1', '6379') takes 20ms. That seems like a long time. I connect to Redis with every PHP request, and it takes 20ms every time.

Is there any way to speed this up? I read that it is supposed to take 1MS for PHP->phpredis to connect with Redis, which means I am doing something wrong.

In the redis.conf I set timeout to 60. Thinking this might allow for persistent connections meaning a second php request might re-use a previously opened connection to Redis, and save time. However nothing changes, pconnect takes roughly 20ms with every request.

What I have tried so far.

  • I ran Redis Server with Ubuntu, this changed nothing.
  • I ran Redis Server with Ubuntu, and opened a unix port. I read that this is faster. But I cannot manage to connect to the unix port in my PHP application. It throws an error.
  • I ran Redis Server with CMD and tried to open a unix port, but this does not work.
  • I installed Predis, this had some effect. When connecting to Redis with Predis it lasted 5ms. However when executing get/set hget/hset commands with Predis it was much slower then the get/set hget/hset commands with phpredis.

I am a huge noobie and I do not know very well what I am doing, I do not know how to ask any clearer and just hope that some smart person knows what is going wrong. Been trying to overcome this issue for the past 4 days and haven't gotten any closer.

Chiel
  • 11
  • 2
  • Are you running Redis under WSL, Docker or something else? – Chris Haas Nov 17 '20 at 19:34
  • this might answer your question: https://github.com/phpredis/phpredis/issues/1671 – Honk der Hase Nov 17 '20 at 20:44
  • @ChrisHaas under WSL – Chiel Nov 18 '20 at 09:09
  • @LarsStegelitz Thank you, they have not found a solution yet. But it seems related to windows. – Chiel Nov 18 '20 at 09:17
  • Did you try the registry entry change https://bugs.php.net/bug.php?id=78825 – Chris Haas Nov 18 '20 at 14:28
  • @ChrisHaas "However, it is also essential to inform you this is an essential Windows tool and needed to be reactivated for a proficient portion of work. You can disable the algorithm temporary as disabling it permanently might have a visible influence on the regular bandwidth. So, as you are done with your work, just reverse the settings by changing the data of two newly created values to 0." Redis is supposed to run constantly, so this is not a solution sadly. – Chiel Nov 19 '20 at 12:52
  • Looking more at this, even [Microsoft products](https://support.microsoft.com/en-us/help/235624/fix-tcp-ip-nagle-algorithm-for-microsoft-message-queue-server-can-be-d) ran into this issue and the solution was to enable TCP_NODEALY. If would recommend enabling that setting just to see if it makes your application perform better, and then see if the rest of the applications on the machine even notice. Really, at worst, your NIC will probably be working a bit overtime and your switch will receive extra packets, which isn't too terrible. – Chris Haas Nov 19 '20 at 14:55
  • @ChrisHaas Alright thank you, that did do something. Now it takes 10ms most of the time. Not a steady 10ms, going from 5ms - 10ms. Must mention that Predis (another redis library for PHP, as opposed to phpredis which I am using now) took a steady 5ms every try and perhaps is faster now, so cant help feeling something simple is off. – Chiel Nov 19 '20 at 16:38
  • @Chiel, you are absolutely right that something is off, and that is that unfortunately, the majority of PHP kernel and extension development occurs on *nix machines, and there are relatively very few people familiar with the deep, deep stuff, especially on Windows. Even the PhpRedis team acknowledges that they just don't have a way to test Windows. I personally develop on Windows (but host only on Linux) and can definitely say that I've encountered plenty of other "it doesn't work the same on Windows" examples in my life. Is it an option at all to switch to a Linux server? – Chris Haas Nov 19 '20 at 18:41
  • @ChrisHaas This is my testing environment, so perhaps in time! Thank you for the clarification. – Chiel Nov 21 '20 at 20:26

0 Answers0