Early Saturday morning here in Berlin, birds already chirping, I sat down in
front of my computer, brewed coffee in hand and typed in www.amazon.com into my
browser so that I could order the Wrox PHP book before I got started for the day.
Yet what to
my wandering eyes did appear but a message which read “We’re sorry but our
store is closed temporarily.” I thought I was still dreaming, so I clicked
reload a couple times but it was true! Amazon, the international e-commerce
leader, was simply closed! At that moment, I sensed thousands of people just
like me staring at their computer screens in disbelief as they stood before the
closed portals of this virtual giant. I also sensed the loss
of revenues, $1000 per second perhaps? In spite of the minor inconvenience of
not being able to order my book right at that moment, it was comforting to know that even the big boys have to deal with Web site down time!
I don’t know what caused the short down time at Amazon on Saturday morning
(perhaps their new French Web
site?) but it got me thinking
about down time and its causes. Last
week I discussed how server-side scripting and database backending can give you a
significant jump in Web site efficiency. For all its effectiveness however, if you have your Web site hosted
at an external ISP, server side scripting with a database will eventually
present you with your next hurdle: Web site down time while you upload and download the database. This is less of a problem for the Amazons of this world, who host their sites internally and can configure their servers any way they like to cover the gap, but for externally hosted sites it's a big issue.
The problem is simply this: a database cannot be accessed by Web site visitors while it is being
uploaded or downloaded from the server. If a user happens to hit your site while
you are uploading your database, he will get a gnarly “database not found” error.
Since databases can quickly reach megabyte dimensions and many
developers still access their hosting servers with slow ISDN and modem connections,
uploading or downloading a database could take 10 to 15 minutes. If you update your
Web site every day and get an average of thousand hits per day, a
sizeable percentage of your users will be seeing a database error on your site.
This should be avoided of course. The good news is that this can be avoided
with a variety of measures.
Replace your main Web site file with an uploading-message file
If you program your interactive Web sites like I do so that you have only one
file which the user hits (e.g. default.asp), it is easy to just replace this
file with a little file of the same name which shows an uploading message. After
you upload your database, recopy the original file back
over the uploading message file.
Redirect to an uploading screen
The above solution has the drawback of having multiple “default.asp” files
hanging around (one false copy and the original file is overwritten), which I
like to avoid. An additional drawback is that some companies have a “24-hour cache”
set on their networks which means that if someone in their network brings up
your uploading message page, they will see that uploading page for the rest of the day no
matter how soon you replace the original file and no matter how many times they
click reload. To circumvent these problems, I have a
file called “default-uploading.asp” and a bit of programming in my default.asp
which redirects the page to this uploading page. But remember: if you use this
solution, make sure on your uploading screen that you have a hyperlink back to your
default.asp, e.g. ("try again in 5 minutes"), otherwise the unattentive user will
keep clicking reload on your upload screen waiting in vain for the site to come
back.
Announce when your Web site can be accessed again
An interesting feature that the German Amazon site had during their brief
down time on Saturday morning was a field to enter your e-mail address to be informed when the Web
site would be back online. I entered my e-mail address and 10 minutes later received
an e-mail with a link back to their page which was back online. Nice service
Update your database online
Another option would be to program your Web application so that you can log in
and change the information online, thus circumventing the need to upload your
database. This requires some talented programming, but it can save you lots of
time in the long run. And if you program in ASP, then you are in luck: a
programmer named Eli Robillard has created a a free ASP application called GenericDB
which allows you to easily edit your databases
online. No matter how large or complicated your databases are, you simply have
to create a small settings file and your complete Web site can be edited with
your browser. GenericDB is one of those killer apps you dream about. If you
program in ASP, take an hour and check it out now!
Backing up your online database and staying in sync
Even if you take the significant programming step so that you can edit your data
online with your browser, you then have two more problems: The first problem is
that while your online database gets updated regularly, the database on your
local development machine gets more and more out of sync. The second problem is you no
longer can make a back up of your database as it is no longer on your local
machine. Here’s how you solve both of these problems: use Windows Script Host
in your server-side script to make a copy of the file to a new name on your
server, then download that copy to your local machine (or if you want to get
fully automated, have your Web site send it to you via e-mail with JMail).
A server in every pot
Unfortunately, the only way for Web developers who maintain remote
database-generated Web sites to get around these gyrations is to become the ISP
themselves and host their own Web sites on their own server. But until that utopian day arrives when everyone can afford their own highspeed line and secure
Web server, most Web developers who maintain remote, database-generated sites
will have to live with either a little down time or do some creative
circumvention.
But if it's any consolation, remember: even the big boys have down time.