How Web Servers Work
Contrary to the popular perception of many, the Internet is not a series of tubes. There is a very formal process that we as website owners, web developers and designers must abide by and hiccups in that process at times cause troubles. Fortunately, many issues can be avoided just by understanding how Web hosting works and more specifically how Web servers work. It's not magic folks - there is a lot of technology that goes on behind the scenes, without which we'd still be sending smoke signals.
The basic process is simple. For example, you type in the URL of your favorite website (www.websitemagazine.com/index.htm) into your browser's address bar and Voila! - the page appears on your screen. How did that happen? It's not magic - your browser connected to a Web server, requested a page and received it.
But what exactly happened behind the scenes? The browser (whether it’s IE, Firefox, or Safari) seperates the URL into three parts; the protocol ("http"), the server name ("www.websitemagazine.com") and the file name (index.htm). The browser establishes a communication connection with a name server to translate the server name "www.websitemagazine.com" into an IP Address, which it uses to "talk" directly to the server machine. The browser essentially formed a virtual "connection" to the server at that IP. Using HTTP protocol, the users' browser sends a GET request to the server, requesting the "http://www.websitemagazine.com/index.htm" file. The server then returns the appropriate HTML text for the Web page requested back to the users browser. (Cookies may also be sent from server to browser in the header for the page.) The browser read the HTML tags and presents the page with specific formatting instructions onto the users screen.
"Servers" and "clients" are the two types of "machines" on the Web and they provide services we use every day such as Web or FTP servers to other machines. When you connected to Website Magazine at www.websitemagazine.com to read the latest issue, we've provided a machine for use via the Internet to service that request. Website Magazine essentially provides you and all its users the server to make this happen. Users' machines however typically do not provide services to anyone else - these machines are known as "client" machines.
Servers often provide several services on the Internet, but it is not uncommon that they provide just one. For example, a server machine might have software running on it to be a Web server, an e-mail server or an FTP server. A users' client machine connects to a server machine for a purpose, so these clients direct their requests to a specific software server running on the overall server machine. For example, if you are running a Web browser, it will by default connect to the Web server on the server machine. Another example might be your e-mail application talking to the e-mail server.
You may be thinking to yourself, "that's a lot of machines to keep track of," - and you'd be right. To understand which machine is which on the Internet, each is assigned a unique address called an IP (an acronym for Internet protocol) address - 32-bit numbers displayed in four "octets" in a "dotted decimal number." IP addresses typically look like this: 22.214.171.124.
Each and every machine has a unique IP address on the Internet. A server has a static IP address that does not change very often. A users' machine at their home office that is using a dial-up or cable modem often has an IP address that is assigned by the ISP (e.g. Comcast) when the machine send instructions to connect. That IP address is unique for that session -- it may be different the next time the machine dials in - but in most cases it stays the same. The reason is that the ISP only needs one IP address for each modem instead of one IP for each actual customer.
Since recalling the infinite variety of numbers that make up IP addresses is difficult if not impossible for all of your favorite websites, and since IP addresses often (although infrequently) need to change, servers typically have text-based names; dubbed domain names e.g., www.websitemagazine.com. It is easier for most of us to remember www.websitemagazine.com than it is to remember 126.96.36.199.
The name www.websitemagazine.com actually has three parts:
1. The host name ("www")
2. The domain name ("websitemagazine")
3. The top-level domain name ("com")
Domain names within the ".com" domain are managed by VeriSign (they also manage the ".net" domain name). Other registrars manage the other domain extensions (like .pro, .biz and .org). VeriSign creates these top-level domain names and ensures that all names within a top-level domain are unique - making sure that you and I don't think we simultaneously own websitemagazine.com. VeriSign maintains detailed contact information for each domain name and even operates the "whois" database to making researching which domain is which easier.
So what brings everything together? Domain name servers (DNS) map the human-readable names to the IP addresses. You are probably familiar with DNS if you've ever purchased a domain and needed to change the DNS to your web host of choice. DNS servers are simply databases that map names to IP addresses, and they are distributed all over the Internet. Most individual companies, ISPs and universities maintain small name servers to map host names to IP addresses. There are also central name servers that use data supplied by VeriSign to map domain names to IP addresses.
If you type the URL "http://www.websitemagazine.com/web-server.htm" into your browser, your browser extracts the name "www.websitemagazine.com," passes it to a domain name server, and the domain name server returns the correct IP address for www.websitemagazine.com. A number of name servers may be involved to get the right IP address. On a UNIX machine, you can access the same service using the nslookup command. Simply type a name like "www.websitemagazine.com" into the command line, and the command will query the name servers and deliver the corresponding IP address to you.
That’s how Web servers work!