Always Get Better

Never stop looking for ways to improve

September 25th, 2010

One of the things I’ve learned about Apache is that as good as it is, it suffers from its monolithic “do-everything” nature. The modules and tuning required for effective operation just doesn’t fit into a lean, quick package. That said, I find it beats out the alternatives hands-down when it comes to running web applications of any complexity.

One very simple and effective method for improving Apache’s performance involves off-loading static content to another server. Since Apache spawns a new process (and the memory allocation that goes with that) for every request, it is pretty wasteful to serve your images, css, javascript and similar files this way.

For larger applications, we could run a second web server that makes use of a single-threaded polling process like lighttpd, or use a content delivery network to move our content physically closer to our users for even more speed.

For smaller applications and organizations, we can use nginx as a proxy to serve static content to our visitors. This can be a separate physical web server, or it can be a service running on the same server as Apache. I use the same-server proxy approach at alwaysgetbetter.com, and it has made a significant difference in my server load and memory usage.

To start, change Apache’s settings so it listens on a separate port (rather than the default port 80).

Next, set up nginx to listen on the default http port 80. We will let Nginx decide whether each request should be served directly from the hard drive, or whether it should pass through to Apache.

The config file for nginx looks like this:

server {
listen 80;
server_name mysite.com www.mysite.com;
access_log /var/log/nginx/website-access.log;
error_log /var/log/nginx/website-error.log;
# serve static files
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|pdf|ppt|txt|tar|wav|bmp|rtf|js|mp3|avi|mov)$ {
root /var/www/html;
expires 30d;
}

# pass requests for dynamic content to site
location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 128m;
client_body_buffer_size 256k;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 4k;
proxy_buffers 32 256k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 512k;
}
}

It is also possible to serve PHP and other dynamic content using nginx, but for our purposes it makes a lot more sense to use Apache for scripting and nginx as the web-facing proxy.

May 29th, 2010

So I’ve been tethering my phone and using it as a backup Internet connection for just over a week now and so far I have been pretty happy with the results.

Using Xplornet as my primary source and my cell phone tethered into my computer via USB, I’m actually able to get fairly reliable service – the computer switches back and forth between whichever connection happens to have access to the Internet.

This could work…

I see that Bell is now offering a 2Mbps modem for rural residents. I’d like to try that as an alternative to Xplornet – maybe I’ll be able to drop my contract in March and have reliable net.

May 24th, 2010

Since we live in the country and rely on line-of-sight Internet for our connectivity, I’ve been increasingly frustrated with service quality and uptime programs. There are a lot of reasons I want to move to a denser population area but access to a proper Internet connection is high on my list.

My phone has turned out to be a decent alternative; using instructions I found online I was able to re-purpose my Palm Pre as a WiFi router. It’s still not broadband but it gives me a way to check my email when my Xplornet fixed wireless (often) fails.

Although Bell Canada supports tethering with their smartphone plans, they don’t go out of their way to make it obvious how to do it. My Tether turned out to be worth the cost; even though there is a free version you can use if you want to play with the settings.

May 20th, 2009

Did you get an MSN message that looks like this?

YourFriend@hotmail.com says (2:26 PM):
http://PictureFreakz.com/?user=yourmsnname&image=DSC00567.JPG ?!?

… HAHAHA!!

Be careful – this is a scam site that invites you to enter your login information and password – then uses it to rope in your contacts with similar messages sent from your account.

April 13th, 2009
European Flag
Creative Commons License photo credit: rockcohen

The EU wants to stop Microsoft from bundling Internet Explorer with its operating system. In today’s day and age, how does this make sense? The charge is led by Opera, who claims that having Internet Explorer ship with Windows unfairly limits competitors from getting through to customers.

Any web designer will tell you that Internet Explorer is one of the most challenging browsers to target since it basically ignores web standards and renders web pages in its own proprietary way. So the design pattern we follow is:

1. Design web site using sane browsers
2. Mutilate our markup so it renders as desired on Internet Explorer

Apologies for the digression, but the point is there is a lot of work needed to make web sites work properly for one web browser. Why do it? Depending on the site, up to 65% of your visitors will be using some version of Internet Explorer – not because it is any “better” but simply because they don’t know about alternatives or haven’t taken the time to try them. Likewise for Safari among Apple users – most people don’t customize their computing experience and simply deal with their default settings.

In that regard, Opera’s proposal makes sense – force vendors to include 3rd party browsers along with Internet Explorer on new machines. But… which browsers should be included? Firefox, Opera, Safari, Netscape? What about the dozens (hundreds?) of others? Who chooses which ones are “mainstream” enough to be included?

The biggest problem I have with this is that Microsoft has done nothing to prevet users from switching web browsers. If you’re a regular reader of this blog, your first move upon booting a new PC is to download Firefox/Chrome and ditch Internet Explorer (that’s one of the main advantages I get from targeting a technical audience).

Suiong Microsoft is not the answer – we need to work on the unwashed masses and teach people to make their own/better choices when it comes to their web browsing experience. While we’re at it, perhaps we can all learn to keep our systems patched as well…

April 8th, 2009
little monkey
Creative Commons License photo credit: michelb

You have to shake your head every time someone goes off about “netbooks”, those wonderful, tiny, cute computers that don’t cost very much. When you look at them, what do you really see? How about a crappy laptop that can barely run Windows. The thing is cheap in more ways than one – but somehow marketers have been able to spin that as a good thing and make big profits off useless hardware without needing to develop anything new.

This Brave New World Seems Just Like the Old

Anything sounds better with a little bit of spin – Web 1.0 is clunky, slow, ugly. Web 2.0 is a designer’s dream, sexy, with new technology. Well, no. The technology isn’t new at all – the web is the same. The only difference is enough marketers held onto the “Web 2.0″ buzz phrase and shouted it repeatedly long enough that it became accepted as fact.

What’s So Social About Media?

There was never anything truly “new” about New Media. There’s nothing earth shattering about Social Media either. Call it a new paradigm all you want, there is nothing different between it and “old” media: the goal is to communicate our message to as many people as possible. How others perceive your brand and how you react to that feedback is not something new and alien – it’s just a lot faster now than it used to be. Your audience is your focus group. Traditional roles haven’t changed one bit – their owners have.

March 9th, 2009

Over the weekend Facebook suffered a multiple hardware failure that caused its photo service to fail. Up to 15% of the site’s multiple-billion photos displayed as nothing more than a question mark on Sunday night.

Facebook is already in the process of cleaning up the mess and restoring the lost files, but the failure is just another example highlighting the importance of making backups of our own data rather than relying on “the cloud” for permanence.