One of my favorite movies is The Usual Suspects, which is about a murder mystery surrounding a mysterious figure named Keyser Söze (SPOILER ALERT: I may give away some clues about the movie in this article. You’ve been warned). At one minor point in the film, a half-dead Turkish man lying in the hospital says that he saw Keyser Söze, and they bring in a forensic sketch artist to draw the face based off of his description. I found this scene to be one of the most interesting scenes in the movie, since the forensic sketch artist had to translate a poor description of a man in Turkish into a highly detailed drawing.
I saw this around the same time that I was struggling to learn how the Internet really worked. I loosely threw around words like “client-side” and “server-side” without really knowing what they meant. Once I saw this part of The Usual Suspects, everything seemed to make sense. The analogy of a forensic sketch artist and a dying Turkish witness seemed to work really well for the relationship between the browser and servers.
The Turkish witness and the forensic sketch artist
To help explain the ideas of clients and servers working over the Internet, let’s imagine a Turkish witness named Serge talking to a forensic sketch artist named Clementine. Clementine asks Serge to describe a person, and Serge responds with a Turkish description of the person, which Clementine translates into an image of that person.
In the world of the web, Clementine is your browser, like Mozilla Firefox or Google Chrome, sometimes called the “client” or “front-end”. The client is responsible for requesting web pages, and translating the response into a human-readable web page. Without Clementine, we would have a very hard time asking Serge to describe the person, since his response would be totally in Turkish. It is possible to request web pages without a browser, and receive a response, but the response would be all in HTML and not mean much to us. Brian J Brennan seems to be cool with it though:
Now that I'm leaving mozilla I don't feel bad switching back to my favorite browser, `telnet` + my imagination pic.twitter.com/0S7LenenNS— Brian J Brennan (@brianloveswords) November 21, 2014
This request-response model is the way that pretty much all things on the web work. The protocol for requests and responses is known as HyperText Transfer Protocol, or HTTP. HTTP is the glue that connects servers to clients. It uses URL’s to locate specific servers and ask for specific information. Did you ever notice that every URL starts with
http://? HTTP is also responsible for carrying the response to the browser, whether that’s the successful response of the HTML page, or a 404 error, which you may have seen before. 404 stands for the code HTTP uses to say “Resource not found”. This would be like asking Serge to identify someone he could not remember. The typical code for “Success” is 200, which would mean Serge remembers the person and can describe him.
BONUS: Deep dive into the dynamic web
/2014/12/02/httpster.html that it sends to the client whenever it’s asked.
My site can work this way because it is not very complicated, just a few HTML files that I wrote sitting somewhere in the cloud at the address
In terms of server-side magic, the first server I ever created was a Node.js server that I learned from reading the Node Beginner Book. Node is nice for learning some server side things for the first time because you actually have to create the HTTP server and handle the requests and responses manually. If you are more of a Python guy, or just want to start a server from a directory on your computer, check out this short article on getting that started.
What kind of metaphors do you use to understand the Internet? Would you say it’s more like a kitchen or the post office? Let me know in the comments below!