Facebook php configuration

Thursday, October 11th, 2007

APC or Alternative PHP Cache is an awesome add-on for any apache web server. On my own server I was able to to handle about I was able to serve well over 1 million page views on a single server more traffic just by enabling the software. Facebook recently gave a presentation on how they use APC to serve over a billion php pages per month. My server does about 3% of that and its been running since 2004 so naturally Facebook doing the same thing as me is good reinforcement that I know what I’m doing.

Installing APC

First you have to download the latest APC and then uncompress it. To compile it use these 4 lines.

/usr/bin/phpize

./configure –enable-apc –enable-apc-mmap –with-apxs=/usr/local/apache/bin/apxs –with-php-config=/usr/bin/php-config –enable-apc-pthreadmutex

make

make install

To finish installing APC you need to edit php.ini and point it at the apc.so directory.

extension_dir = /usr/lib/php/extensions/
extension = apc.so

Configuring APC

My Server

apc.shm_segments = 1
apc.shm_size = 64
apc.stat = 1

Facebook

apc.shm_segments = 1
apc.shm_size = 648
apc.stat = 0

Other Improvements

Naturally setting up APC isn’t the only thing you can do to improve your server and your users experience. Enabling MySQL query cache is one thing you should do as it will vastly improve the number of pages your server can serve.

my.cnf with 64mb cache

query_cache_type = 1
query_cache_size = 67108864

Another thing you can do is use the Firefox plugin YSlow from Yahoo and it will show what parts of your site are slow and it will also make suggestions on what you can do to improve load times. They have a user guide thats better than anything I can write.

Beyond simple server setups you can use squid as a reverse transparent proxy to serve static content and you can learn about distributed cluster computing from Google.

Skype memory leak

Thursday, September 27th, 2007

I use Skype for talking with my family and cheap long distance. But when I brought up my task list today I saw Skype hogging my memory. Sadly, there isn’t much you can do except restart Skype every so often.

Skype Memory Leak

What you can do is delete \Program Files\Skype\Plugin Manager\skypePM.exe because it does nothing and can eat up as much as 30MB of ram doing nothing. PM stands for Plug-in Manager but if you have never enabled or disabled plugins for Skype you don’t need it and can safely delete or rename the file.

Disable Trillian Splash Screen

Tuesday, September 18th, 2007

I noticed a few people were coming to my site looking for a way to remove the Trillian splash screen. Well you can do it and it requires a little editing of the configuration file. Open up the trillian.ini file located at:

C:/Program Files/Trillian/users/default/trillian.ini OR
C:/Documents and Settings/windows username/Trillian/trillian profile/trillian.ini

Now edit the line under [Setup] from Show Loading=1 to

Show Loading=0

If you don’t have these lines in your trillian.ini file you might want to upgrade to the latest version. You might also want to use these settings Minimize Buddies=1 and Show Closing=1 as well as removing useless Trillian plugins as it will speed up trillian loading time significantly.

Delete all system restore points

Wednesday, August 29th, 2007

In Windows XP creates a system restore point every 24 hours and whenever you make changes to the system. The problem I was having is that when my available disk space was shrinking the system restore points were getting more and more defragmented. This normally wouldn’t be a problem but for some reason the disk defrag says these restore points are unmovable files. Well I looked for a solution and the most obvious one is to use the disk cleanup wizard to delete the restore points. The only problem I had with this is that the wizard doesn’t delete the latest restore point. This creates a fragmented restore point that fragments the newest restore point. Basically I will always have an unmovable restore point unless I can find a way to delete every single one of them.

I found a way. In the Windows XP Control Panel go to the System Restore tab and check “Turn off System Restore on all drives” and then click OK. This will delete all the system restore points. After you have turned off system restore run the defrag utility and then enable system restore and you have a cleaned up drive.

I’ve known about this for a while but I forgot how to do it and I was getting frustrated that I couldn’t remember how to do it. Hopefully writing this out will make me remember.

The problem with SPF records

Monday, July 30th, 2007

Quick does your domain have a SPF record? In linux type the command below and you should see something like:

# dig yourdomain.com TXT +short
“v=spf1 a mx -all”

I’ve been kind of appalled on how some websites still haven’t implemented SPF records to fight spam. On top of the non adopters you have people who haven’t implemented their records correctly. Most of the SPF implementations are from idiots that use a horrible wizard that suggest they use a soft fail(?all) for any server that doesn’t match their allowed server list. Soft fail doesn’t work. All major email services let through SOFTFAIL and NEUTRAL email. The SPF website has a better spf wizard but unfortunately it doesn’t come up in most searches.

Why should you use -all over any other? It means FAIL. Its the only way to tell another mail server that it shouldn’t accept mail from an unauthorized source. Any server that is not defined in the SPF record should automatically fail authentication. Using FAIL is the only way to minimize spam. SOFTFAIL and NEUTRAL do nothing to combat people masquerading as your domain. FAIL is also the only way to stop receiving bounce messages for spam sent spoofing itself as coming from your domain.

“+” Pass
“-” Fail
“~” SoftFail
“?” Neutral

Don’t understand how SPF works? Your SPF record should identify all the servers that are allowed to send mail as your domain. All modern websites let through email that is SOFTFAIL and NEUTRAL and PASS. I blame SPF Generators for this problem as most of them generate SOFTFAIL which all the big email sites like GMail and Hotmail let through.

Here is what all email servers do when they check SPF records

Result Explanation Intended action
Pass The SPF record designates the host to be allowed to send accept
Fail The SPF record has designated the host as NOT being allowed to send reject
SoftFail The SPF record has designated the host as NOT being allowed to send
but is in transition
accept but mark
Neutral The SPF record specifies explicitly that nothing can be said about
validity
accept
None The domain does not have an SPF record or the SPF record does not
evaluate to a result
accept
PermError A permanent error has occured (eg. badly formatted SPF record) unspecified
TempError A transient error has occured accept or reject

The only option to combat spam effectively is to FAIL any server that is sending email and is not defined as allowed.

PLEASE FAIL ANY UNAUTHORIZED EMAIL

Thanks

Fixing a Firefox illegal operation

Sunday, July 1st, 2007

Ever since I installed noscript I’ve been having trouble with web pages that have embedded movies in them. Firefox doesn’t like them. I have IETab installed so I could quickly bypass a page that was giving me an illegal operation.

Illegal Operation in Plugin
Windows Media Player Plug-in Dynamic Link Library
The plugin performed an illegal operation. You are strongly advised to restart Firefox.

Or it would say

Mozilla ActiveX control and plug-in support error
The plugin performed an illegal operation
Restart the broswer

To fix this I had to install the Windows Media Player Firefox Plugin. If you don’t trust the link you can go to the Firefox Plugin site and scroll to the bottom and click on “Vers. 11 (XP, Vista)” in the Windows Media Player section.

I had some problems with the downloaded exe file not showing up in the Downloads history. I had to go to the folder where firefox saves my files and run it from there. If you are curious if the Plugin installed correctly you can type “about:plugins” into the address bar in firefox and you should see a section that looks like this.

Windows Media Player Firefox Plugin

You also shouldn’t be getting any illegal errors.

Stealth mode for Firefox

Sunday, June 24th, 2007

With the release of Safari for Windows a number of people have labeled its private browsing mode as “Porn Mode”. Stealther enables this functionality of surfing the web without leaving a trace while not having to annoyingly clear all of your private data.

Alex Albrect on a recent Diggnation episode claimed that Safari would be great if you wanted to buy your girlfriend flowers and/or hide your porn browsing from her. Either way you don’t want to leave a trace and you consider completely wiping out the history a trace. The Stealther Plugin for Firefox fixes this problem by temporarily disabling your private data.

If there are times you want to surf the web without leaving a trace in your local computer, then this is the right extension for you. What it does is temporarily disable the following:

  • Browsing History (also in Address bar)
  • Cookies
  • Downloaded Files History
  • Disk Cache
  • Saved Form Information
  • Sending of ReferrerHeader
  • Recently Closed Tabs list

Installing Stealther

Go to https://addons.mozilla.org/en-US/firefox/addon/1306 and click the Install Now button.

Stealther plugin installation

You may be required to give permission for the addon to install by going to the Tools Menu and then clicking on Options…

Firefox Allowed Sites

Stealther Configuration

To access the configuration menu for Stealther you can go to the Tools Menu -> Addons -> Select Stealther -> Options

Stealther plugin options

You can add a toolbar button by right clicking on your navagation toolbar (back/forward/reload/stop/etc) and dragging the round grey lock to the position you want it on your toolbar. Here is where I put it.

Stealther toolbar button

If you want to hide the existence of Stealther you can opt to not install the toolbar and hide the Tools menu entry.

Using Stealther

When you click the button it turns blue and it will force the browser to forget everything that happened once Firefox is closed. There are a number of ways to can use Stealther

  • [Tools / Stealther] menu option
  • Toolbar button
  • Statusbar icon
  • [Ctrl+Shift+S] keyboard shortcut (customizable)

Speed up Trillian start up

Saturday, June 16th, 2007

Trillian is the best IM client that links together multiple services. I currently use it for multiple AIM accounts, MSN and my old ICQ account. The only problem I have with trillian is that I have to wait for it to reload whenever I reboot my computer. I decided to take action into my own hands and neutred its plugins so that it would load in under a second instead of 5-10 seconds.

In the Trillian directory I renamed all the features I don’t use:

  • crypto.dll
  • proxy.dll
  • plugins\av.dll - by far the biggest slowdown
  • plugins\irc.dll - mIRC for me.
  • plugins\http.dll

This removed a good 8 seconds off the time required to start Trillian. I’d recommend it for anyone that sees the Trillian splash screen when they start windows. Also remember if you update Trillian you will need to remove or rename these files again.