Wish More Hosts Offered WebDAV? Blame PHP!

There is a lot to hate about PHP, which most programmers will be more than happy to share with you. At length. In a heated voice. Possibly requiring a valium afterwards. The arguments about PHP’s suckiness are interesting and largely quite accurate, while at the same time almost completely academic given its pervasiveness. But that’s a subject for another less stressful day.

In addition to its many faults as a language, PHP is responsible for another injustice on the web: the general unavailability of WebDAV.

WebDAV, for those not in the know, stands for “Web-based Distributed Authoring and Versioning,” a cool technology that is available on very few web hosts.

What can WebDAV do? Well, it lets multiple people edit and work with documents safely over the web. This means that if you are editing a document, it locks it so I don’t try to make changes at the same time. And most operating systems will let you do this almost like the files are right there on your own hard drive. Sounds nice and it is. iCal uses WebDAV. Photoshop, GoLive, and Acrobat from Adobe use it. It isn’t some obscure technology that web hosts have never heard of.

WebDAV is also not new. In web terms, it is practically ancient. The first unofficial working group on it was started in 1995 and it became an official IEEE working group in early 1997. That was 12 years ago! That’s older than Wikipedia or Google!

And the problem it is not that there isn’t server software support for WebDAV. The Apache 2 web server has included WebDAV support almost form the beginning and IIS has included support for a number of years as well.

So why is WebDAV so unpopular with web hosts? As I said above, it is PHP’s fault.

The Apache web server software runs about half the web sites out there and it is the crux of the problem. I know I wrote above that Apache has included WebDAV support from the beginning, right? Almost.

There are actually two live branches of the Apache software: Apache 1 (actually 1.3 at this point) and Apache 2 (2.2 at this point). Apache 2 does include WebDAV support right out of the box, so to speak. Apache 1… not so much.

There is a third party module that adds support to Apache 1, but it has not been updated since 2001. It may work just fine; I honestly haven’t tried it. That said, I don’t know if most web hosts would want to deal with unsupported software that is older than them.

So why can’t the web hosts just use Apache 2? Here’s where PHP gets in the way. Behold this message from the PHP website:

We do not recommend using a threaded MPM in production with Apache2. Use the prefork MPM instead, or use Apache1.

Basically, it is saying you have to use Apache 1 or a dumbed down older version of Apache 2. Even so, this is better than the 2004 version:

Do not use Apache 2.0.x and PHP in a production environment neither on Unix nor on Windows.

The reason PHP doesn’t play well with Apache 2 has to do with threading. Basically, threads are a mechanism that lets one program do a bunch of things at the same time. In Apache 2, this means one program is running, but different threads are handling HTTP requests. Apache 1 didn’t use threads this way and instead ran a bunch of copies of the whole program. This takes up more system memory and makes it slower for a server to switch from handling one request to the next.

So, multithreaded is faster, and multiprocess eats memory and is slower. Go threads! But there is always a catch. Since each program may have multiple threads messing with things at the same time, you have to be much more careful when programming for a multithreaded environment. Your code must be what is called “threadsafe”, which means it will be meticulous about only touching the memory it is allowed to touch and about letting everyone else know it is needs something.

If you run non-threadsafe code in a multithreaded environment, things can break, crash, or just misbehave is very unpredictable ways. This is because different threads are all working with the same memory without being careful about it. Imagine you are cooking in a kitchen. You grab things, move things, mix things, etc. All is fine. Now imagine there are twelve of you in the kitchen doing this, each cooking your own recipe, but none of you can see each or touch each other. Your bowl will move while you are adding the milk. The stove will turn on and off at random times. Mayonnaise will decide to spread itself in the middle of your peanut butter and jelly sandwich. That is what non-threadsafe code can do in a multithreaded program. It is bad.

To be fair to the PHP folks, the PHP core can handle the threads just fine. The problem is the libraries it depends on. You know all those weird random functions that make PHP a Swiss army knife for web programming? Image processing, networking, mail handling, database management, etc. They depend on libraries that are not under the control of the PHP team. And they are not necessarily threadsafe.

So, PHP doesn’t play well with Apache 2, but WebDAV is only really at home with Apache 2. If you are a web host, without a bit of work to make it run smoothly, you have a choice of providing PHP or WebDAV, and PHP will win that fight every time.

Luckily, some web hosts are willing to got through the trouble to make it work (basically you have to pull PHP out of the server and run it in as a separate program that talks to Apache). If you are looking for one, feel free to check out my list of recommended WebDAV web hosts.

Related Information

  • Most Popular Hosts in April 2011
    ThisMonth LastMonth Host Review Storage Transfer Price* 1 1 IX Web Hosting read review unlimited unlimited $3.95 2 2 HostMonster read review unl...
  • Most Popular Hosts in January 2011
    ThisMonth LastMonth Host Review Storage Transfer Price* 1 3 IX Web Hosting read review unlimited unlimited $3.95 2 2 HostMonster read review unl...
  • Most Popular Web Hosts in November 2010
    ThisMonth LastMonth Host Review Storage Transfer Price* 1 3 HostGator read review unlimited unlimited $8.95 2 4 HostMonster read review unlimited unlimit...

Post a Comment

Your email is never published nor shared. You're allowed to say what you want...