terminal

How To Host Slashdot On a Shared Server

By: Jon Gales

This week’s PowerUser Monday is brought to you by Scott Kelby’s Macintosh

The Naked Truth. Read MacMerc’s review of it here.

If you have a story suggestion, please email it to jon@macmerc.com.

Last week I covered the WWDC Keynote speech live (from the satellite feed

shown at the Tampa

Apple Store). If you missed it and live in a cave, here’s

the archive.

Like all of our live events it was a complete blast–we had tons of people

chatting

in

AIM/iChat

and served

an

amazing

amount

of pages

to enough people to sell out a basketball arena. The most amazing part

of all is that MacMerc is completely housed on a single shared server from

the fine folks at ActaDivina.

spike How To Host Slashdot On a Shared ServerI

could go on and on, but pictures are better than words. Seen at right what Webalizer made

of our traffic spike. The bright blue bar is pages (the main focus of this

article). That spike is pretty impressive… It’s roughly 20 times above our

average. So, what’s the secret to being able to handle the load? Static pages

baby.

Most of the cool features on MacMerc are made possible because of the

cool technology behind it. On any given news article you can comment, moderate

other

comments,

and

sometimes even vote in a poll. On stories like this one you see "blocks"

on the right hand side that give you access to some cool stuff. If you’re a

member (it’s free), you can even see how many people are currently at the site.

On any given page

load, we have server-side code that talks to our database and fetches the

data, formats it, and then exports it off to your browser. It’s all pretty

neat, but

it takes a lot of power to run. I made the decision a long time ago (right

after our server crashed during the iTunes Music Store announcement I believe)

that we would never try live coverage again without going static.

I wrote a

special content management system just for the keynote coverage. It

has a

pretty

slick

interface

and makes a static page as output. It’s also a time saver because it writes

all the time stamps and mark up for me. I just plug and chug. This was the

only scripting going on for the whole site, and only I was using it.

What’s the difference

between static and dynamic? When you accessed us during the keynote

the database

was

completely

still… No server

side programming

happened. Your browser said, "Give me the index page" and our server

said,

"here it is".

To take it a step further, I used mod_rewrite to forward everyone but myself

to the static index page. So if you typed in:

http://www.macmerc.com/ilovedellsomuch

You would see the same exact thing as everyone else. This is so we can assure

that the server is JUST working on shoving out the index page. The only person

that wasn’t seeing this page was me because I was doing the play-by-play.

So how did we do? Well here are some numbers/facts:

  • At our peak we were serving 150,000 pages an hour
  • That peak works out to about 40 pages a second (you should see this fly

    by on the terminal… really something).

  • With almost 500,000 pages served, we only went through about 5 gigs of

    bandwidth (the page was REALLY optimized). Not having any images really helped

    things move smoothly.

  • We still almost got nuked. The highest load average (via top in the terminal)

    I’ve ever seen happened during our peak… Over 100.

  • For a few hours we made Slashdot look

    like a Geocities page. Felt quite good. I felt tempted to try and crash someone’s

    site… Start a tradition of being "Merc’d".

If you’re looking for a host that can handle peaks, check out ActaDivina (nope,

we don’t get anything if you sign up… we just like them). They were superb.

They noticed the peak and streamlined Apache to make things

a little more smooth. Didn’t even have to ask them. If you got any questions

(or suggestions, we are going to be doing this again the

next

time

there is

a similar

event)

please let

me know. If you’re going to be having a similar event and want to find

out more about the content management system that I wrote, feel free to ask.

Scheduling Your Mac

By: Jon Gales

Back in the OS 9 days it was pretty hard to put your beloved Mac on a schedule.
Now with OS X’s Unix underbelly, it’s easy as 1, 2, configure. The Unix utility
Cron is built into OS X, and can automate most anything. Here’s a quick intro:

Cron is a daemon (program that’s always running) that processes crontab files.
Each user has a crontab file. It’s a very simple format, but it has to be exactly
right:

minute hour day month weekday command

That’s not so bad is it? Put a * when you want it to occur every time. For
example, if we want a job to process at 1PM every day this would be the crontab:

0 13 * * *
command

Now, here is where it stars to get useful… Meet your new favorite command.

open => used to open applications or web URL’s. Here are some examples:

‘open
/Applications/’ opens the Applications folder in the Finder
‘open -a TextEdit /foo.txt’ opens foo.txt in TextEdit.
‘open http://www.macmerc.com/’ opens the URL in your default browser.

so if you have tab browsing and set new links to open a new tab, you can set
your computer to queue a few sites for you in the morning:

0 7 * * * open http://www.macminute.com
0 7 * * * open http://www.cnn.com
0 7 * * * open http://www.mobiletracker.net

At 7AM you’ll get met with three tabs of goodness. Fun! You can do more with
this though–it’s not just opening apps. Any command you can do in the terminal
can be put on a schedule. You can even run Applescripts by using the command
"osascript".

Now, how to actually write your own crontab file. You can do it manually from
the Terminal by typing crontab -e, but I suggest using the free Cronnix.
It labels what column is what which is really handy if you don’t do it every
day.

MacManX’s Picks

Well, I’m proud to start the first of our personal picks this week. I’m sure that my collection is probably the most eclectic, but I find all of these freeware apps very useful.

mu MacManXs PicksMenuMeters

MenuMeters is a collection of menu extras, featuring easy, graphic monitoring of CPU, disk, network, and RAM usage. MenuMeters is simple, easy to use, and valuable. If you can’t seem to find a practical use for it, at least the CPU graph is pretty neat to watch.

mu MacManXs PicksVLC

VLC is a powerful multimedia player that can read a variety of formats including DVD, VCD, MPEG, and DivX. For those of you who are depressed by Apple’s lack of support for more than 2 channels with its DVD player, VLC is your solution and features support up to 5.1 channels. Currently, VLC’s GUI is more advanced and intuitive than MPlayer and unlike the current version of MPlayer, VLC tells you when and why it can’t play a certain file, rather than just quitting.

mu MacManXs PicksTux Paint

Do you have small children? Have you made the move to OSX? Do you and/or your kids miss KidPix? Then I strongly recommend that you try Tux Paint . Tux Paint is a paint application that is aimed towards young children (similar to KidPix). Tux Paint features basic drawing tools, designs, colors, and a downloadable stamp set.

mu MacManXs PicksCocktail

Cocktail is an undeniably valuable tool for every OSX user who is either afraid of the terminal, or just doesn’t have the time to bother with it. Cocktail takes control of nearly every terminal command available and presents it in a very easy and intuitive GUI. SOme features include prebinding, Cron scripts, delete archived log files, delete caches, and customizing the look and features of the Finder and Dock.

mu MacManXs PicksFreeSnap (fka, Snatcher)

FreeSnap (fka, Snatcher) is an easy to use and powerful screen shot application. It features the ability to take screen shots of the entire screen, window, or selection. FreeSnap also features AppleScriptability, scaling, timed screen shots, 10 different formats, global key combos, a completely invisible mode and more.

Well, I hope you enjoyed my picks for this week and find some of them useful. Have a great week!

James

mu MacManXs PicksDownloads provided by MacUpdate ??