Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#33753] implementation of Redis caching #3615

Closed
wants to merge 15 commits into from
Closed

[#33753] implementation of Redis caching #3615

wants to merge 15 commits into from

Conversation

hans2103
Copy link
Contributor

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33753&start=0

In PR #3397 user @andrewnester created the posibility for Redis Caching in Joomla. But it wasn't complete and there where some obsolete files included in the PR.
There for I've created a new pull request.

  • apply patch
  • go to Global Configuration >> System
  • notice cache handler "Redis" in the dropdown
  • select cache handler "Redis" and new config fields will appear
  • if needed apply config. (host, port and auth can vary at some hosting providers)
  • save configuration
  • refresh your website while keep an eye on the Redis monitor
  • if everything works well, you'll see that Redis caching will serve the website.

Credits to @andrewnester for the initial pull request. (forked from memcached)

{
if ((class_exists('Redis')) != true)
{
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this returns false because Redis doesn't exist then there's no fall backs and you're going to get all kind of PHP Errors I think

Also is there any reason why you don't call the isSupported method here instead of repeating this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just copying what Memcache(d) and @andrewnester did.
Will it return with all kind of PHP Errors if Redis doesn't exist?

Instead of repeating yourself it's better to call isSupported method again. Do you have a suggestion how to improve the code?

@andrewnester
Copy link

@hans2103 @wilsonge what about throwing RuntimeException in this case?

@wilsonge
Copy link
Contributor

Probably. Because when you initialise the class you then have to call isSupported before you do anything because you have no way of knowing what's going on. I'd do the isSupported check in the constructor before getting the connection - throw a RuntimeException if the class doesn't exist - meaning we can do a try/catch there. Then when you get the connection you can assume the class exists and don't need the duplicated check

@hans2103
Copy link
Contributor Author

please provide your code suggestion and I will aply the improvement.

@hans2103 hans2103 changed the title implementation of Redis caching [#33753] implementation of Redis caching May 31, 2014
changing self::isSupported into static::isSupported since the function is static
using throw will result in an non working Joomla site. 
using the error message people will still be able to use Joomla and change the config.
don't use Redis is Caching is not enabled in config.
@jissereitsma
Copy link
Contributor

Checked the code on my own hosting environment (CentOS, PHP 5.4, PECL extension for Redis, and ofcourse Redis service running) and it turns out fine. When Redis is installed by default on a clean Linux environment, authentication is disabled. Enabling authentication anyway in the Joomla! configuration (using this patch) gives a warning in the backend. Using a wrong IP or port-number also generates a warning.

Tested succesfully.

@javigomez
Copy link
Contributor

@mbabker could you review this one? just because I'm having some trouble to review right now https://twitter.com/hans2103/status/472858924497240065

@mbabker
Copy link
Contributor

mbabker commented May 31, 2014

If folks with Redis can try testing this, that's good enough for me. It'd be great if the code style issues could be cleaned up before merge, but we can fix it if need be too.

@Bakual
Copy link
Contributor

Bakual commented May 31, 2014

Goes into 3.4-dev I guess?

@zanardigit
Copy link

@test
Test successful: I can see pages being served by REDIS cache server.
Notes:

  • on Ubuntu I had to 1) install redis server (apt-get install redis-server) and 2) install redis PHP library via PECL (pecl install redis)

@yireo
Copy link

yireo commented May 31, 2014

Yes, 3.4-dev branch would be best because this is a complete new feature.

#codecompliance hmm, bummer. We are having too much beer here at jab14 and both @hans2103 as my own laptop here is lacking proper coding styles at this point. Let us know if it is an issue or not.

@mbabker
Copy link
Contributor

mbabker commented May 31, 2014

I can clean it up and merge it later tonight if it's tested well.

@hans2103
Copy link
Contributor Author

I succesfully tested it on byte.nl where Redis PECL is installed
Francesco (@zanardigit) succesully tested on his local Joomla where Redis PECL is installed
Jisse (@yireo) succesfully tested it on hist local Joomla where Redis PECL is installed
Hope this is well enough

mbabker pushed a commit that referenced this pull request Jun 1, 2014
@mbabker
Copy link
Contributor

mbabker commented Jun 1, 2014

Merged for 3.4 at 5a845d2

@huba80
Copy link

huba80 commented Nov 7, 2015

Hi,

It seems to me that this is the most relevant "forum" to seek some help. I have Redis 3.0.3 installed on my VPS and I use Joomla 3.4.5. I tried to test Redis cache with http://tools.pingdom.com/fpt/ (website performance testing). I ran test multiple times. The result was very disappointing. If I selected Redis cache in Joomla config my website loaded in 4-6 seconds. When I turned off Redis cache in Joomla config the website loaded in about 3.5 sec. The site loaded faster without Redis or when I turned Redis off. I opened a thread in Joomla.org but no-one seems to be able to give advice or investigate this issue further. Lets say for them it is easier to recommend another caching system than solve, investigate this issue. I have a managed VPS at knownhost. Im very satisfied with them but as Im not a developer, programer I don't know how to check Redis config or log files. Could anyone help me here please? I cant believe that Redis gives such a poor performance. Something must be wrong.

Many thanks

@yireo
Copy link

yireo commented Nov 7, 2015

Hi,

When you have such a delay, and you know that Redis is fast, the most logical conclusion is that your Joomla actually has no way to reach Redis with the current settings and hosting. Which settings are you using?

@huba80
Copy link

huba80 commented Nov 7, 2015

Thanks for your answer.

What you mean by which setting Im using? What settings of mine do you want to know?
I tried to ask Joomla community but it looks like Redis is far not popular. This is why Im here. Im happy to do anything to check if everything is set properly.
In global config I just chose Redis cache and that's it. Redis is installed on my VPS and I think it gives a great performance to my other site using Magento. This is why I think there must be some problem with Joomla but no-one can (or want) to help.

@yireo
Copy link

yireo commented Nov 8, 2015

As soon as you enable Redis, there are numerous settings appearing in your Joomla Global Configuration that need to be configured: Redis Server Host, Redis Server Port, Redis Database. What did you enter there? These details need to match the details of your Redis service.

You mentioned you "installed" Redis. Do you also mean that you actually configured Redis on your server to run as a service? Is Redis running? If so, you must know the port and database.

@huba80
Copy link

huba80 commented Nov 8, 2015

Well...where to start.... As I mentioned earlier I have a managed VPS. The reason to be "managed" that Im just a simple website owner who has a busy website so I had to find a VPS. It is managed because "I don't know things". I don't know how to setup a VPS or install a program on VPS etc...
I asked my hosting provider to install Redis on my VPS. They did it but it wasn't easy. First off they asked me for Redis installation guide as they don't support 3rd party extensions. So They installed it on my VPS. As soon as it has been installed Redis option showed up in Joomla global config. Redis server host was automatically filled as "localhost" just as the port which is 6379. No other config has been added. Authentication (empty), Database (number zero). This is all my Joomla config. As far as I read online this config should be ok.
What Im not so sure about that is how Redis is configured on my VPS.
My hosting provider is not willing to dig into the problem because it is still a 3rd party extension which they don't support.
On Joomla forum no-one can help and they send me back to Redis. I wrote in Redis forum here:
https://www.reddit.com/r/redis/comments/3rk6ak/redis_303_with_joomla_345/
They send me back to ask Joomla. Everyone points at each other and no-one can really help.
I understand there is a documentation on Redis website but there are commands that I don't have a single clue of. So far that I could find out:

I run 2 commands in WHM.
The first is: redis-cli ping
Answer was: PONG
The second was:
redis-cli --latency -h host -p port
The answer was:
[root /]# redis-cli --latency -h host -p port Could not connect to Redis at -p:6379: Name or service not known [root /]#
I have also tried:
$ redis-cli
redis 127.0.0.1:6379> ping
Answer was:
[root /]# $ redis-cli redis 127.0.0.1:6379> ping [root /]#
Im not sure if I was doing everything right. Is this what I should have seen there?
Im on:
CENTOS 6.7 i686 virtuozzo – host WHM 11.52.0

I've also find a guide here:

http://www.varunpant.com/posts/how-to-set-up-redis-in-ubuntu-linux

There they say the redis.conf file should look similar to this:

daemonize yes
pidfile /var/run/redis.pid
logfile /var/log/redis.log
port 6379
bind 127.0.0.1
timeout 300
loglevel notice
##Default configuration options
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename dump.rdb
dir /tmp/redis/
appendonly no
glueoutputbuf yes

I checked my redis.conf file and there is not even port setting. Full of text but not much configuration.

I have concerns about Redis configuration file but Im unable to attach here.

@yireo
Copy link

yireo commented Nov 8, 2015

The questions you are asking about Redis are actually not related to Joomla at all. The "redis-cli" output shows that your server is not running Redis as a service. You might have a PHP support for Redis clients, but if there is no Redis server available, it is like having PHP MySQL support without having a MySQL database server. Your hosting provider should provide you with Redis as a running service, or otherwise the work they have done now is pointless. If they are missing out on that point entirely, I recommend you switch hoster or hire somebody to setup the hosting for you, because Redis requires a system administrator to be setup. I don't think we can discuss this any further in this GitHub thread, because the issues you are having are not related to Joomla and/or the Redis support in Joomla that is offered here in this Pull Request. It is related to your server actually still not supporting Redis as a service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet