eaccelerator optimization

In one of our previous articles here, we had written about eAccelerator and metioned that it should significantly reduce the server load while increasing its speed from 1 to 10 times. But during the evaluation of eAccelerator under 1000+ http req/sec. conditions, we have noticed that Apache repeatedly launches child processes untill it reaches the MaxClients server limit and causes abnormal load averages to bring multi-core and multi-cpu performance servers on their knees just in seconds. When we debug the issue, we have noticed that all complaints in gdb backtraces were somehow about nothing but Zend.

We know eAccelerator has been reported to work with Zend many times but we realised that they do not actually accord well even when the requests only go over 50 – 60 per second. Just imagine the view when you get thousands of them. Previously in our related article, while discussing the initial configuration of eAccelerator, we’ve told that you might load it either as a Zend extension or alternatively as a PHP extension in your php.ini file. Now we explicitly recommend you not to load it as a Zend extension. Instead, prefer the straight PHP extension way with;
extension=”eaccelerator.so”

Do not install Zend Optimizer with eAccelerator if you don’t use scripts encoded with Zend Encoder. So also disable Zend optimization right behind the eAccelerator configuration lines with;
zend_optimizer.optimization_level=0

and just in case put your whole eAccelerator configuration lines at the top of your php.ini file as Zend Optimizer must be loaded after eAccelerator inside php.ini. Incidentally, for those who run the older version of eaccelerator, it’s vital to upgrade it to the latest one as old versions have a spinlock bug that leads into deadlock under heavy loads. Then, restart the apache and observe the new attitudes. Although you’ll gain some increase in the number of requests that are being responded without a fatal crash, there’re still two important things to take care of: “stat()” system calls and the compression.

stat() is a Unix system call that returns data on the size and the parameters associated with a file. On every single hit eAccelerator will check the modification time of a script to see if it’s changed and needs to be recompiled. Each time, this is done by the stat calls which consume time and add a serious overhead to the system which precludes the response to mass requests. You must skip these expensive calls which are enabled by default;
eaccelerator.check_mtime = “0”

When you disable this check, remember that you have to manually clean the eAccelerator cache when you update a file.

Compression also requires an additional cpu activity. While it’s essential for the complete http part, it’s not meaningful for the codes that are going to be cashed. And if we’re talking about skinning a flint here, then disable this feature also;
eaccelerator.compress = “0”

According to our observations, following all these configuration modifications, now the system can handle 100 http req/sec. effectively reducing the overall load at nearly %80. But if your requests grow, this brilliant savings will probably turn into a crash. In our opinion, eaccelerator is very well suited for the web servers that serve utmost 100 http req/sec. which approximately corresponds to ~1000 concurrent users (depending on the type of your web application), not for more.

Those who will take a chance on xcache as an alternative to eaccelerator won’t gain a victory above 100 requests per second, because most probably your web server will become unresponsive with a lot of processes in lockf state. We’ve also tested xcache under same pressures.

But this is not a case of this-cache or that-cache situation, it clearly seems to be a case of locking mechanism used. My impression is that we need to enable semaphore locks instead of default fcntl under certain loads. As FreeBSD doesn’t support pthread mutex locking, our next resort shall be a marginal one if semaphores don’t really help. That is spinlocks which is still considered experimental within APC (Alternative PHP Cache). Install APC from ports by enabling IPC SHM (shared memory) and spinlocking, try the configuration below and see what happens if locking is an issue for you, too. But before, you need to make sure that your “kern.ipc.shmmax” value has been set large enough in/etc/sysctl.conf to handle the shm_size below.
extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=128
apc.file_update_protection=0
apc.stat=0
apc.ttl=0

linux批量更改后缀名

一.rename解决

1. Ubuntu系统下

rename ‘s//.c//.h/’ ./*

把当前目录下的后缀名为.c的文件更改为.h的文件

2. CentOS5.5系统下

rename .c .h *.c

把当前目录下的后缀名为.c的文件更改为.h的文件

二.shell 脚本解决

#!/bin/bash

#http://blog.csdn.net/longxibendi
find ./ -name *.c | while read i
do
echo “$i”;
mv $i.c $i.h
done

三.find xargs 解决

find ./ -name “*.c” | awk -F “.” ‘{print $2}’ | xargs -i -t mv ./{}.c ./{}.h

注意,第三种方案是递归的更改,会更改当前目录下及其子目录下所有匹配文件

四.参考:

http://blog.csdn.net/longxibendi/archive/2010/09/16/5889055.aspx

如何屏蔽优酷广告

最近看优酷的视频,有时视频本身只有5秒钟,TMD被广告QJ了30多秒,甚是不爽,今日觅得此等良法,与大家共享。

一、打开 C:\Windows\System32\drivers\etc 这个文件夹,里面有一个文件名为“hosts”的文件,无扩展名,右键——打开,用记事本打开它。

二、打开后,在文本最后,空一行,添加以下内容:

127.0.0.1 atm.youku.com

127.0.0.1 Fvid.atm.youku.com

127.0.0.1 html.atm.youku.com

127.0.0.1 valb.atm.youku.com

127.0.0.1 valf.atm.youku.com

127.0.0.1 valo.atm.youku.com

127.0.0.1 valp.atm.youku.com

127.0.0.1 lstat.youku.com

127.0.0.1 speed.lstat.youku.com

127.0.0.1 urchin.lstat.youku.com

127.0.0.1 stat.youku.com

127.0.0.1 static.lstat.youku.com

127.0.0.1 valc.atm.youku.com

127.0.0.1 vid.atm.youku.com

127.0.0.1 walp.atm.youku.com

保存,就OK了。

从此就不会有广告骚扰你了。。

如果好用的话。记得留言、

还有其他的代码

#奇艺
127.0.0.1 afp.qiyi.com
127.0.0.1 focunbaiduafp.allyes.com
#CNTV
127.0.0.1 a.cctv.com
127.0.0.1 a.cntv.cn
127.0.0.1 ad.cctv.com
127.0.0.1 d.cntv.cn
127.0.0.1 adguanggao.eee114.com
127.0.0.1 cctv.adsunion.com
#新浪视频
127.0.0.1 dcads.sina.com.cn
#pptv
127.0.0.1 pp2.pptv.com
#乐视
127.0.0.1 pro.letv.com

#搜狐高清

#www.iqshw.com
127.0.0.1 images.sohu.com
@HostsX 国内站点广告/视频类网站
#CNTV
127.0.0.1 a.cctv.com
127.0.0.1 a.cntv.cn
127.0.0.1 ad.cctv.com
127.0.0.1 d.cntv.cn
127.0.0.1 adguanggao.eee114.com
127.0.0.1 cctv.adsunion.com
#我乐网
127.0.0.1 acs.56.com
127.0.0.1 acs.agent.56.com
127.0.0.1 acs.agent.v-56.com
127.0.0.1 bill.agent.56.com
127.0.0.1 bill.agent.v-56.com
127.0.0.1 stat.56.com
127.0.0.1 stat2.corp.56.com
127.0.0.1 union.56.com
127.0.0.1 uvimage.56.com
127.0.0.1 v16.56.com
#6间房
127.0.0.1 pole.6rooms.com
127.0.0.1 shrek.6.cn
127.0.0.1 simba.6.cn
127.0.0.1 union.6.cn
#土豆网
127.0.0.1 adextensioncontrol.tudou.com
127.0.0.1 iwstat.tudou.com
127.0.0.1 nstat.tudou.com
127.0.0.1 stats.tudou.com
127.0.0.1 *.p2v.tudou.com*
127.0.0.1 at-img1.tdimg.com
127.0.0.1 at-img2.tdimg.com
127.0.0.1 at-img3.tdimg.com
127.0.0.1 adplay.tudou.com
127.0.0.1 adcontrol.tudou.com
127.0.0.1 stat.tudou.com
#酷6网
127.0.0.1 1.allyes.com.cn
127.0.0.1 analytics.ku6.com
127.0.0.1 gug.ku6cdn.com
127.0.0.1 ku6.allyes.com
127.0.0.1 ku6afp.allyes.com
127.0.0.1 pq.stat.ku6.com
127.0.0.1 st.vq.ku6.cn
127.0.0.1 stat0.888.ku6.com
127.0.0.1 stat1.888.ku6.com
127.0.0.1 stat2.888.ku6.com
127.0.0.1 stat3.888.ku6.com
127.0.0.1 static.ku6.com
127.0.0.1 v0.stat.ku6.com
127.0.0.1 v1.stat.ku6.com
127.0.0.1 v2.stat.ku6.com
127.0.0.1 v3.stat.ku6.com
#激动网
127.0.0.1 86file.megajoy.com
127.0.0.1 86get.joy.cn
127.0.0.1 86log.joy.cn
#天线视频
127.0.0.1 casting.openv.com
127.0.0.1 m.openv.tv
127.0.0.1 uniclick.openv.com
#迅雷看看屏蔽:
127.0.0.1 mcfg.sandai.net
127.0.0.1 biz5.sandai.net
127.0.0.1 server1.adpolestar.net
127.0.0.1 advstat.xunlei.com
127.0.0.1 mpv.sandai.net

删除无用网卡信息

通过注册表删除多余网卡本地连接的方法这篇文章的内容如下: 在网卡出了问题并重新安装了网卡驱动程序后,系统将会自动创建连接,而且这个连接将会由原来的“本地连接”变成“本地连接2”。而“本地连接”的相关信息仍然存在于系统中。当你在“本地连接2”中设置IP等相关信息时,如果这些参数与以前的“本地连接”中设置的相同,系统将会提示被其它网卡占用的信息,此时你可以手工将以前的连接信息删除,将“本地连接2”转换成“本地连接”,问题即可解决,方法如下:打开注册表编辑器,展开到“HKEY_LOCAL_MCHINESYSTEMCurrentControlSetControl Network{4D36E972-E325-11CE-BFC1-08002BE10318}”,
  在该子键下面保存着关于本地连接的信息。在此有一个或多个子键,其中第一个子键对应着“本地连接”,第二个子键就对应着“本地连接2”依此类推,你也可以展开该子键,再选择下面的“Connection”子键,在右侧窗口中将会看到具体是对应着哪个连接,直接将对应以前旧连接的整个子键删除即可。

Installing and Configuring Windows Server 2008 SMTP

Installing SMTP Server Feature on Windows 2008 is an easy process requiring only few steps to complete. On this article we will describe a step by step configuration and installation of the SMTP Server feature and how to enable the smtp to relay from local server.

Step 1:

Opening Server Manager Console and under Features select Add Features

Step 2:

Selecting SMTP Server option

Step 3:

Click on Install wait until finish and click close

Step 4:

Waiting for installation to finish and clicking on Close

Step 5:

Opening IIS 6.0 Manager under Administrative Tools -> Internet Information Services 6.0

Step 6:

Under [SMTP Virtual Server] second mouse click and properties

Step 7:

Select Relay under Access Tab

Step 8:

Select Only the list below and click on Add button

Step 9:

Enter IP Address 127.0.0.1 for relay

Step 10:

Sending a manual email through telnet to confirm everything working successfully. Telnet localhost 25 or telnet yourpublicip 25 and make sure you open the specific port on your firewall to be available to public.

WHMCS From Latin1 To UTF8

The database was in latin1 sweedish colation and this had some side effects with the Greek characters.

FIRST THING: GO TO PHPMYADMIN AND EXPORT DATABASE TO HAVE A BACKUP!

Then I went to administration, utilities, database status, download backup.

This makes a good backup with proper encoding inside. (for me this was the right version and not the one created with phpmyadmin)

I opened the .sql file with Notepad++ and I replaced latin1 with utf8 in all the document. Save.

Then I went to phpmyadmin and i checked all tables and then selected the action drop. I confirmed dropping the tables, and then I went to import.

I imported the new sql file I created with Notepad and then I checked the database structure, tables structure and browsed some of the data. Everything appeared perfect!

Loaded a sample page of WHCS but all the Greek characters were corrupted and looked like ?????. After some research I added this line in configuration.php

mysql_charset=”utf8″;

Now everything worked perfect! I checked the database again and I made sure that the database collation was utf8_general_ci (if it isn’t go to operations and change collation).

I’m a happy Greek user of WHMCS now!

WebsitePanel not creating DNS entries in secondary name server

You must add an IP Address to each Name Server under Configuration > Servers > Click on the name of the first name server and then choose IP Address, then type an IP address (192.168.0.101) and then add. Do the same for the second Name Server (192.168.0.102).

Then, in the SimpleDNS Server Service Properties look for the section called “Listening IP Address” , choose the IP Address that you assigned this server and then click the Add button. Do this for BOTH Name Servers and BOTH SimpleDNS Server Services.

These IP Addresses are used to tell SimpleDNS which IPs to allow zone transfers from…if they arent specified then SimpleDNS wont allow a zone transfer from your secondary name server like you want it to 🙂

(Also, just as a side note… I went into the SimpleDNS management interface directy, and went into the options and told it to only bind to port 53 on the specific IP Address that I chose above….that way it’s not listening for DNS on all IPs on the machine. This is probably more important in a single server installation, or where your DNS servers have multiple NICs or IPs.)

Kernel Panic after Yum Update – CentOS with Hyper-V Linux Integration Components

I am runnning CentOS 5.5 in a VM on Hyper-V. I created a fresh installation. I then installed Hyper-V Linux Integration Components. After Installing them I ran yum update.

After running a “yum update”, and rebooting I received this error.

Unable to access resume device (/dev/VolGroup00/LogVol01)
mount: could not find filesystem ‘/dev/root’
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic – not syncing: Attempted to kill init!

During the yum update process, it updated my kernel. Kernels that are installed after Hyper-V Linux Integration Components don’t always mesh well together. Here is how I fixed my issue.

While booting, grub will ask you to hit any key to boot into the menu.

Hit any key and you will see a list of the Linux kernels on your machine.

Mine looks like:

CentOS (2.6.19-194.26.1.el5)
CentOS (2.6.18-194.el5)

The first one(newest) is booting by default and causing the issues. I will select my old kernel for the time being so that I can boot into linux and fix the issue with the new kernel.

So I will select CentOS (2.6.18-194.el5) and boot into linux. At this point, it should boot into linux normally.

Now, virtually put in your Linux Integration Components V2.1 CD into the VM.
As root, run:

mkdir /opt/linux_ic_v21_rtm
cp -r /media/CDROM/* /opt/linux_ic_v21_rtm
cd /opt/linux_ic_v21_rtm
grep -ilR uname * | xargs sed -i ‘s/uname \-r/echo “2.6.19-194.26.1.el5″/g’
make && make install
reboot

Replace 2.6.19-194.26.1.el5 with the kernel that is giving you grief. If you forgot which kernel it was you can double check the /boot/grub/grub.conf file. Chances are its the one on the top.

After the reboot, it should be able to boot into the new kernel.

Websitepanel无法新建网站的解决办法

今天在转移WEBSITEPANEL的时候遇到以下问题,无法新建网站:

[8/16/2010 6:35:19 PM] ERROR: ‘Internet Information Services 7.0’ UpdateSite
System.NullReferenceException: Object reference not set to an instance of an object.
at WebsitePanel.Providers.Web.IIs70.SetWebSiteApplicationPool(WebSite site, Boolean createAppPools)
at WebsitePanel.Providers.Web.IIs70.UpdateSite(WebSite site)
at WebsitePanel.Server.WebServer.UpdateSite(WebSite site)

将BackupCatelog.xml文件中的对应<AspNetInstalled />字段改成<AspNetInstalled>2</AspNetInstalled>即可正常恢复。

 

websitepanel更换服务的版本

Websitepanel虽然开源免费,但仍有很多不足。比起Plesk易用性差很多。

这次转移碰到个问题,之前是03的系统,转移后复制了原数据库,但服务的信息仍是旧的,面板又不支持自动更新服务的版本。这个时候需要根据Providers中的ServiceID来修改Services表中的数据,这样就可以了。