Webinoly is just the perfect tool for NGINX experts. Give it a try!
+2 votes
1.0k views
by Talented
edited by

Comparing latency with redis-cli I found out that I have 8000 microseconds latency with TCP and half of that(!) 4000 microseconds with a UNIX socket (LXC on a KVM VPS with dedicated resources). And Till Krüss Object Cache supports it very well. So my proposed changes as a pull request on GitHub https://github.com/QROkes/webinoly/pull/41.

Also here a script that I use to disable transparent hugepages persistently to further improve Redis latency on my host:

#!/bin/bash

 

cat > /usr/local/bin/disable-tph.sh <<EOF

#!/bin/bash

echo never > /sys/kernel/mm/transparent_hugepage/enabled

echo never > /sys/kernel/mm/transparent_hugepage/defrag

EOF

 

chmod u+x /usr/local/bin/disable-tph.sh

 

cat > /etc/systemd/system/disable-thp.service <<EOF

[Unit]

Description=Disable Transparent Hugepages

[Service]

ExecStart=/usr/local/bin/disable-tph.sh

[Install]

WantedBy=multi-user.target

EOF

 

sudo systemctl start disable-tph

sudo systemctl enable disable-tph

1 Answer

+1 vote
by Expert
selected by
 
Best answer

Thanks, Micha!

Do you have any technical references or docs to support these improvements?

by Talented
edited by

Yes, here some references:

  1. "...unix domain sockets can achieve around 50% more throughput than the TCP/IP loopback..."
    https://redis.io/topics/benchmarks#factors-impacting-redis-performance:~:text=unix%20domain%20sockets%20can%20achieve%20around%2050%25%20more%20throughput%20than%20the%20TCP%2FIP%20loopback
  2. https://guides.wp-bullet.com/how-to-configure-redis-to-use-unix-socket-speed-boost/
  3. https://sudonull.com/post/89734-Redis-which-is-faster-a-UNIX-socket-or-TCP-Which-is-more-stable-pconnect-PushAll-Blog

My own testing confirmed the 50% on a virtualized environment (with redis-cli --intrinsic-latency 100). Also with the wp-config additions Till Krüss's Object Cache connected wonderfully with redis over the socket, without testing I would not have made the suggestion. I did not do a long turn test though, but I do not expect any problems.

by Talented
The transparent hugepages issue is mentioned here: https://redis.io/topics/latency
by Expert

The TCP vs Sockets is an old discusion that always ends up in the same conclusion: "Under certain conditions one is better than the other"

I will consider it in the future, it's not a priority, also following this logic we will need to change the php-fpm connection too.

Seems like it's the same case for Transparent Hugepages, it's good for some things and bad for anothers.

by Talented

Regarding transparent hugepages people seem to be unanimous, it is not a question if it should be turned off:

Thanks for considering the sockets (of course you are right, in my virtualized case it showed good results, but they are microseconds after all...).

And you are right, according to this explanation a socket for both php-fpm and redis would make sense: https://stackoverflow.com/questions/42704763/what-are-the-differences-from-running-php-fpm-over-an-unix-socket-vs-a-tcp-ip-so

by Expert

Who'd know better than the redis people?

Couldn't agree more! The thing is that Webinoly is not a Redis server and we don't know what will be the impact on the whole web server. I'm just saying that we need to do a little more research before making a decision in this regard.

by Talented

Sounds good, once I find some time I'll try to run a site longer on sockets, both php-fpm and redis. But for now I will concentrate on other things. smiley

I am definitely turning off transparent hugepages on my host server, will let you know if there are any problems after some time.

by Expert

Just for the record and future references:

  • THP was implemented and released in v1.14.0, most cloud providers actually set this value to "never" by default, but we've implemented a double check, just to be sure.
  • Redis unix sockets won't be implemented.
Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

To report a bug, please create a new issue on GitHub or ask a question here with the bug tag.
Webinoly Support Paypal Donations

PayPal · GitHub Sponsors · Bitcoin

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.

...