Support » Plugin: Redis Object Cache » Enabled Unix Socket but still showing TCP Protocol

  • Hello Till,
    First of all thanks for creating this ultimate speed solution for WP based site. I am using Redis Object Cache since a year and really happy with the outcomes.

    Recently, I came across the following article which indicates that using Unix Socket instead of TCP, increases the performance by a good margin.

    So, I configured the server as per the following article:
    https://guides.wp-bullet.com/how-to-configure-redis-to-use-unix-socket-speed-boost/

    Then, I added the following snippets in my wp-config.php as discussed in this topic:
    https://wordpress.org/support/topic/work-perfect-with-tcp-dont-work-with-unix-socket/

    After making all these changes I restarted the Nginx and Redis but still, I don’t see any Unix Socket Usage related info in Diagnostics section.

    I still get the following output:

    Status: Connected
    Client: PhpRedis (v4.2.0)
    Drop-in: Valid
    Ping: +PONG
    Redis Extension: 4.2.0
    Predis Client: 1.1.1
    PHP Version: 7.2.13-1+ubuntu18.04.1+deb.sury.org+1
    Multisite: No
    Global Prefix: "bnt_"
    Blog Prefix: "bnt_"
    WP_CACHE_KEY_SALT: "example.com:"

    Am I missing something? How do I know if Redis Object Cache is using Unix Socket instead of TCP connection?

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 16 total)
  • Hi, Narender Chopra.
    Redis work with other apps as unix socket?

    And check redis in terminal, use command:
    redis-cli -s /var/run/redis/redis.sock
    Then input monitor

    And check redis in terminal, use command:
    redis-cli -s /var/run/redis/redis.sock
    Then input monitor

    The output is OK

    Plugin Author Till Krüss

    (@tillkruess)

    @preetji: Can you try moving the Redis constants further up in your config file?

    Hello Till,
    Thanks for your reply. Actually, I already have the Redis constants in the starting of the Wp-Config, right after the Database credentials.

    Finally, I was able to get the Unix Socket displayed in Diagnostics Section of the plugin. But now, it says “Not Connected”. There is some permission error:

    Status: Not Connected
    Client: PhpRedis (v4.2.0)
    Drop-in: Valid
    Connection Exception: Permission denied (RedisException)
    Redis Extension: 4.2.0
    Predis Client: 1.1.1
    PHP Version: 7.2.13-1+ubuntu18.04.1+deb.sury.org+1
    Multisite: No
    Global Prefix: "bnt_"
    Blog Prefix: "bnt_"
    WP_REDIS_SCHEME: "unix"
    WP_REDIS_PATH: "\/var\/run\/redis\/redis.sock"

    I tried to switch unixsocketperm from 755 to 775 and vice-versa, Restarted Redis yet the same issue.

    I followed the below-given steps to make the redis user a member of the www-data group:

    1. sudo usermod -g www-data redis
    2. sudo mkdir -p /var/run/redis/
    3. sudo chown -R redis:www-data /var/run/redis
    4. sudo service redis-server restart

    Output for the socket: redis-cli -s /var/run/redis/redis.sock ping
    pong

    • This reply was modified 2 months, 3 weeks ago by  Narender Chopra. Reason: output added
    Plugin Author Till Krüss

    (@tillkruess)

    Can you try using TCP instead of Unix sockets?

    Hey Till,
    I have been using TCP instead of Unix Socket since the starting and it works fine. I was just thinking to implement Unix as it is said to be 20-25% faster than TCP connection.

    Plugin Author Till Krüss

    (@tillkruess)

    Aha, fair enough. I’m so used to TCP due to it’s distributed nature 🙂

    I would just create a single PHP file and use that for testing the connection because you might get a more detailed error message.

    
    <?php
    
    (new Redis)->connect('/var/run/redis/redis.sock');
    

    To resolve the permission issue, I have to refer you to Google or Stack Overflow. I’m sure your answer is out there.

    It would be great if you could post it here when you figured it out.

    Hey Timm,
    I gave it another try and switched the unixperm in redis.conf to 777 and restarted the server. Now, the status shows connected and has the following output:

    Status: Connected
    Client: Predis (v1.1.1)
    Drop-in: Valid
    Ping: PONG
    Redis Extension: Not Found
    Predis Client: 1.1.1
    PHP Version: 7.3.0-2+ubuntu18.04.1+deb.sury.org+1
    Multisite: No
    Global Prefix: "bnt_"
    Blog Prefix: "bnt_"
    WP_REDIS_SCHEME: "unix"
    WP_REDIS_PATH: "\/var\/run\/redis\/redis.sock"

    I am worried about Redis Extension: Not Found . It shows version 4.x.x when I switched my site configuration from PHP 7.3 to PHP 7.2.

    So, will it affect the performance of the plugin? Should I switch back to PHP 7.2 or stay with PHP 7.3?

    Plugin Author Till Krüss

    (@tillkruess)

    I always recommend PhpRedis (PECL) over Predis.

    Try upgrading to PHP 7.3 with PhpRedis 4.2.0, that’s my setup.

    Hey Till,
    I used the following steps to install/configure PHP 7.3 FPM and still can’t get PHP Redis Extension to be shown inside the plugin diagnostics with PHP 7.3:

    # php7.3-fpm
    apt update && apt install php7.3-fpm php7.3-xml php7.3-bz2 php7.3-zip php7.3-mysql php7.3-intl php7.3-gd php7.3-curl php7.3-soap php7.3-mbstring php7.3-bcmath -y
    
    # Adding redis.ini
    echo "extension=redis.so" > /etc/php/7.3/mods-available/redis.ini
    ln -sf /etc/php/mods-available/redis.ini /etc/php/7.3/fpm/conf.d/20-redis.ini
    ln -sf /etc/php/mods-available/redis.ini /etc/php/7.3/cli/conf.d/20-redis.ini
    service php7.3-fpm restart

    When I ran apt-get install php-redis the output is following:
    php-redis is already the newest version (4.2.0-1+ubuntu18.04.1+deb.sury.org+1)

    Plugin Author Till Krüss

    (@tillkruess)

    Did you restart your server? What does php -i show?

    Hey Till,
    I got it working after Removing php-redis extension, installing php7.3-dev and re-installing php-redis through pecl command. It just worked.
    Thanks a lot for the help 🙂

    I would love to hear from you about this one: https://pressjitsu.com/blog/redis-object-cache-wordpress/

    Any update to the plugin coming soon with the differences/improvements listed in the above blog post?

Viewing 15 replies - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.