Chinaunix首页 | 论坛 | 博客
  • 博客访问: 32206
  • 博文数量: 21
  • 博客积分: 707
  • 博客等级: 上士
  • 技术积分: 237
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-15 12:48
文章分类

全部博文(21)

文章存档

2011年(21)

分类: LINUX

2011-03-09 16:31:26

come from: Openx performance boosting with memcachedOpenx  performance boosting with memcached
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.75 out of 5)

I was testing memcached in one of my cluster. It is seems to be very useful to increase performance. As it is “Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.” , Read more about and see who all are using memcached.

But the main thing is your application need memcached support otherwise it won’t work.

So Openx have a plugin for memcached support. This will help your openx faster delivery via delivery cache. To enable this plugin go to Global Settings > Banner Delivery Settings to choose memcached caching of banners. Don’t enable it if you are not installing the following packages.

Before enabling this plugin you must need to install a perfect memcached server in your openx server. So please proceed the following instructions.

Install memcached server

Download the memcached server from

# wget -c # tar -xzf memcached-1.4.5.tar.gz # cd memcached-1.4.5/ # yum -y install libevent libevent-devel # ./configure --prefix=/opt/memcached # make # make install

Now the installation finished. Let us use the following command to start memcached .

# /opt/memcached/bin/memcached -u nobody -d -m 128 -l 127.0.0.1 -p 11211

In the above command memcached will start as a daemon and listen on port 11211 on 127.0.0.1 . Here -m 128 means the amount of memory it can use, here 128 MB of RAM.
So let us create an init script for start/stop of memcached. /etc/init.d/memcached

#-------------------------------------# ------------ #!/bin/sh # # Memcached This shell script takes care of starting and stopping # Memcached. # # chkconfig: 2345 95 55 # description: memcached is a memory caching server # Source function library. if [ -f /etc/init.d/functions ]; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions else echo "Could not find functions file, your system may be broken" exit 1 fi # Source networking configuration. if [ -f "/etc/sysconfig/network" ] ; then . /etc/sysconfig/network fi # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -f /opt/memcached/bin/memcached ] || exit 0 # See how we were called. case "$1" in start) # Start daemons. echo -n "Starting memcached: " /opt/memcached/bin/memcached -u nobody -d -m 128 -l 127.0.0.1 -p 11211 echo_success echo touch /var/lock/subsys/memcached ;; stop) # Stop daemons. echo -n "Shutting down bandmin: " pkill -9 memcached pkill -9 memcached echo_success echo rm -f /var/lock/subsys/memcached ;; *) echo "Usage: memcached {start|stop}" exit 1 esac exit 0 #-------------------------------#

Now give execute permission to init script as follows,

# chmod 755 /etc/init.d/memcached

If you need to start this server during reboot , please add the following line to /etc/rc.local

# /etc/init.d/memcached start

So our server is ready. Now we need ton install the php-pecl memcached extension. Otherwise your application won’t work,

Install php-pecl memcached

Download the latest stable memcached from

# wget -c # tar -xzf memcache-2.2.5.tgz # cd memcache-2.2.5/ # phpize # ./configure # make # make install

Now restart apache and create a phpinfo page and test whether the memcache options is showing or not. If it is there go to Openx admin and enable the plugin.

Popularity: 50%

阅读(513) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~