Edit: Steve Reynolds posted a great followup focusing on how to do this in EC2.

stackSo my brother recently asked me how to best go about configuring a WAMP (Windows, Apache, MySQL, PHP) stack for production. I’m sure there’s a ton of things you should do, but here were some intial thoughts that sprang to mind. I may update the post with others as I think of them.

All of this applies to a single server environment, once you start scaling out different rules apply. Ideally your architecture should be designed so that you can scale horizontally though, so that if things do take off you don’t find yourself re-writing everything.

Feel free to add other tips in the comments …

Windows

  • Turn off uneccessary “stuff”
    Windows runs a bunch of services by default that you don’t need. Bin them. Especially the following:
    - Windows Firewall (will mess with your inbound/outbound traffic)
    - Indexing service (will thrash your hard drive trying to be “helpful”)
    - Any anti-virus services (use your discretion here, but generally they can cause a lot of unecessary disk activity.)
  • Sort the startup folder and app tray
    Blitz everything from the startup folder and app tray that isn’t absolutely necessary.

Apache

  • Grab the right copy
    Always get the most recent copy for bug fixes and features. At the time of writing v2.2 has some nice load-balancing configuration features for instance. Also, make sure you download the SSL-enabled version of http server, it may come in handy.
  • Set cache settings
    Take a look at the ExpiresActive and ExpiresByType config options to setup caching for your images and files that won’t change that much (css, js). This will make your site more performant in the eyes of the user and save you money on bandwith charges.
  • Sort out your logging
    In test mode you probably want LogLevel set to “debug”, in production you’ll want this at something like “warn” to avoid unecessary logfile activity. Also make sure you use CustomLog to grab all the info you can about your end users and rotatelogs to manage your logfiles.
  • Disable directory browsing
    An absolute must, see this howto.
  • Setup custom error pages
    Use the ErrorDocument directive to setup nicer looking error pages. They look better, and don’t give outyour sensitive environment info.
  • Enable compression
    It’s well worth doing and straightforward.

MySQL

  • Write to a seperate disk
    Do data writes on a different disk to the webserver and application processing. You want to ensure that you don’t have disk contention issues.
  • Consider RAID
    If uptime is crucial consider implementing something like RAID 1 to mirror your data across multiple disks.
  • Backup the DB data
    Do this at least every 12 hours, using something like S3.
  • Tweak configuration options
    There are hundreds of config options for MySQL, probably worthy of a seperate post in their own right, but by far the most important is your upfront decision about which table-type to use, as it’s difficult to change afterwards. Check out this lowdown on some of the different options.

PHP

  • Enable extensions
    PHP works quite nicely out of the box, but remember to enable any extra extensions (the bits with “extension=” in your PHP.ini file)
  • Tweak post rules
    You might want to set the “post_max_size” variable if you’re accepting large (or want to limit) file uploads.

Miscellaneous musings

  • Consider S3 for storage
    Storage is hard. Doing it yourself is hard. If you’re doing it a lot let Amazon worry about it for you, by building on top of S3. In your application design it’s easier to bake this in upfront rather than retrofit it. And it’s cheap.

Bartlet for America

October 30, 2008

FIVE days from now the U.S. people will vote for their next President, the leader of The Free World. Forty five percent of his own countrymen will vote against him. He will carry the electoral college with 5 to 6 swing states. Media outlets will both laud and pound him. Bloggers will rejoice. Others will hate the sight of him. Some will plot to take him down. Many more across the world will see him as little more than a figurehead for a cabal of selfish modern day robber-barons, intent on peddling the new religion of consumerism, and all the foreign misadventures it entails.

We have a dim view of politics in the UK. Heck, we’ve had long enough to get cynical about it – we’ve had parliamentary representation for over 300 years, and enough dubious political figures to found a small colony (and many did). We rail about low pay, the state of the railways, the youth and Prescott’s Jag. We moan about a government out to tax us to death (and beyond), and the appalling state of our health service. We don’t choose to vote, but we like to have our say, even so.

We forget that most politicians don’t earn as much as the average Managing Director. They don’t get into politics for a cushy life, an easy ride. They do so to serve. To make a difference, to affect change in a hurting world, to step into the arena, not cower in the corner. We should treat them as heroes, not villains, applaud their commitment, their sacrifice, their service.

I for one still believe in a place called Hope. As Leo himself once said:

    “This is the most important thing I’ll ever do. I have to do it well.”

That’s what service is all about. Just ask Josiah Bartlet.

FOWA Day 2

October 10, 2008

Back at FOWA for day 2. Things feel a little bit more sombre this morning, maybe because the stock markets are tanking, and Tim Bray from Sun gave a pessimistic keynote about the future (more on that in a later post).

In the meantime here’s a gratuitous picture of a very fast server. I think this would look good in the living room at home:

Surfing at FOWA

October 9, 2008

So I’m at the Future of Web Apps conference in London today with Mike.

It looks even bigger & better than last year. Best moment so far was being first on the conference surfboard:

What’s the frequency ?

August 27, 2008

REM play the Southampton Rose Bowl, and we’re here to join in the fun …

Band practice

August 27, 2008

Matt, Chalkers and I hooked up to play some tunes a couple of weekends ago. We were at least as good as the “on the road” years in Zippy’s …


We may have, er, tweaked the sound a little:

… but at least we had some better gear than uni days:

IPhone

June 25, 2008

So I picked up a new phone today. After 10 years with Orange I switched to O2 for one reason alone – Apple’s new IPhone.

photo

So far I’ve been mightily impressed.

So last Friday I played my first game of football on a professional pitch – the not so hallowed – turf of arch rivals Chelsea. My thanks to Bob O’Hanlon for shoehorning me into the IBM team for the “Right to Play World Cup”.

This is me loafing around the goal area:

Bob and I also saw Avram Grant going into a meeting 24 hours before we heard he’d got the chop:

… but possibly the highlight of the day was meeting Chelsea legend Marcus Tandy, sorry I mean Jason Cundy:

Startup School 2008

April 20, 2008

So Mike and I were fortunate enough to get an invite to 2008’s startup school, run by the good folks over at Y-Combinator. We piled into the Kresge auditorium over at Stanford with a bunch of other geeks to hear a bunch of great speakers talk tech for the day.

The speakers were all excellent, but the pick of the bunch for me was probably David Heinemeier Hansson who talked at length about how to build a sustainable business, rather than a sexy-for-20-seconds-then-completely-forgotten-about-web2.0-thingymagig. Go see the talk here if you’re into that sort of thing.

It’s hard work running a startup: