PDA

View Full Version : memcached - definetly worth it for high load servers.


ekool
Tue 22nd Aug '06, 3:37pm
We've been running into the typical mysql problems like most sites of relative size. They run good 90% of the time, but when that big query hits and the table gets locked, all hell breaks loose and the entire site basicly gets shut down and has to wait... which usually spirals the httpd processes out of control or locks users out, etc.

We get memcached running yesterday and it has made a HUGE difference on the mysql server. memcached seems to be handeling the majority of the small requests, so even when a large query comes in, only a few requests back up and the site remains relatively responsive.

I can post a howto if anyone is interested, but if you are running into issues, memcached is DEFINETLY worth getting up and running since it is relatively painless.

Zachery
Tue 22nd Aug '06, 3:49pm
How exactly are you making use of memcached?

ekool
Tue 22nd Aug '06, 3:53pm
How exactly are you making use of memcached?

We have installed memcached on our mysql server (we have 2 apache servers for the front end) and have enabled memcached in the config.php file -- I ran the memcached in debug mode and watched the requests fly by. The load on the mysql server is much lower (even tho its running both mysql and memcached) and the site is much more responsive.

Using mtop, the number of requests that fly by the screen (and get locked out on table lock) are very few now.

riverdale
Fri 13th Oct '06, 5:59pm
We've been running into the typical mysql problems like most sites of relative size. They run good 90% of the time, but when that big query hits and the table gets locked, all hell breaks loose and the entire site basicly gets shut down and has to wait... which usually spirals the httpd processes out of control or locks users out, etc.

We get memcached running yesterday and it has made a HUGE difference on the mysql server. memcached seems to be handeling the majority of the small requests, so even when a large query comes in, only a few requests back up and the site remains relatively responsive.

I can post a howto if anyone is interested, but if you are running into issues, memcached is DEFINETLY worth getting up and running since it is relatively painless.

A how to for this will sure be useful, many folks have more visitors than money to pay for servers :)

ekool
Sun 15th Oct '06, 10:32pm
A how to for this will sure be useful, many folks have more visitors than money to pay for servers :)
Welp, I'm not sure there is really enough info for a howto. Memcached is a snap to install, there's only a few command line options to configure. Once you set that up, all you have to do is put a bit of info into the vb config.php file and its done.

lafsunlmtd
Mon 16th Oct '06, 3:59am
what would we put into the config.php file?

ekool
Mon 16th Oct '06, 2:41pm
// vB_Datastore_Memcached - for using a Memcache server
$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$config['Misc']['memcacheserver'] = 'INSERTIPHERE';
$config['Misc']['memcacheport'] = '11211';

Hastin
Mon 16th Oct '06, 3:31pm
Just curious, do you run this on your main server, or a different server?

Also, how does one install it, or do you just drop and run the daemon?

ekool
Tue 17th Oct '06, 4:06am
Just curious, do you run this on your main server, or a different server?

Also, how does one install it, or do you just drop and run the daemon?
I run it on my dedicated mysql server.

kerplunk
Tue 17th Oct '06, 3:24pm
I can't imagine why anyone would run memcached on their database server. Database servers need all of the RAM they can get. ;) I suggest investing in multiple web servers (if not done so already) with 2GB of RAM and allocation 1GB to memcached on each. Many large websites using memcaching do it that way. (i.e. Wikipedia)

ekool
Tue 17th Oct '06, 3:31pm
I can't imagine why anyone would run memcached on their database server. Database servers need all of the RAM they can get. ;) I suggest investing in multiple web servers (if not done so already) with 2GB of RAM and allocation 1GB to memcached on each. Many large websites using memcaching do it that way. (i.e. Wikipedia)
Then obviously you havent tried it.

I have a dedicated mysql server that was locking and causing delayed responses/queries, etc. The system had enough power to handle it, but the table locking issue proved to be the major bottleneck.

Having a ton of extra memory is only going to buy you so much leeway, when the disk, ultimately, is going to be your bottleneck. Short of loading the DB into memory entirely (and heaven forbid, have a crash/power outage) -- there is no way to fix this.

However, running memcached -- even on the same box -- keeps so many requests out of the database, that it doesnt get touched nearly as often. In addition, the memcached server is much more optimized then mysql for storing the small datastore objects that you are using it for. You dont have a ton of overhead for database type operations that are unecessary for this type of data.

I'll finish with this...

"In theory there is no difference between theory and practice. But, in practice, there is."

—Jan L.A. van de Snepscheut

Why dont you give it a try, and see for yourself. Sure, having a dedicated machine is better then not having one. But you have real expense there.. putting it on the same box makes a HUGE difference and costs nothing.

Just my 2c.

kerplunk
Tue 17th Oct '06, 3:41pm
What are you talking about? We have multiple memcached servers running and I have a lot of experience with memcaching. I don't understand what you are saying?

I think you need to re-read my post. Memcache is a great tool and is necessary for larger websites.

ekool
Tue 17th Oct '06, 4:46pm
What are you talking about? We have multiple memcached servers running and I have a lot of experience with memcaching. I don't understand what you are saying?

I think you need to re-read my post. Memcache is a great tool and is necessary for larger websites.
There is absolutely nothing wrong with running memcached on the same server you use for mysql. Some people cant afford to buy a seperate server just for memcached. Installing it on the mysql server works just fine and provides a large speed increase.

My apache servers far exceed the load of my mysql server. I would never put it on one of those.

kerplunk
Tue 17th Oct '06, 7:02pm
First of all, I never said to buy a separate server dedicated to memcached. It isn't economical to do so. I suggested adding web servers (which you, personally, should think about doing) and running memcached with the extra memory.

Secondly, things like this are obviously case-by-case. Your setup is different from mine, and mine is different from someone else's. I was just sharing with everyone what is normally done. Normally, the database server needs all of the server resources it can get. Web servers are a dime a dozen.

eva2000
Wed 18th Oct '06, 3:11am
I can't imagine why anyone would run memcached on their database server. Database servers need all of the RAM they can get. ;) I suggest investing in multiple web servers (if not done so already) with 2GB of RAM and allocation 1GB to memcached on each. Many large websites using memcaching do it that way. (i.e. Wikipedia)
Only reason i can see is memory will always be faster than hard drives for reading and writing data from/to :) Table locking in MySQL will always exist, just a matter of how fast you can get through those LOCKs :)

kerplunk
Wed 18th Oct '06, 5:14am
Hey George :)

I'm not sure if we are talking about the same thing here, but I just wanted to point out to everyone about "memory being faster than hard drives" that Memcached uses its own protocol. There is absolutely no hard disk drive access for memcaching. Obviously MySQL data is stored on the hard disk, but if we are talking about putting memcached on the database server versus on a server that isn't the database server, there will be no slow down. The only bottleneck would be the network and if you have a private network (preferrably gigabit) there should be no difference.

Anyway, I don't even know what we are talking about now... for anyone reading this, just know that memcaching is DEFINITELY something I would recommend. It is great. We use it for everything from handling our PHP sessions to caching the entire homepage of our site.

eva2000
Thu 19th Oct '06, 4:21am
Yeah i guess only real requirement is enough physically installed memory available for the task :)

KrON
Fri 20th Oct '06, 1:02am
I can't imagine why anyone would run memcached on their database server. Database servers need all of the RAM they can get. ;) I suggest investing in multiple web servers (if not done so already) with 2GB of RAM and allocation 1GB to memcached on each. Many large websites using memcaching do it that way. (i.e. Wikipedia)

I have a couple issues/questions with this post.

1) Why are you suggesting he use multiple instances of memcache? AFAIK, Jelsoft's memcache implimentation is limited in that it is not capable of keeping multiple memcache instances in sync.. If your vB config was set to "localhost", and someone did something on webserver 1 that would trigger an update of the datastore, then that server running that php code would trigger the update of the datastore on its local memcached instance, and the other servers would be SOL, handing out out of date info until they freshened their datastore from the master db.

2) 1GB of memory each instance? This is totally wasteful given what Jelsoft is currently using memcache for. Unless you have hacked your vb to store stuff like the postparsed table, sessions, or even post text, you can get by with the default memcached setting of 64mb, as there really is not much data at all being stored in memcache.

We've been using memcached for a long time now, on a site that gets a TON of traffic, and haven't ever really needed to go above 64mb for our solitary memcache server, and we're hacked to store a lot of other info in there aside from just the datastore.

kerplunk
Fri 20th Oct '06, 1:51am
I have a couple issues/questions with this post.

1) Why are you suggesting he use multiple instances of memcache? AFAIK, Jelsoft's memcache implimentation is limited in that it is not capable of keeping multiple memcache instances in sync.. If your vB config was set to "localhost", and someone did something on webserver 1 that would trigger an update of the datastore, then that server running that php code would trigger the update of the datastore on its local memcached instance, and the other servers would be SOL, handing out out of date info until they freshened their datastore from the master db.

2) 1GB of memory each instance? This is totally wasteful given what Jelsoft is currently using memcache for. Unless you have hacked your vb to store stuff like the postparsed table, sessions, or even post text, you can get by with the default memcached setting of 64mb, as there really is not much data at all being stored in memcache.

We've been using memcached for a long time now, on a site that gets a TON of traffic, and haven't ever really needed to go above 64mb for our solitary memcache server, and we're hacked to store a lot of other info in there aside from just the datastore.
I guess I was thinking about our own setup where we use multiple memcache servers for many things things besides vBulletin. For our non-vB stuff, it is nice to have multiple memcache servers because if one server is taken down, our code will automatically use the other servers.

If we are talking about vBulletin specifically, then no, you probably are not going to need a gig of storage for the caching of the mem ;)

KrON
Fri 20th Oct '06, 12:16pm
I would love for vB's memcache class to get fleshed out a little to support failover and multiple memcache servers as well. Currently it is "dumb" in the sense that it just checks for the presence of a key, and if that key is not there fetches it. That's why using multiple caches with vB is a bad idea as it is very easy for that data to get stale, and when it comes to the datastore that is a real PITA to troubleshoot :)

ekool
Fri 20th Oct '06, 3:10pm
Not to mention that in the event that your memcached server goes down, your entire site will be unavailable. Fallback to another memcached server would be good, or at the very least back to mysql.

Hopefully in a new version.

telc
Fri 20th Oct '06, 3:42pm
I would like to try out the datastore caching on a large forum. Is there any risk in enabling it, like unrecoverable corruption of the datastore. Or would I simple be able to disable the datastore caching at any time and go back to the old way of using the database as the datastore?

Also what of query hits would I save on, by having datastore caching enabled?
Is the datastore table accessed with each page load, if caching is disabled?

kerplunk
Fri 20th Oct '06, 4:52pm
Not to mention that in the event that your memcached server goes down, your entire site will be unavailable. Fallback to another memcached server would be good, or at the very least back to mysql.

Hopefully in a new version.
I am pretty sure I heard one of the vB developers say that with 3.6, if you are using datastore cache, then if the memcached server is unavailable, it will automatically just rely on the database as usual so there will be no downtime. Still, support for multiple memcached servers would be great. I'd also like to see vBulletin allow you to store PHP sessions in memcached rather than the database.


KrON, I see that memcached 1.2 was released recently. Have you been using this? Noticed any issues? I think I'm using 1.1.12...

jw00dy
Fri 20th Oct '06, 7:27pm
// vB_Datastore_Memcached - for using a Memcache server
$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$config['Misc']['memcacheserver'] = 'INSERTIPHERE';
$config['Misc']['memcacheport'] = '11211';
So this is the install or the config I guess?

What is the name of the program, so I can download it with Yum. Or am I missing the boat on how this works/installs?

Also, would this conflict with any PHP accelerators?

Oh, and don't forget to open up 11211 on your firewall if you haven't.

jw00dy
Fri 20th Oct '06, 7:29pm
Also, I'm running mysql and vB on the same server, would this still be okay to add? I've got 10,000+ users, and so far it's been pretty peppy, but sometimes it slows almost to a halt for some reason, which me believes to be related to large searches.

gray_ru
Fri 20th Oct '06, 8:04pm
Also, I'm running mysql and vB on the same server, would this still be okay to add? I've got 10,000+ users, and so far it's been pretty peppy, but sometimes it slows almost to a halt for some reason, which me believes to be related to large searches.

I have the same config and completely satisfied with memcached. It decreases total number of queries in mysql, saves a lot of CPU and adds stability. And it took about 20 minutes to deploy.

I have a couple issues/questions with this post.

2) 1GB of memory each instance? This is totally wasteful given what Jelsoft is currently using memcache for. Unless you have hacked your vb to store stuff like the postparsed table, sessions, or even post text, you can get by with the default memcached setting of 64mb, as there really is not much data at all being stored in memcache.

We've been using memcached for a long time now, on a site that gets a TON of traffic, and haven't ever really needed to go above 64mb for our solitary memcache server, and we're hacked to store a lot of other info in there aside from just the datastore.


Do you mind to share these hacks? All these sessions queries usually top my slow-query.log and I think that caching these will noticeably improve the performance.

KrON
Sat 21st Oct '06, 12:41am
I am pretty sure I heard one of the vB developers say that with 3.6, if you are using datastore cache, then if the memcached server is unavailable, it will automatically just rely on the database as usual so there will be no downtime. Still, support for multiple memcached servers would be great. I'd also like to see vBulletin allow you to store PHP sessions in memcached rather than the database.


KrON, I see that memcached 1.2 was released recently. Have you been using this? Noticed any issues? I think I'm using 1.1.12...

We're running 1.2.0 w/o issue. The release notes claim it is like 40% faster, but to be honest I haven't really noticed a difference..

jw00dy
Sat 21st Oct '06, 3:40am
I have the same config and completely satisfied with memcached. It decreases total number of queries in mysql, saves a lot of CPU and adds stability. And it took about 20 minutes to deploy.
Are you by chance running APC as well? Wonder if the two will work together or not.

How exactly is this configured? I uncommented the stuff in config.php, but that doesn't seem to work as vB just says it's not installed.

After reading a ton of stuff, I've come to the conclusion that I need libevent (dependency of memcached) memcached & memcache (they are different).

I've installed all three (via source).

I added extension = memcache.so to php.ini, restarted apache then enabled the memcache stuff in config.php, and it does not work. I get that it's not installed.

What am I doing wrong here. I'll be honest, I'm grasping at straws here as theirs just not enough solid information on how this actually is supposed to work from a setup/install standpoint.

Assistance is GREATLY appreciated.

gray_ru
Sat 21st Oct '06, 4:02am
Are you by chance running APC as well? Wonder if the two will work together or not.

How exactly is this configured? I uncommented the stuff in config.php, but that doesn't seem to work as vB just says it's not installed.

After reading a ton of stuff, I've come to the conclusion that I need libevent (dependency of memcached) memcached & memcache (they are different).

I've installed all three (via source).

I added extension = memcache.so to php.ini, restarted apache then enabled the memcache stuff in config.php, and it does not work. I get that it's not installed.

What am I doing wrong here. I'll be honest, I'm grasping at straws here as theirs just not enough solid information on how this actually is supposed to work from a setup/install standpoint.

Assistance is GREATLY appreciated.
You have to start memcached daemon. It can be done in shell typing something like this:
./memcached -d -m 64 -l 127.0.0.3 -p 11211
It will start memcached with 64 Mb of memory and will listen port 11211 on 127.0.0.3. Then add these parameters to config.php.

kerplunk
Sat 21st Oct '06, 5:28am
I have a big noob when it comes to startup scripts. I always have been. I don't really understand chkconfig or anything like that.

Does anyone (KrON) know how to make it so memcached automatically starts... i.e.

/etc/rc.d/init.d/memcached start

? :)

I could use this, but I don't know how to activate it with chkconfig... http://www.dev411.com/wiki/Memcached_startup_files_for_Red_Hat_(RHEL)

gray_ru
Sat 21st Oct '06, 5:57am
It is pretty easy in FreeBSD - just add to /etc/rc.conf something like this:
memcached_enable=YES
memcached_flags='PUT_HERE_ALL_FLAGS_FOR_DAEMON' but it is valid for ports installation, it creates /etc/rc.d/memcached.sh itself during installation.

jw00dy
Sat 21st Oct '06, 6:37am
I have a big noob when it comes to startup scripts. I always have been. I don't really understand chkconfig or anything like that.

Does anyone (KrON) know how to make it so memcached automatically starts... i.e.

/etc/rc.d/init.d/memcached start

? :)

I could use this, but I don't know how to activate it with chkconfig... http://www.dev411.com/wiki/Memcached_startup_files_for_Red_Hat_(RHEL (http://www.dev411.com/wiki/Memcached_startup_files_for_Red_Hat_%28RHEL))
Yep,
# chkconfig memcached on

However, usually their needs to be a startup script already in place, and I don't believe memcached has one.

jw00dy
Sat 21st Oct '06, 8:05am
You have to start memcached daemon. It can be done in shell typing something like this:
./memcached -d -m 64 -l 127.0.0.3 -p 11211It will start memcached with 64 Mb of memory and will listen port 11211 on 127.0.0.3. Then add these parameters to config.php.
Thank you! Worked like a charm.

I'm trying to find any information the parameters that you would use in /etc/memcached.conf so that the script posted by kerpluk can be used to start and stop etc the service.

I've got all the other stuff done.

Once it's done I'll document the entire process. U

jw00dy
Sat 21st Oct '06, 8:06am
I have a big noob when it comes to startup scripts. I always have been. I don't really understand chkconfig or anything like that.

Does anyone (KrON) know how to make it so memcached automatically starts... i.e.

/etc/rc.d/init.d/memcached start

? :)

I could use this, but I don't know how to activate it with chkconfig... http://www.dev411.com/wiki/Memcached_startup_files_for_Red_Hat_(RHEL (http://www.dev411.com/wiki/Memcached_startup_files_for_Red_Hat_%28RHEL))
Working on this for you, so I can tell you exactly what to do. Just need to know what to put in the memcached.conf file so it starts with the correct parameters that we want it to.

KrON
Sat 21st Oct '06, 12:37pm
If you have an init script in /etc/init.d/, just:

cd /etc/init.d/
/sbin/chkconfig --add memcached

That will add it to your runlevels so it will start next reboot.

kerplunk
Sat 21st Oct '06, 11:53pm
It says "chkconfig: - 80 12" in that init.d startup file...

Is that relevant to anything? On some things I remember seeing something like this on our other startup scripts:

on off on on on off



Also, what is inside memcached.conf? What is an example one? I can't find any examples anywhere...

jw00dy
Sun 22nd Oct '06, 1:27am
that is exactly the problem I'm having.

I did find what I believe to be the variables, which I'll post after testing them to see if they work or not. I'd hate to cause issues for someone if I posted bad info.

However, I'm having some trouble. For some reason (and this worked 1 time yesterday) memcached won't start for me. I'm getting:
/usr/local/bin/memcached: error while loading shared libraries: libevent-1.2.so.1: cannot open shared object file: No such file or directory[/QUOTE
when I try to start memcached again.

My startup script as it stands right now is: # /usr/local/bin/memcached -u nobody -d -m 64 -l 127.0.0.3 -p 11211

I have libevent installed (via source), and it shows libevent-1.2.so.1 in /usr/local/lib/

When I configured the source for memcached I did:
[QUOTE]# ./configure --with-libevent=/usr/local/lib/libevent-1.2.so.1
# make
# make install
But it's not working. I know I'm missing something dumb here, but that should have worked me thinks. As it did the first time I tried it after installing.

I'm thinking something might have gotten corrupt or something, because this is just odd to say the least.

I'm going to smoke it all and try again and see what happens.

If anyone see's something I did wrong, please let me know.

jw00dy
Sun 22nd Oct '06, 1:30am
If you have an init script in /etc/init.d/, just:

cd /etc/init.d/
/sbin/chkconfig --add memcached

That will add it to your runlevels so it will start next reboot.
once you run "chkconfig --add memcached" I needed to run "chkconfig memcached on" so it turns it on based off the information in the memcached_init file posted by kerplunk.

I'll post the complete process once I get this working. Not that you don't know how to do this, just for the noob like me that hadn't done it before, and could use some clear steps, which don't appear to exist at this point.

Oh, and for the record, I'm on CentOS 3.x w/apache 1.3.37 (or whatever the latest is), w/php 4.4.4, w/apc 3.0.12p2

jw00dy
Sun 22nd Oct '06, 4:49am
USE AT YOUR OWN RISK!! I WILL TAKE NO RESPONSIBILITY IF YOU BREAK SOMETHING

Ok, here's my how to. Note this is all based on an install on a single server with the following installed.


Apache 1.3.37
PHP 4.4.4
MySQL 4.1.21
APC 3.0.12p2
Running on a CentOS 3.x server (latest kernel available via Yum)Let me first say that I noticed a speed increase immediately after this was installed and configured.
Download all src packages needed for the install. At the time of this writing, current versions are memcache-2.1.0, memcached-1.2.0, & libevent-1.2
# wget http://pecl.php.net/get/memcache-2.1.0.tgz
# wget http://danga.com/memcached/dist/memcached-1.2.0.tar.gz
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz (http://www.monkey.org/%7Eprovos/libevent-1.2.tar.gz)
We'll start with libevent because it is a dependency of memcached.
Extract Files: # tar xvfz libevent-1.2.tar.gz
Install libevent
# cd libevent-1.2
# ./configure && make
# make install
Take note of where libevent is installed.
In my installation is ended up --> /usr/local/lib/libevent-1.2.so.1
libevent installation complete.
Next we'll install memcached.
Extract files: # tar xvfz memcached-1.2.0.tar.gz
# cd memcached-1.2.0
# ./configure --with-libevent=/usr/local/lib/libevent-1.2.so.1

Let me say even though I did this option, it didn't seem to work on my server. I had to do some linking to make it work, which I'll outline just in case yours doesn't work like mine.
# make
# make install
Memcached installation complete.
Now we'll install memcache
Extract Files: # tar xvfz memcache-2.1.0.tar.gz
# cd memcache-2.1.0 (make sure it's memcache and NOT memcached)
# phpize
# ./configure && make
# make install
Take note of the php extensions directory that memcache is installed in.
Mine is: /usr/local/lib/php/extensions/no-debug-non-zts-20020429
That's it. Your done installing.
Now we need to test it and see if it works.
# /usr/local/bin/memcached -u nobody -d -m 64 -l 127.0.0.3 -p 11211
This is the config I like, so feel free to use different options.
-u nobody: The user that the daemon will run as
-d: ??? Maybe run as daemon?
-m 64: memory 64mb
-l 127.0.0.3: (note that's a lowercase L) Listen IP address
-p 11211: listen port (default)
Ok, so hopefully this worked.
If it did not, and you get an error when trying to start memcached that says that it basically can't find libevent-1.2.so.1 then you'll need to do the following to fix it. Exact Error I got was:
memcached: error while loading shared libraries:
libevent-1.2.so.1:cannot open shared object file: No such file or directory
Run the following command to see where memcached is looking for it's libs.
# LD_DEBUG=libs memcached -v
Now you should have taken note of the libevent in section 4 and you will need to compare that location with the different locations that it lists.
The one I chose to use was "trying file=/usr/lib/libevent-1.2.so.1"
Now we can assume that the file doesn't exist in that location since we are getting an error that says it doesn't. So we'll create a link from the actual file in the location I've chosen that it's looking in.
ln -s /usr/local/lib/libevent-1.2.so.1 /usr/lib/libevent-1.2.so.1
Done, now we need to test again.
# /usr/local/bin/memcached -u nobody -d -m 64 -l 127.0.0.3 -p 11211
This time is should have worked. And if you run the ps -xx command of your choice you should see it listed.
Now, I spent a considerable amount of time trying to get the startup script that kerpluk posted links to, but did not have any luck. The failed portion of it relates to the start-memcached script. And I don't know enough about scripting to know how to work around the problem. So I just cheated and added the startup commands to rc.local.
Edit /etc/rc.local with your editor or choice.
Add the following lines (or your version of it) to the bottom of the file.
## Start Memcached
/usr/local/bin/memcached -u nobody -d -m 64 -l 127.0.0.3 -p 11211
Now it will automatically start when you reboot your server.
Ok, now we need to add memcache to PHP as an extension.
Open your phpinfo file from ACP in vB and find the location of php.ini.
Once you have the location, edit the file and add/verify the following:
find "extension_dir =" and make sure it's set to your php extensions directory.
Mine has: extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429"
Which is correct based off the information we took note of in the last step of section 8. If it's not, then you have two options, you can either make it so it has the directory that you obtained during the install of memcache or add it to the extension line that we'll add to php.ini.
IF you chose to add the extension directory to extension_dir or if it was already correct (mine was from previously installing APC), then add the following somewhere in the section that has all the extensions.
;
; memcache Section
;

extension = memcache.so
memcache.allow_failover = 0
OR if extension_dir doesn't point to the correct location you can add it this way:
;
; memcache Section
;

extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429/memcache.so"
memcache.allow_failover = 0
Either one will work just fine.
Save the file, and restart apache
# service httpd restart
If all goes well, then we're ready to enable the options in vB's config.php file.
# cd /your/path/to/forums/includes
Edit config.php
find these three lines:
//$config['Datastore']['class'] = 'vB_Datastore_Memcached';
//$config['Misc']['memcacheserver'] = '127.0.0.1';
//$config['Misc']['memcacheport'] = '11211';
uncomment the lines by removing the preceeding two /'s (//)
Then edit the second 2 lines so that it matches your configuration that you set when you started memcached.
When it's done it should look something like this:
$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$config['Misc']['memcacheserver'] = '127.0.0.3';
$config['Misc']['memcacheport'] = '11211';
Save and exit and your done.
Now all you need to do is make sure you forums are still online and that you aren't getting any errors.I hope that helps. If someone has any suggestions etc, please feel free to share. I am NOT a guru at this. I'm just posting information that I had to dig for hours to figure out, and wanted to help the next guy.

kerplunk
Sun 22nd Oct '06, 6:30pm
Thank you for the response, jw00dy, but I have tried starting memcached before with /etc/rc.local and it does not work. Memcached cannot be started as "root" and I suspect this is the problem.

Questions remaining to be answered:

- What goes in memcached.conf? What is an example memcached.conf?
- What is the absolute proper way to use a memcached startup script?

jw00dy
Sun 22nd Oct '06, 9:56pm
Exactly, which is why you use the -u option followed by the user you want to start/run memcached.

-u nobody

digitalpoint
Sun 22nd Oct '06, 10:01pm
I would love for vB's memcache class to get fleshed out a little to support failover and multiple memcache servers as well. Currently it is "dumb" in the sense that it just checks for the presence of a key, and if that key is not there fetches it. That's why using multiple caches with vB is a bad idea as it is very easy for that data to get stale, and when it comes to the datastore that is a real PITA to troubleshoot :)

Not to mention that in the event that your memcached server goes down, your entire site will be unavailable. Fallback to another memcached server would be good, or at the very least back to mysql.

Hopefully in a new version.Agreed! It would be so easy too (see this thread)... :)

We are currently using 4 memcached serrvers (I use it for lots of stuff outside of vBulletin) with the automatic failover/pooling stuff.

Would just be nice to be able to utilize the pooling/failover with vBulletin without having to hack on the PHP files each upgrade.

kerplunk
Mon 23rd Oct '06, 5:58am
Exactly, which is why you use the -u option followed by the user you want to start/run memcached.
Ah ha! :)

Thank you very much, jw00dy!

jw00dy
Mon 23rd Oct '06, 11:54am
You are welcome ;)

hydn
Tue 24th Oct '06, 4:28am
Where can win32 users find an all in one memcache how 2?

fotografik
Tue 24th Oct '06, 6:09am
8. Now we'll install memcache

Extract Files: # tar xvfz memcache-2.1.0.tar.gz
# cd memcache-2.1.0 (make sure it's memcache and NOT memcached)
# ./configure && make
# make install
Take note of the php extensions directory that memcache is installed in.
Mine is: /usr/local/lib/php/extensions/no-debug-non-zts-20020429
That's it. Your done installing.Need help at this stage.

The package that I downloaded (as per the pecl link above) only contains the following files after decompressing.

config.m4
config.w32
CREDITS
example.php
memcache.c
memcache.dsp
php_memcache.h
README

Am a total newb at installing this (but managed to install the libevent and memcached) so would appreciate any/all help. Thanks in advance.

jw00dy
Tue 24th Oct '06, 8:30am
Ahh crap, I left that part out, sorry about that. I've fixed my original.

Run phpize first, then you'll have all the other stuff.

# cd memcache-2.1.0 (make sure it's memcache and NOT memcached)
# phpize
# ./configure && make
# make install

jw00dy
Tue 24th Oct '06, 5:39pm
Where can win32 users find an all in one memcache how 2?
Sorry I can't help you due to not running win :(

However, I imagine that it can't be much different, but I have no idea to be honest.

fotografik
Wed 25th Oct '06, 12:23pm
Ahh crap, I left that part out, sorry about that. I've fixed my original.

Run phpize first, then you'll have all the other stuff.
# cd memcache-2.1.0 (make sure it's memcache and NOT memcached)
# phpize
# ./configure && make
# make installThanks for the update. Which leads me to my next question - apparently phpize is not installed on our servers, so how would I go about installing memcache without the phpize step?

Installing the devel-php version (which would then also install phpize) sounds a wee bit dangerous on production servers (sorry, like I said, i am a total n00b at this, having to take over our previous sysadmin's role).

jw00dy
Wed 25th Oct '06, 1:26pm
you should be just fine to install php-devel, as it doesn't mess with your actual php, it just gives you the development tools for php. At least that's how I understand it.

Now, as far as I know, without phpize, you are stuck.

At least I know of no way to do it without it.

fotografik
Thu 26th Oct '06, 12:38pm
you should be just fine to install php-devel, as it doesn't mess with your actual php, it just gives you the development tools for php. At least that's how I understand it.

Now, as far as I know, without phpize, you are stuck.

At least I know of no way to do it without it.After a bit of googling, found that phpize is available without installing php-devel, just have to point to it, thus after a bit of rooting around directories, found the phpize command at /usr/local/bin/php5/bin/phpize (your location might be different).

Now onwards to complete the rest of the steps. :D

jw00dy
Thu 26th Oct '06, 2:14pm
Great to hear!

fotografik
Thu 26th Oct '06, 10:17pm
Reporting back that libevent, memcached and memcache have been installed and working fine (or at least hasn't crashed our forums :p thus assume that they are working fine).

What was not entirely clear was on where the individual components are installed so this is how our forums are configured and where the components are run :-

SQL Server
-> libevent
-> memcached

Web Server
-> memcache

The components were installed/activated after our peak period (10pm-1am nightly), thus we would have to wait until tonight's peak to monitor if performance has been boosted with this change.

Optimistic that it has, it is usually during this peak period when one or two slow queries cause Web server processes and load to spiral out of control (usually recovers in 5-10 minutes but on occasions have needed to manually restart server and processes).

Thanks to jwoody (and Google - Google is my best friend now) for the tips and help here.

jw00dy
Fri 27th Oct '06, 12:52am
That's great news. Let me know how it all turns out. I wish their was a way to see the stats for memcache/memcached, and I'm sure their is, but at this point, I don't know what it is. But it would be great to see the stats for it.

digitalpoint
Fri 27th Oct '06, 6:17pm
I wish their was a way to see the stats for memcache/memcachedHere's a vBulletin plug-in that does it for you... Even does a basic latency test on your memcached server(s). Can of course easily be adapted for a single memcached server (see this post). :)

http://img116.imageshack.us/img116/9848/memcachese2.png

KrON
Fri 27th Oct '06, 6:23pm
Sweet, I've got it installed (and deactivated) until we switch over to loadbalanced memcache servers (should happen in the next day or so, I've got it setup, just fixing some other stuff) :)

jw00dy
Fri 27th Oct '06, 6:59pm
Thanks Digitalpoint. That will come in very handy :)

fotografik
Sat 28th Oct '06, 12:36pm
Thanks Digitalpoint. That will come in very handy :)Hi,
Could you share the hack that digitalpoint did to show stats for a single memcached server?

Thanks in advance.

digitalpoint
Sat 28th Oct '06, 4:17pm
See this post.

fotografik
Sun 29th Oct '06, 2:30am
See this post.I did. I installed the xml as posted by you but I get errors similiar to Kron and the table is empty.

Was wondering if there were any changes to be made for a single memcached server settings.

jw00dy
Sun 29th Oct '06, 2:58am
did, dp, get you squared away? If he's okay with it, I can send you my fixed (with his help) version.

digitalpoint
Sun 29th Oct '06, 3:15am
Fine with me... I've made a couple minor cosmetic additions to mine (like show stuff in GB, MB, or k as necessary), but nothing beyond that.

fotografik
Mon 30th Oct '06, 12:52am
checking phpinfo() in AdminCP gets me this (as per attached screencap).

Just wondering if my install is *really* utilising the memcache and memcached extensions, while waiting to install the stats plugin.

jw00dy
Mon 30th Oct '06, 1:21am
Here is the version for a single server.

digitalpoint, it would be great if you don't mind sharing your fixes for the GB/MB etc, that would be great to see that in that format vs what they are now.

fotografik
Mon 30th Oct '06, 6:04am
Here is the version for a single server.

digitalpoint, it would be great if you don't mind sharing your fixes for the GB/MB etc, that would be great to see that in that format vs what they are now.Thanks a bunch. Works perfectly.

fotografik
Mon 30th Oct '06, 6:10am
Thanks to jwoody and digitalpoint for their code. Here is a screencap of my stats.

jw00dy
Mon 30th Oct '06, 1:52pm
Not bad. Looks like you have what I have. Way more memory allocated then it probably needs. :)

Thanks again digitalpoint. I look at this thing all the time.

KrON
Mon 30th Oct '06, 1:57pm
Just in case anyone was curious, a pic of our stats for the past day or two.

jw00dy
Mon 30th Oct '06, 2:03pm
Pretty cool.

I'm starting to think the part that says "mb used" is actually a percentage. So if it says .03 it's 3% or if it says .47 then it's 47%. Thoughts?

digitalpoint
Mon 30th Oct '06, 2:38pm
MB Used really is MB used... it's not a percentage. vBulletin doesn't use much memory for the datastore (for example, my datastore table in the DB is only 212.7k).

Anyway, here's the plug-in I'm using (just formatting the bytes/MB better). I didn't put it as an XML plug-in because for whatever reason it seems to not work that way for some users. {shrug}:

$memcache = new Memcache;
foreach ($vbulletin->config['Misc']['memcacheserver'] as $key => $server) {
$memcache->addServer($server, $vbulletin->config['Misc']['memcacheport'][$key]);
}
$stats = $memcache->getExtendedStats();
$memcache->close();

$labels = array (
'host' => 'Host',
'pid' => 'PID',
'uptime' => 'Daemon Uptime',
'time' => 'Server Time',
'version' => 'Version',
'pointer_size' => 'Pointer Size',
'rusage_user' => 'RUsage User',
'rusage_system' => 'RUsage System',
'curr_items' => 'Current Items',
'total_items' => 'Total Items',
'bytes' => 'Memory Used',
'curr_connections' => 'Current Connections',
'total_connections' => 'Total Connections',
'connection_structures' => 'Connection Structures',
'cmd_get' => 'Gets',
'cmd_set' => 'Sets',
'get_hits' => 'Get Hits',
'get_misses' => 'Get Misses',
'bytes_read' => 'Data Read In',
'bytes_written' => 'Data Written Out',
'limit_maxbytes' => 'Memory Allocated',
'latency' => 'Latency Test',
);

$data = array('Host' => '', 'Latency Test' => '', 'Memory Allocated' => '', 'Memory Used' => '', 'Current Items' => '', 'Total Items' => '');

$i=0;
foreach($stats as $key => $val) {
$data[$labels['host']][] = $key;
foreach($val as $key2 => $val2) {
$data[$labels[$key2]][] =
(strpos($key2, 'bytes') !== false) ? vb_number_format($val2, 2, true) :
(($key2 == 'time') ? date("M j, Y, G:i:s", $val2) :
(($key2 == 'curr_items' || $key2 == 'total_items' || $key2 == 'curr_connections' || $key2 == 'total_connections' || $key2 == 'connection_structures' || $key2 == 'cmd_get' || $key2 == 'cmd_set' || $key2 == 'get_hits' || $key2 == 'get_misses') ? number_format($val2) :
(($key2 == 'uptime') ? intval($val2 / 86400) . 'd, ' . intval(($val2 % 86400) / 3600) . 'h, ' . intval(($val2 % 3600) / 60) . 'm, ' . intval($val2 % 60) . 's' : $val2)));
}
$latency = microtime();
$memcache = new Memcache;
$memcache->addServer($vbulletin->config['Misc']['memcacheserver'][$i]);
$memcache->set('latency-test', 'some value', 0, 10);
$test = $memcache->get('latency-test');
$memcache->close();
$data[$labels['latency']][] = round ((microtime() - $latency) * 1000, 4) . ' ms';
$i++;
}
print_table_start();
print_table_header('Memcached Servers', count($stats) + 1);
foreach($data as $key => $val) {
print_cells_row(array_merge((array)"<strong>$key</strong>", $val), 0, 0, -5, 'top', 0, 1);
}
print_table_footer(2, '', '', false);For users with a single memcached server (using the default vBulletin setup), change this:
foreach ($vbulletin->config['Misc']['memcacheserver'] as $key => $server) {
$memcache->addServer($server, $vbulletin->config['Misc']['memcacheport'][$key]);
}to this:
$memcache->addServer($vbulletin->config['Misc']['memcacheserver'], $vbulletin->config['Misc']['memcacheport']);

jw00dy
Mon 30th Oct '06, 2:43pm
Thanks digitalpoint for the explanation, as I thought for sure it was a percentage, but I guess it just doesn't use much, as mine is really small. I ended up changing my allocated to 16mb and that's probably still overkill.

I'll play with mine and see if I can get it to work.

Thanks for the info on MB etc.

digitalpoint
Mon 30th Oct '06, 3:06pm
The vBulletin function that does it doesn't go beyond GB... maybe they should add TB and PB while they are at it now. ;)

goha
Fri 17th Nov '06, 3:38am
Installed mamcache, installed statistics. EVerything look working, so far so good.

Can somene please explain me, what does all this numbers in Statistics mean?

Memcached Servers

Latency Test 0.106 ms
MB Allocated 256.00
MB Used 0.09
Current Items 25
Total Items 2,811
PID 10413
Daemon Uptime 0d, 22h, 33m, 35s
Server Time Nov 17, 2006, 12:30:08
Version 1.2.0
Pointer Size 32
RUsage User 48.499626
RUsage System 132.447864
Current Connections 2
Total Connections 464,918
Connection Structures 81
Gets 3,802,089
Sets 2,812
Get Hits 3,802,063
Get Misses 26
MB Read 62.15
MB Written 23,099.24

Freezerator
Tue 21st Nov '06, 11:22am
I still dont understand correctly how to set this up?

I have 2 servers, one mysql and one apache. Mysql with 4gb mem and apache with 2gb mem.

I see memcache and memcached. What is the difference? Wich one to install where?

Currently my load is acceptable on my mysql server <1., but apache server is to high <5. Is this usefull then?

goha
Tue 21st Nov '06, 2:43pm
If yo wish to have memcached ro be running on mysql server (I did so, and I have two servers like you) then:

Apache server - Memcache

MYSQL - Memcached

And yes, I found it is usefull, as it lower waiting time and lower the possibility of table locks.

TonyPBN
Mon 27th Nov '06, 4:13pm
We're looking to put as many things in the datastore as possible to help increase the speed of our site. As of writing this the only other things we are using memcached for besides the datastore are for storing templates.

Before we upgraded to 3.6 we were putting banners and the imodcache in memcached as well but I did not include these items when we upgraded because I'm looking for a more complete solution in terms of programming to keep hacking at a minimal.

Does anyone else store information besides the datastore in memcached? If so, what information? What methods are you using for this? How are you falling back to mysql when memcached is unavailable?

I'm curious to see how people are handling this.


Thanks!

kmike
Tue 28th Nov '06, 7:37am
Does anyone else store information besides the datastore in memcached? If so, what information? What methods are you using for this?

Instead of memcached, we're using eaccelerator's shared memory cache (one webserver), but the idea is the same.

Apart from the datastore and the templates, we're storing iforumcache (for a short time) and also some non-forum related content which is taking relatively long time to generate. We don't have a complete nice solution for this though, there are source code patches here and there.

How are you falling back to mysql when memcached is unavailable?It's very straightforward - if a value returned from the cache_get() helper function is null, the execution falls back to the default vB code path.

JyaJay
Tue 28th Nov '06, 5:44pm
I have one memcached server running but apparently without ExtendedStats.

The plugin from digitalpoint at the 5th page generates this output:

Warning: Memcache::getextendedstats() [function.Memcache-getextendedstats]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /admincp/index.php(977) : eval()'d code on line 5

Warning: Invalid argument supplied for foreach() in /admincp/index.php(977) : eval()'d code on line 38

Warning: Memcache::set() [function.Memcache-set]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /admincp/index.php(977) : eval()'d code on line 48

Help Memcached Servers
Host :0
Latency Test 9.799 ms

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /admincp/index.php(977) : eval()'d code on line 57

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /admincp/index.php(977) : eval()'d code on line 57

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /admincp/index.php(977) : eval()'d code on line 57

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /admincp/index.php(977) : eval()'d code on line 57



How can I enable extended status for memcached?

goha
Tue 28th Nov '06, 7:03pm
May be it is the case of difference between single server and multi server configuration?

Please refer to post number 70 in this thread
http://www.vbulletin.com/forum/showpost.php?p=1242217&postcount=70
in th eend of the post you will find the difference between single and multi servers..

JyaJay
Tue 28th Nov '06, 7:38pm
I already corrected that.


Fixxed it, I had to replace:

$memcache->addServer($vbulletin->config['Misc']['memcacheserver'], $vbulletin->config['Misc']['memcacheport']);

with:
$memcache->addServer('127.0.0.3', 11211);

netwind
Fri 1st Dec '06, 8:44am
Is any difference between memcache and using datastore in file if eaccelerator installed ?
I think eaccelerator precompile datastore.php file and load it almost all in memory.
I have only one dedicated server. Could memcache better for me ?

orban
Fri 1st Dec '06, 9:15am
datastore in file and xcache works faster for me to be honest but it's hard to tell.

digitalpoint
Fri 1st Dec '06, 3:19pm
For a single web server, I personally think eAccelerator is a better choice (doesn't need to go through the hassle of opening a network connection to the memcached server). If you have multiple web servers that need to share a single cache, memcached is the way to go IMO.

JyaJay
Fri 1st Dec '06, 9:29pm
Now that I got memcache running here are the stats:

Host 127.0.0.3:11211
Latency Test 1.362 ms
Memory Allocated 64,00 MB
Memory Used 31,9 KB
Current Items 25
Total Items 223
PID 10572
Daemon Uptime 0d, 5h, 50m, 0s
Server Time Dec 2, 2006, 2:27:43
Version 1.2.0
Pointer Size 32
RUsage User 1.630000
RUsage System 4.620000
Current Connections 9
Total Connections 4,026
Connection Structures 27
Gets 45,497
Sets 223
Get Hits 45,420
Get Misses 77
Data Read In 901,6 KB
Data Written Out 96,82 MB

Can somebody explain the use of "only" 32KB?

digitalpoint
Sat 2nd Dec '06, 4:35am
vBulletin doesn't use much memory for it's datastore.

KrON
Sat 2nd Dec '06, 9:12am
Now that I got memcache running here are the stats:



Can somebody explain the use of "only" 32KB?


The datastore data is serialized and really take up much space at all. We have our vB hacked to store the datastore, templates and styles, and we're only using about 520k.

JyaJay
Sun 3rd Dec '06, 8:20am
Thanks to the amazing guide of jw00dy I installed memcached but I couldn't figure out what actually happens with vBulletin. The server got a way better load average now which is in my eyes the work of memcache but there is no way for me to proof that. Could somebody explain this a little what exactly gets cached in the case of vBulletin?

The datastore data is serialized and really take up much space at all. We have our vB hacked to store the datastore, templates and styles, and we're only using about 520k.

Did this help to improve the performance compared to only caching the datastore, and if so what modifications have you done on vB?

TonyPBN
Mon 4th Dec '06, 7:11pm
Could somebody explain this a little what exactly gets cached in the case of vBulletin?



Did this help to improve the performance compared to only caching the datastore, and if so what modifications have you done on vB?



By default vbulletin will store the items in your datastore table.

Since there is a style query and a template query on every page load by putting those two items in memcached we have eliminated 2 queries on every page. They aren't problematic queries but it will help.

Paul_M
Tue 5th Dec '06, 2:01pm
I've gone through this today, and I have memcache running on my main server and memcached running on my mysql server. Everything appears to be fine, I've used the linked modification to give memcached information in the admincp and it shows OK.

However a few modifications I have are broken/not working since I made these changes (vbgooglemap most obvious). Is there a way to detect if memcache(d) is causing these problems, or an obvious way to make sure hacks/add-ons will work with memcached?

hydn
Wed 6th Dec '06, 3:23am
Any windows 2003 instructions available for this?

Zachery
Wed 6th Dec '06, 4:26am
memcache does not currently run on windows as far as I am aware.

hydn
Wed 6th Dec '06, 4:33am
I does http://jehiah.cz/projects/memcached-win32/

but no much documentation

JyaJay
Wed 6th Dec '06, 12:13pm
By default vbulletin will store the items in your datastore table.

Since there is a style query and a template query on every page load by putting those two items in memcached we have eliminated 2 queries on every page. They aren't problematic queries but it will help.

Maybe for you this is a natural question but it would really help me if you describe what exactly you did so I can cache these queries like you did. Thanks in advance!

Mitch100degrees
Thu 7th Dec '06, 7:23am
I've read the entire thread, but I'm still confused. I have a high mysql load, and I'm looking for solutions. I have phpsuexec so I can't use a php cacher, does memcached work with that? Also I have apache / mysql running on the same server, will memcached help me or should I not bother?

Also which one do I use? memcached or memcache...

Edit: Forgot to mention the box has 2GB of memory.

Zia
Sat 9th Dec '06, 12:54am
[quote=Mitch100degrees;1266503]I've read the entire thread, but I'm still confused. I have a high mysql load, and I'm looking for solutions. I have phpsuexec so I can't use a php cacher, does memcached work with that? Also I have apache / mysql running on the same server, will memcached help me or should I not bother?

Also which one do I use? memcached or memcache...

SQL memcache
http://pecl.php.net/packages.php?catpid=3&catname=Caching

memcached :memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
http://www.danga.com/memcached/


I am also thinking to install memcache

Zachery
Sat 9th Dec '06, 1:12am
Stop using phpsuexe, its not worth the overhead.

hydn
Sat 9th Dec '06, 11:54pm
Think i got it working on windows IIS.

When I stop the memcache.exe service the forum breaks says cannot connect to memcache via port etc... and when i restart service it runs FAST!!!

Anyway I can see the stats to when I try to add plugin i get:
MySQL Error : Unknown column 'executionorder' in 'field list'

Any suggestions?

hydn
Sun 10th Dec '06, 12:08am
Never mind i got it. Just removed executionorder="5" for my 3.5

hydn
Sun 10th Dec '06, 12:25am
Ok it's working I see the stats. My only error now is right above the stats table i see this single error:

Warning: Memcache::set() [function.Memcache-set (http://blackberryforums.pinstack.com/psadm143/function.Memcache-set)]: php_network_getaddresses: getaddrinfo failed: No such host is known. in \admincp\index.php(693) : eval()'d code on line 46Any ideas?


BTW here's the rest of the stats:
Memcached Server
Host xxxxxxxxxx
Latency Test -749.58 ms
Memory Allocated 64.00 MB
Memory Used 39.9 KB
Current Items 33
Total Items 94
PID 1412
Daemon Uptime 0d, 1h, 40m, 1s
Server Time Dec 10, 2006, 0:07:27
Version 1.2.0
Pointer Size 32
Current Connections 10
Total Connections 7,156
Connection Structures 15
Gets 82,683
Sets 94
Get Hits 82,650
Get Misses 33
Data Read In 1.42 MB
Data Written Out 235.30 MB

hydn
Mon 11th Dec '06, 2:21am
Warning: Memcache::set() [function.Memcache-set (http://blackberryforums.pinstack.com/psadm143/function.Memcache-set)]: php_network_getaddresses: getaddrinfo failed: No such host is known. in \admincp\index.php(693) : eval()'d code on line 46

Anything on this?

Mitch100degrees
Mon 11th Dec '06, 4:38am
[quote=Mitch100degrees;1266503]I've read the entire thread, but I'm still confused. I have a high mysql load, and I'm looking for solutions. I have phpsuexec so I can't use a php cacher, does memcached work with that? Also I have apache / mysql running on the same server, will memcached help me or should I not bother?

Also which one do I use? memcached or memcache...

SQL memcache
http://pecl.php.net/packages.php?catpid=3&catname=Caching

memcached :memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
http://www.danga.com/memcached/


I am also thinking to install memcache

Thanks for the links, I'll look into it.

Stop using phpsuexe, its not worth the overhead.

Zachery, I was thinking of doing that. My site performed so much better with a php cacher, it was unreal. Now I get random couldn't connect to the database emails everyday. I've been dealing with it because i've been hacked so many times through holes in php scripts its unreal. I'm a webhost and the evil script that comes to mind is flashchat, that did me in good. So I gave up my speed for phpsuexe to help stop the idiots. :(

matmat
Mon 11th Dec '06, 8:42am
I'm a webhost and the evil script that comes to mind is flashchat, that did me in good. So I gave up my speed for phpsuexe to help stop the idiots. :(

Yes, FlashChat has a new exploit In September, read about it and how to fix it here:

2006-09-04 FlashChat <= 4.5.7 (aedating4CMS.php) Remote File Include Vulnerability
http://securitydot.net/xpl/exploits/vulnerabilities/articles/1420/exploit.html

We have to remove it completely for the good work of the servers.


MatMat

Mitch100degrees
Tue 12th Dec '06, 5:27am
Yes, FlashChat has a new exploit In September, read about it and how to fix it here:

2006-09-04 FlashChat <= 4.5.7 (aedating4CMS.php) Remote File Include Vulnerability
http://securitydot.net/xpl/exploits/vulnerabilities/articles/1420/exploit.html

We have to remove it completely for the good work of the servers.


MatMat
Yes thats the fun one. I got hacked about 8 times in a week before I sat going through every log file for every client trying to find how they were doing it. I decided not to do that again and enable phpsuexe.

Does any one have any thoughts on what to do in my case again without phpsuexe?

t3nt3tion
Sat 30th Dec '06, 3:01pm
@jw00dy - added reputation since that install guide was awsome ! Keep up the good work.

jw00dy
Sat 30th Dec '06, 4:45pm
Thanks, I just wanted to contribute, and I'm glad it has helped.

melayux
Sun 18th Feb '07, 2:28am
Hello All,

I already install the memcache into my system. But when I install the plug it seems that it create a void space instead of giving me the statistic.

My VbUliten version is : 3.6.4

Thank you,

goha
Sun 18th Feb '07, 3:18pm
Please verify, if you are using sinlge or multi server version of the script.

kontrabass
Tue 20th Feb '07, 11:41am
Ok, now we need to add memcache to PHP as an extension.
Open your phpinfo file from ACP in vB and find the location of php.ini.
Once you have the location, edit the file and add/verify the following:
find "extension_dir =" and make sure it's set to your php extensions directory.
Mine has: extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429"
Which is correct based off the information we took note of in the last step of section 8. If it's not, then you have two options, you can either make it so it has the directory that you obtained during the install of memcache or add it to the extension line that we'll add to php.ini.
IF you chose to add the extension directory to extension_dir or if it was already correct (mine was from previously installing APC), then add the following somewhere in the section that has all the extensions.
;
; memcache Section
;

extension = memcache.so
memcache.allow_failover = 0
OR if extension_dir doesn't point to the correct location you can add it this way:
;
; memcache Section
;

extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429/memcache.so"
memcache.allow_failover = 0
Either one will work just fine.
Save the file, and restart apache
# service httpd restart


Just a stupid question: If I'm using APC for my php caching on the web server, is it still necessary to install memcache along with memcached? Can I just install memcached on the DB server and be done with it?

TommyBALL
Tue 20th Feb '07, 11:48am
You need both.
- memcached = the cache itself. By itself it does nothing.
- memcache is the extension that lets PHP communicate and actually use the cache (memcached).

Regards
- Tommy

melayux
Tue 27th Feb '07, 3:39am
Please verify, if you are using sinlge or multi server version of the script.

I'm using single version for the script

fotografik
Wed 14th Mar '07, 2:50am
The datastore data is serialized and really take up much space at all. We have our vB hacked to store the datastore, templates and styles, and we're only using about 520k.Is there a guide or examples to show how additional items can be added to use memcache besides just the datastore?

BamaStangGuy
Thu 15th Mar '07, 12:03am
Is there a guide or examples to show how additional items can be added to use memcache besides just the datastore?
Not that I know of which is why I started this thread on vb.org: http://www.vbulletin.org/forum/showthread.php?t=141793

kerplunk
Fri 30th Mar '07, 6:50am
I'd just like to point out again that this is an excellent guide on how to setup a Memcached server:

http://www.vbulletin.com/forum/showpost.php?p=1237714&postcount=39

It would be awesome if we could get that in one of the sticky threads in this forum.

eva2000
Sat 31st Mar '07, 6:25am
I'd just like to point out again that this is an excellent guide on how to setup a Memcached server:

http://www.vbulletin.com/forum/showpost.php?p=1237714&postcount=39

It would be awesome if we could get that in one of the sticky threads in this forum.
Stickied http://www.vbulletin.com/forum/showthread.php?p=1331824#post1331824 :D

Deimos
Thu 17th May '07, 11:14pm
Hmm, installation went aok, but, apon changing the forum config file to the correct listening port/ip, the forum throws up an error saying memcache isn't running? yet it is.

Any suggestions?

Error says

Fatal error: Memcache is not installed in /includes/class_datastore.php on line 271

kerplunk
Thu 17th May '07, 11:33pm
Did you actually start the memcached server?

Deimos
Fri 18th May '07, 12:18am
Funny thing is, it says it's already listening if I try and start it again, but, it doesn't seem to show on the process list via ps -xx

hmm

kerplunk
Fri 18th May '07, 3:41am
ps aux | grep memcached

What does it show?

Deimos
Fri 18th May '07, 7:53am
Hiya

It shows


nobody 10069 0.0 0.0 1932 644 ? Ss 05:41 0:00 /usr/local/bin/memcached -u nobody -d -m 64 -l 127.0.0.3 -p 11211

root 22494 0.0 0.0 2588 484 pts/0 R+ 05:53 0:00 grep memcached

kerplunk
Fri 18th May '07, 2:31pm
Is 127.0.0.3 an IP that you have bound/assigned to your server?

Deimos
Fri 18th May '07, 3:24pm
Ahh...not sure

I tried it with 127.0.0.1 and the shared IP to (the one listed in WHM) but neither seemed to work.

jw00dy
Fri 18th May '07, 7:51pm
did you try .2?

.2 and .3 shoudl work just fine.

Just make sure also specify the IP and port in your vb file.

TommyBALL
Sat 19th May '07, 9:02am
All the addresses from 127.0.0.1 to 127.255.255.254 refer to "yourself". That is; they are all loopback addresses.
The loopback net is defined as: 127.0.0.0/8

Some implementations only use the 127.0.0.1 address, while others use the full range. Windows use the full range.
127.0.0.0/8 - This block is assigned for use as the Internet host
loopback address. A datagram sent by a higher level protocol to an
address anywhere within this block should loop back inside the host.
This is ordinarily implemented using only 127.0.0.1/32 for loopback,
but no addresses within this block should ever appear on any network
anywhere [RFC1700, page 5].
http://tools.ietf.org/html/rfc3330

Deimos
Sat 19th May '07, 11:01am
did you try .2?

.2 and .3 shoudl work just fine.

Just make sure also specify the IP and port in your vb file.

Aye, did that :(


$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$i = 0;
// First Server
$i++;
$config['Misc']['memcacheserver'][$i] = '127.0.0.1';
$config['Misc']['memcacheport'][$i] = 11211;
$config['Misc']['memcachepersistent'][$i] = true;
$config['Misc']['memcacheweight'][$i] = 1;
$config['Misc']['memcachetimeout'][$i] = 1;
$config['Misc']['memcacheretry_interval'][$i] = 15;

And it's definatly running

nobody 20246 0.0 0.0 1932 644 ? Ss May18 0:01 /usr/local/bin/memcached -u nobody -d -m 64 -l 127.0.0.1 -p 11211

But, I still get

http://www.worthingforum.co.uk/

(Fatal error: Memcache is not installed in /includes/class_datastore.php on line 271)

TommyBALL
Sat 19th May '07, 11:26am
Have you set up the memcache PHP extension? You will need that for PHP to be able to talk to the memcached deamon.

Regards
- Tommy

Deimos
Sat 19th May '07, 4:59pm
Thought I had...Doh!

Ok it works now, kinda

One site loads AOK with it, but another one on the same server (Same version of VB), just loads a blank white page
If memcache is disabled in the VB config file, it loads ok

Arghhhh

TommyBALL
Sat 19th May '07, 5:26pm
You cannot have 2 forums run on same memcached daemon. They will thrash each others data. You need to set up 2 memcached daemons.
You can either set them up on 2 different ports or 2 different IP's. Then set up each forum to access it's own dedicated memcached daemon.

Deimos
Sat 19th May '07, 7:25pm
Well that makes sense :)

Thanks for your help and to everyone else

Got it working for both forums now.

ekool
Wed 23rd May '07, 1:26am
I noticed a problem today. I have multiple forums on the same machine. When I attempted to turn on memcached support on another forum it would only load a blank page... so I'm guessing more then one forum cannot share the same memcached server.

This should be possible with each forum using some unique identifier in the memcached server?

Anyone know a workaround to this problem?

KrON
Wed 23rd May '07, 1:33am
I noticed a problem today. I have multiple forums on the same machine. When I attempted to turn on memcached support on another forum it would only load a blank page... so I'm guessing more then one forum cannot share the same memcached server.

This should be possible with each forum using some unique identifier in the memcached server?

Anyone know a workaround to this problem?

See two posts above yours?

ekool
Wed 23rd May '07, 1:37am
See two posts above yours?

Yah, but there should be a workaround in VB, like I mentioned... a unique identifier of the data. Almost like a prefix in a mysqldatabase table.

KrON
Wed 23rd May '07, 1:44am
Yah, but there should be a workaround in VB, like I mentioned... a unique identifier of the data. Almost like a prefix in a mysqldatabase table.

Seeing as vBulletin does not support multiple forums on one server any more than they support a single instance of vBulletin on a server, running another instance of memcache seems like the logical fix.

TonyPBN
Wed 23rd May '07, 1:48am
You need to set up 2 memcached daemons.
You can either set them up on 2 different ports or 2 different IP's. Then set up each forum to access it's own dedicated memcached daemon.

It's already been answered.

ekool
Wed 23rd May '07, 1:50am
Seeing as vBulletin does not support multiple forums on one server any more than they support a single instance of vBulletin on a server, running another instance of memcache seems like the logical fix.

It's already been answered.

I've got it working right now with 2 servers, but now you have to dedicate two separate memory pools which just seems inelegant.

Oh well.

KrON
Wed 23rd May '07, 1:59am
Given how much data you actually need to run a vBulletin datastore (< 32mb), having two memcache daemons allocating that 32mb each really makes minimal, if any difference.

jw00dy
Wed 23rd May '07, 2:26am
Ha, if you are able to run more then 1 forum on your server then you don't need to add more then 2mb per daemon. Memcached on my server (pretty big site) only uses .9mb.

Just fire up another daemon and call it good. Your making an easy solution difficult for the sake of elegance. :)

R1Swedie
Mon 28th May '07, 3:25pm
I'm really having difficulties getting this to work.

I've run the steps jwool told on page 3. No errors.

But when changing the vB config, I get the error saying that "Memcache is not installed" message.

I have this in php.ini:
extension = "/usr/lib/php4/20020429/memcache.so"
memcache.allow_failover = 0

the memcache.so file is there and is functional

I run: apachectl restart

My setup:

Webserver:
libevent
memcache
(also memcached installed)

Mysql server:
memcached

the webserver connects to the mysql server with an internal IP: 192.168.0.5.

I therefor setup config.php like this:

$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$config['Misc']['memcacheserver'] = '127.0.0.1';
$config['Misc']['memcacheport'] = '11211';

127.0.0.1 is the loopback IP for the webserver.

What is wrong? I just don't understand what to do...

It says it is not installed.

But when I run ps aux | grep memcached it says it's there...

t3nt3tion
Mon 28th May '07, 3:35pm
What`s the string used to start the daemon ? What did you use ?

kerplunk
Tue 29th May '07, 3:25am
http://www.vbulletin.com/forum/showpost.php?p=1237714&postcount=39

Read that. It tells you how to install it and how to start it. :)

ams3521
Sun 10th Jun '07, 2:31pm
I followed those instructions Kerplunk and am getting the same error messsage as RISwedie.

I thinks its the $config settings in the config.php file. but i don't know what to put in.

Mbx
Sun 10th Jun '07, 8:04pm
Some questions regarding memcache. Is this feature a replacement for File Cache ? Or can you use both ? Is actually more data stored in memcache than in file cache ?

Thatīs all. Thanks alot.

dbembibre
Mon 11th Jun '07, 6:06am
HELP PLEASE

I have a forum database (mysql5.0.42) with 3 million of posts, i installed and configured memcached and all work right, but i dont know how many memory set to the daemon.
I have php5.2.3, eAccelerator and apache 2.0.55.
Dual Dual Xeon 5130 with sas discs and 4GB of memory, i dont have any other forum or php site.

ekool
Mon 11th Jun '07, 5:09pm
HELP PLEASE

I have a forum database (mysql5.0.42) with 3 million of posts, i installed and configured memcached and all work right, but i dont know how many memory set to the daemon.
I have php5.2.3, eAccelerator and apache 2.0.55.
Dual Dual Xeon 5130 with sas discs and 4GB of memory, i dont have any other forum or php site.

The memcache daemon only stores minimal very frequently accessed information. 32mb to 64mb should be more then enough.

dbembibre
Tue 12th Jun '07, 4:01am
The memcache daemon only stores minimal very frequently accessed information. 32mb to 64mb should be more then enough.

Ok 64 sound right for me, thanks a lot friend :D

goyo
Wed 13th Jun '07, 3:05am
Ok 64 sound right for me, thanks a lot friend :D

We have similar servers with similar apache/mysql/php versions...have you noticed any performance improvement ?

ekool
Wed 13th Jun '07, 4:22am
We have similar servers with similar apache/mysql/php versions...have you noticed any performance improvement ?

For myself, I noticed a big decrease in "trivial" requests on my mysql server when viewing it with mtop.

jubmedia
Fri 15th Jun '07, 1:36am
Hello,

I think we may be a good candidate for memcached but could use some advice. Maybe I should explain how I'm set up now. Here is our current architecture:

4 servers running moveable type and vbulletin. Specs for each webserver are:
2 X 2.8GHz/2MB Cache, Xeon, 800MHzFront Side, 2GB memory

The four load-balanced frontends listed above are then connected via a backend gigabit network to a dedicated mysql box that is:
2 X 2.0 GHz/4MB Cache Dual Core Xeon, 1333MHz FSB, 4GB memory

We also have all 4 frontends connecting on the backend gigabit to a NFS server which has the same specas as the webserver but with more harddrives in failover raid.

Right now the mysql is handling 198 queries per second or about 700,000 an hour.
Our Vbulletin database is 2.3GB in size

The webservers all have eaccelerator installed on them.

Here are my questions:

1) would memcached help speed up my site? Am I a good candidate for its use?
2) would I install memcached on only the 4 webservers, only the database server, all 5? What about the NFS box, should i put it there too? I have 12 other servers in my rack that I own that handle other web properties of mine. Could I and should I employ those too if they have unused memory available?
3) Do I still run eaccelerator or is memcache a replacement?
4) Moveabletype 4 is going to be able to use memcache, can it use the same memcache as vbulletin or do separate programs require independent memcaches instances dedicated to their use only?

Finally, I read some early posts that there is no failover support in vbulletin so if something is in the cache and it dies, then it might be lost. Has this been rectified? Will it not failover to the database to get the missing information?

I really appreciate any insights! Thanks in advance to anyone willing to tackle me and my ignorance!

jw00dy
Fri 15th Jun '07, 3:47am
I can't speak to all of your questions, but I'll take a couple of them.

1) YES
2) I don't recall since I only have one server, but if you go to the beginning of this thread it's talk about quite a bit.
3) No memcache/memcached does not replace your PHP accelerator -- memcache/memcached is for MySQL, not PHP.
4) ?

My understanding is that in the latest rev (3.6.7 pl1) it is supported via the config.php file so you will need to take the new one you get with the install and add the specific info for your vB as well as setup the memcache stuff (by default it only has 1 server setting, but my understanding is you just create (copy) more memcache sections. Although, I don't use it, so again, don't quote me on it. That's just what I've seen from my examination of the new file.

I'm sure the really smart ones will give you some feed back.

kerplunk
Fri 15th Jun '07, 5:36am
jubmedia: Just run one memcached server. You can host it on any server that you have free RAM available.

You will have to install the PHP extension called memcache (no "d") on all of your web servers.

As for you final question, if you are asking if it is OK to use the same memcached server for two completely different applications (vBulletin and something other than vBulletin, for example), the answer is: maybe, but probably. :)

tekguru
Fri 15th Jun '07, 1:15pm
Guys, quick question before we consider trying to use memcached to lower server resources....

- We run a ServInt VPS Pro 2Gb RAM, 5Gb burst
- Already running eAccelerator

So:

- Is it worth trying memcached on such a server?
- Would / Should we have to remove / disable eAccelerator?
- Or on such a VPS is it not worth trying it?
- Would memcached affect the backups we make via MyPhpAdmin and SQLYog?

Thinking that if vBulletin supports its use then it could be beneficial?

Looking for a quick answer if possible.

Cheers

kerplunk
Fri 15th Jun '07, 4:58pm
- Is it worth trying memcached on such a server? Yes
- Would / Should we have to remove / disable eAccelerator? No
- Or on such a VPS is it not worth trying it? Try it
- Would memcached affect the backups we make via MyPhpAdmin and SQLYog? No

tekguru
Fri 15th Jun '07, 7:33pm
Cheers for the verification, I've given SerVint the go ahead to install - fingers crossed!

BamaStangGuy
Thu 21st Jun '07, 6:22am
To enable Multithreading all you have to do is configure it with --enable-threads right?

Any way to confirm it's using both processors?

kerplunk
Fri 22nd Jun '07, 1:46am
http://code.sixapart.com/trac/memcached/browser/trunk/server/doc/threads.txt

BamaStangGuy
Fri 22nd Jun '07, 3:56am
Thanks

kerplunk
Fri 22nd Jun '07, 4:43pm
np :)

thanks for bringing this up. i'll need to enable it on our servers too.

jthorpe
Mon 2nd Jul '07, 11:33pm
Guys, I installed memcached tonight and everything is working fine on my forum, but my Vbadvanced pages aren't working. They are just blank. Anyone experience this before?

BamaStangGuy
Tue 3rd Jul '07, 4:25am
You must be using an outdated version of it. A bug like that was fixed for storing datastore in memory.

jthorpe
Tue 3rd Jul '07, 11:05am
An outdated version of memcached or VBAdvanced?

I have the latest memcached but not the latest of the VB Advanced portal.

Zachery
Tue 3rd Jul '07, 2:46pm
vBa fixed the datastore issues abit ago I believe.

jthorpe
Tue 3rd Jul '07, 4:49pm
Hmm, I may just have to upgrade to the latest version. I'm still running 2.2. Thanks for the info.

PSS
Mon 16th Jul '07, 8:23pm
I have installed memcache and memcached, thanks to jw00dy (http://www.vbulletin.com/forum/member.php?u=62753) for a fine howto!

What troubles me is this: when the daemon halts or is killed for any reason (like a bug), latest Vbulletin just hits you with:

Fatal error: Unable to connect to memcache server in /includes/class_datastore.php on line 309

Why not let Vb go on from there like nothing happened!!!??? Unset $config['Datastore']['class'], $config['Misc']['memcacheserver'] and $config['Misc']['memcacheport'] and try again?

I find it unbelievable that Vb can be killed by one missing extension. That is why I'm not using memcache on live servers until this is sorted out.

PSS
Mon 16th Jul '07, 10:21pm
I have installed memcache and memcached, thanks to jw00dy (http://www.vbulletin.com/forum/member.php?u=62753) for a fine howto!

What troubles me is this: when the daemon halts or is killed for any reason (like a bug), latest Vbulletin just hits you with:

Fatal error: Unable to connect to memcache server in /includes/class_datastore.php on line 309

Why not let Vb go on from there like nothing happened!!!??? Unset $config['Datastore']['class'], $config['Misc']['memcacheserver'] and $config['Misc']['memcacheport'] and try again?

I find it unbelievable that Vb can be killed by one missing extension. That is why I'm not using memcache on live servers until this is sorted out.

Still wonder about above, but meanwhile I worked around this with a small shell script which I put to cron on every minute, it checks if memcached has a pid, if not it restarts it. Alter to your needs (works only with one memcached process):


#!/bin/sh
pid=`ps --user=nobody | grep memcached | awk '{print $1}'`

if kill -0 $pid 2> /dev/null ; then
exit 0
else
echo memcached process not found, restarting...
/usr/local/bin/memcached -u nobody -d -m 128 -l 127.0.0.3 -p 11211
sleep 2
pid=`ps --user=nobody | grep memcached | awk '{print $1}'`
if kill -0 $pid 2> /dev/null ; then
echo process $pid ok
fi
fi
exit 0

Save as memcachedcheck.sh, chmod to 755 and run.

BamaStangGuy
Mon 16th Jul '07, 11:41pm
Thanks for the script :)

dinodonk
Tue 17th Jul '07, 12:28am
how to use SIM to check is memcached running?

Thanks

Loller
Tue 17th Jul '07, 7:33pm
May be anyone knows, for what needs this variables in config.php :
$config['Misc']['memcacheweight'], $config['Misc']['memcachetimeout'] and $config['Misc']['memcacheretry_interval'] ?

dinodonk
Tue 17th Jul '07, 11:32pm
memcached can not start.
i got this error msg :
[Tue Jul 17 21:21:42 2007] [notice] LDAP: SSL support unavailable
PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/memcache.so' - /usr/lib/php4/memcache.so: undefined symbol: php_url_parse_ex in Unknown on line 0

how to fix?

fotografik
Wed 18th Jul '07, 10:53am
We updated the forums software to 3.67PL1 today, and noticed that the memcached daemon on our SQL server has been absolutely idle since the server restart.

We are also having issues with the memcache stats and am unsure how to fix.

last pid: 1394; load averages: 0.20, 0.19, 0.17 up 0+03:36:57 21:48:14
123 processes: 2 running, 121 sleeping
CPU states: 1.5% user, 0.0% nice, 3.0% system, 0.0% interrupt, 95.5% idle
Mem: 425M Active, 2057M Inact, 143M Wired, 112M Buf, 887M Free
Swap: 4096M Total, 4096M Free

PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
627 mysql 99 86 -10 832M 385M ucond 3 25:47 8.20% mysqld
1375 root 1 96 0 2624K 1884K CPU2 0 0:01 0.00% top
494 nobody 1 4 0 38232K 37772K kqread 0 0:00 0.00% memcached
554 root 1 96 0 3452K 2956K select 0 0:00 0.00% sendmail
1326 darren 1 96 0 6112K 3120K select 0 0:00 0.00% sshd
548 root 1 96 0 3388K 2508K select 0 0:00 0.00% sshd
1323 root 1 4 0 6136K 3108K sbwait 2 0:00 0.00% sshd
393 root 1 96 0 1328K 880K select 0 0:00 0.00% syslogd
571 root 1 8 0 1348K 1044K nanslp 0 0:00 0.00% cron
1329 root 1 20 0 3784K 2624K pause 0 0:00 0.00% csh
513 root 1 8 0 1684K 1208K wait 2 0:00 0.00% sh
480 root 1 96 0 1244K 784K select 0 0:00 0.00% usbd
1328 darren 1 8 0 1636K 1324K wait 3 0:00 0.00% su
1327 darren 1 8 0 1716K 1336K wait 3 0:00 0.00% sh
558 smmsp 1 20 0 3332K 2736K pause 2 0:00 0.00% sendmail
616 root 1 5 0 1300K 940K ttyin 2 0:00 0.00% getty
615 root 1 5 0 1300K 940K ttyin 0 0:00 0.00% getty
618 root 1 5 0 1300K 940K ttyin 0 0:00 0.00% getty
619 root 1 5 0 1300K 940K ttyin 2 0:00 0.00% getty
621 root 1 5 0 1300K 940K ttyin 2 0:00 0.00% getty
617 root 1 5 0 1300K 940K ttyin 2 0:00 0.00% getty
620 root 1 5 0 1300K 940K ttyin 2 0:00 0.00% getty
622 root 1 5 0 1300K 940K ttyin 0 0:00 0.00% getty
364 root 1 114 0 500K 352K select 2 0:00 0.00% devd
260 root 1 20 0 1208K 656K pause 0 0:00 0.00% adjkerntz
I have updated the plugin that displays the stats (tried both the single-server and dual-server versions) but the memcache stats are not being displayed (see attached screenshot).

Help!!

jw00dy
Wed 18th Jul '07, 7:50pm
did you modify your config.php so it has the memcache info in it correctly?

fotografik
Thu 19th Jul '07, 12:07pm
did you modify your config.php so it has the memcache info in it correctly?Yes, and for the fun of it, I started another memcached process on the SQL server, and had it connected via the public network interface to the webserver. Noticed something funny about the stats - the latency via the private interface is consistently 4-5x that of the public interface.

Stats in AdminCP has been enabled but we are still getting an error (see attached) - I had my sysadmin look at the php code and apparently there were some extra comment fields which he removed that fixed the non-display or something.

phpinfo now also shows the correct settings for memcache (previously did not)

parttimepoker
Thu 26th Jul '07, 1:53pm
I just installed memcached for my VB forum and everything is working fine, however I am not seeing any real increase in performance. The server load is essentially the same, the speed of the forum is about the same.

We have about 200-300 users online at anytime, over 1 million posts, on a dual xeon with 2gb of memory. Memcached is set to run with 64mb

Any ideas....thought this would noticeably increase performance but I'm not seeing it. Please dont respond by saying I should install a PHP caching system, I'm doing that next :p

parttimepoker
Thu 26th Jul '07, 2:07pm
Now memcached keeps crashing

hydn
Sat 4th Aug '07, 8:24pm
checking phpinfo() in AdminCP gets me this (as per attached screencap).

Just wondering if my install is *really* utilising the memcache and memcached extensions, while waiting to install the stats plugin.

Same screenshot here. It also say connection 0 for me. How do u know if it's working???

dbembibre
Fri 5th Oct '07, 9:06am
I dont know if the starters script exist, but i cant found.
This is my solution from debian starters script in my Centos5.

Create the configuration file

touch /etc/memcached.conf

And put in:

#Memory a usar
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1

Create the startups files

touch /etc/init.d/memcached
chmod +x /etc/init.d/memcached

Edit with your favorite editor and paste this code


#!/bin/bash
#
# memcached This shell script takes care of starting and stopping
# standalone memcached.
#
# chkconfig: - 80 12
# description: memcached is a high-performance, distributed memory
# object caching system, generic in nature, but
# intended for use in speeding up dynamic web
# applications by alleviating database load.
# processname: memcached
# config: /etc/memcached.conf
# Source function library.
. /etc/rc.d/init.d/functions
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/memcached
DAEMONBOOTSTRAP=/usr/local/bin/start-memcached
DAEMONCONF=/etc/memcached.conf
NAME=memcached
DESC=memcached
PIDFILE=/var/run/$NAME.pid
[ -x $DAEMON ] || exit 0
[ -x $DAEMONBOOTSTRAP ] || exit 0
RETVAL=0
start() {
echo -n $"Starting $DESC: "
daemon $DAEMONBOOTSTRAP $DAEMONCONF
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $PIDFILE
echo
return $RETVAL
}
stop() {
echo -n $"Shutting down $DESC: "
killproc $NAME
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $PIDFILE
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL




touch /usr/local/bin/start-memcached
chmod +x /usr/local/bin/start-memcached

Edit with your favorite editor and paste this code


#!/usr/bin/perl -w
# start-memcached
# 2003/2004 - Jay Bonci <jaybonci@debian.org>
# This script handles the parsing of the /etc/memcached.conf file
# and was originally created for the Debian distribution.
# Anyone may use this little script under the same terms as
# memcached itself.
use strict;
if ($> != 0 and $< != 0) {
print STDERR "Only root wants to run start-memcached.\n";
exit;
}
my $etcfile = shift || "/etc/memcached.conf";
my $params = [];
my $etchandle;
# This script assumes that memcached is located at /usr/bin/memcached, and
# that the pidfile is writable at /var/run/memcached.pid
my $memcached = "/usr/local/bin/memcached";
my $pidfile = "/var/run/memcached.pid";
# If we don't get a valid logfile parameter in the /etc/memcached.conf file,
# we'll just throw away all of our in-daemon output. We need to re-tie it so
# that non-bash shells will not hang on logout. Thanks to Michael Renner for
# the tip
my $fd_reopened = "/dev/null";
sub handle_logfile {
my ($logfile) = @_;
$fd_reopened = $logfile;
}
sub reopen_logfile {
my ($logfile) = @_;
open *STDERR, ">>$logfile";
open *STDOUT, ">>$logfile";
open *STDIN, ">>/dev/null";
$fd_reopened = $logfile;
}
# This is set up in place here to support other non -[a-z] directives
my $conf_directives = {
"logfile" => \&handle_logfile
};
if (open $etchandle, $etcfile) {
foreach my $line (<$etchandle>) {
$line =~ s/\#.*//go;
$line = join ' ', split ' ', $line;
next unless $line;
next if $line =~ /^\-[dh]/o;
if ($line =~ /^[^\-]/o) {
my ($directive, $arg) = $line =~ /^(.*?)\s+(.*)/;
$conf_directives->{$directive}->($arg);
next;
}
push @$params, $line;
}
}
unshift @$params, "-u root" unless (grep $_ eq '-u', @$params);
$params = join " ", @$params;
if (-e $pidfile) {
open PIDHANDLE, "$pidfile";
my $localpid = <PIDHANDLE>;
close PIDHANDLE;
chomp $localpid;
if (-d "/proc/$localpid") {
print STDERR "memcached is already running.\n";
exit;
} else {
`rm -f $localpid`;
}
}
my $pid = fork();
if ($pid == 0) {
reopen_logfile($fd_reopened);
exec "$memcached $params";
exit(0);
} elsif (open PIDHANDLE,">$pidfile") {
print PIDHANDLE $pid;
close PIDHANDLE;
} else {
print STDERR "Can't write pidfile to $pidfile.\n";
}


Test the scripts


[root@srv01 init.d]# /etc/init.d/memcached restart
Shutting down memcached: [ OK ]
Starting memcached: [ OK ]


Review if the conf file is well parsed

[root@srv01 init.d]# ps aux | grep memcached
nobody 5966 0.5 0.3 18248 16444 pts/0 S 13:55 0:00 /usr/local/bin/memcached -u root -m 16 -p 11211 -u nobody -l 127.0.0.1


Add memcached as autostart daemon


[root@srv01 init.d]# /sbin/chkconfig memcached on
[root@srv01 init.d]# /sbin/chkconfig --list | grep memcached
memcached 0:off 1:off 2:on 3:on 4:on 5:on 6:off

BamaStangGuy
Sun 11th Nov '07, 5:58pm
Does anyone know how to print the contents of a memcached daemon to a screen so i can see all the keys being stored?

fotografik
Tue 13th Nov '07, 9:57am
Memcached stats for 1xx.xxx.xx.xx
pid: 494
uptime: 5476517
time: 1194961902
version: 1.2.2
pointer_size: 32
rusage_user: 2763.042131
rusage_system: 10516.599549
curr_items: 33
total_items: 2488867
bytes: 35110
curr_connections: 1
total_connections: 21199837
connection_structures: 130
cmd_get: 236545753
cmd_set: 2488868
get_hits: 236545728
get_misses: 25
evictions: 0
bytes_read: 4615792759
bytes_written: 449428165328
limit_maxbytes: 8388608
threads: 1
miss_ratio: %0
get/set_ratio: 95.04:1The Get/Set Ratio used to be 900:1 )or higher, and over the last week or so, it seems to be dropping on a daily basis. Would appreciate any information from others who use memcache and memcached.

The memcached has been running for weeks without a restart (if that info is of any help).

t3nt3tion
Tue 20th Nov '07, 8:34am
/usr/local/bin/memcached -u root -m 16 -p 11211 -u nobody -l 127.0.0.1

Doesn`t the -u root make the string have root options too ?

jw00dy
Tue 20th Nov '07, 7:05pm
Yes, you ONLY need the second -u nobody

t3nt3tion
Tue 20th Nov '07, 7:29pm
Damn, now I have to change the script. Anyone have an idea how to modify the start script from above to support starting multiple daemons of memcached ? Basically, add user, and port, ip, and starting memcache would start them all.

azn_romeo_4u
Wed 21st Nov '07, 12:54pm
total noob here, but I have a question on what to set...

If all goes well, then we're ready to enable the options in vB's config.php file.
# cd /your/path/to/forums/includes
Edit config.php
find these three lines:
//$config['Datastore']['class'] = 'vB_Datastore_Memcached';
//$config['Misc']['memcacheserver'] = '127.0.0.1';
//$config['Misc']['memcacheport'] = '11211';
uncomment the lines by removing the preceeding two /'s (//)
Then edit the second 2 lines so that it matches your configuration that you set when you started memcached.
When it's done it should look something like this:
$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$config['Misc']['memcacheserver'] = '127.0.0.3';
$config['Misc']['memcacheport'] = '11211';
Save and exit and your done.

I'm mainly interested in this part

//$config['Datastore']['class'] = 'vB_Datastore_Memcached';
//$config['Misc']['memcacheserver'] = '127.0.0.1';
//$config['Misc']['memcacheport'] = '11211';

This is the default value in config.php

$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$i = 0;
// First Server
$i++;
$config['Misc']['memcacheserver'][$i] = '127.0.0.1';
$config['Misc']['memcacheport'][$i] = 11211;
$config['Misc']['memcachepersistent'][$i] = true;
$config['Misc']['memcacheweight'][$i] = 1;
$config['Misc']['memcachetimeout'][$i] = 1;
$config['Misc']['memcacheretry_interval'][$i] = 15;

T_T I don't remember this part

Then edit the second 2 lines so that it matches your configuration that you set when you started memcached.

Hemanth
Sat 1st Dec '07, 10:06am
I'm using Xcache as my datastore cache.. Will adding a memcache make much difference or atleast do they both work together?

I'm on a single server.

Hemanth
Sat 1st Dec '07, 4:39pm
Hi,

Everything goes on well just like posted in post no: 39.

But after enabling it in vB's config file i'm getting this error in forums:

Fatal error: Memcache is not installed in /includes/class_datastore.php on line 270

The memcache daemon is running fine. Do I need to restart the server?

Wonko-The-Sane
Mon 11th Feb '08, 10:35am
Warning: Memcache::connect() [function.Memcache-connect (http://442forums.net/forums/function.Memcache-connect)]: Can't connect to :0, Failed to parse address "" (0) in /includes/class_datastore.php on line 222

Fatal error: Unable to connect to memcache server in /includes/class_datastore.php on line 224any hints ?


My config file.

// ****** DATASTORE CACHE CONFIGURATION *****
// Here you can configure different methods for caching datastore items.
// vB_Datastore_Filecache - to use includes/datastore/datastore_cache.php
// vB_Datastore_APC - to use APC
// vB_Datastore_XCache - to use XCache
// vB_Datastore_Memcached - to use a Memcache server, more configuration below
$config['Datastore']['class'] = 'vB_Datastore_Memcached';

// It is also necessary to specify the hostname or IP address and the port the server is listening on
/*
$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$i = 0;
// First Server
$i++;
$config['Misc']['memcacheserver'][$i] = '127.0.0.3';
$config['Misc']['memcacheport'][$i] = 11211;
$config['Misc']['memcachepersistent'][$i] = true;
$config['Misc']['memcacheweight'][$i] = 1;
$config['Misc']['memcachetimeout'][$i] = 1;
$config['Misc']['memcacheretry_interval'][$i] = 15;
*/
php.ini has memcache in it.

forum442:~/memcache-2.1.0# ps aux | grep memcached
nobody 6544 0.0 8.7 47136 45768 ? Ss 13:48 0:00 /usr/local/bin/memcached -u nobody -d -m 64 -l 127.0.0.3 -p 11211
root 8719 0.0 0.1 3200 636 ttyp0 S+ 14:35 0:00 grep memcached
forum442:~/memcache-2.1.0#

any idea's ?

Thanks in advance, I am sure its something dumb I am not doing, but I am hungover and looking at a putty shell is not fun.

t3nt3tion
Mon 11th Feb '08, 10:37am
Well, your memcache part is commented out.

t3nt3tion
Mon 11th Feb '08, 10:37am
Should be :




// ****** DATASTORE CACHE CONFIGURATION *****
// Here you can configure different methods for caching datastore items.
// vB_Datastore_Filecache - to use includes/datastore/datastore_cache.php
// vB_Datastore_APC - to use APC
// vB_Datastore_XCache - to use XCache
// vB_Datastore_Memcached - to use a Memcache server, more configuration below
$config['Datastore']['class'] = 'vB_Datastore_Memcached'