Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do web servers work?

Tags:

webserver

I am a .NET developer and I've been working in C# for almost 3.5 yrs. I want to understand how the web server works and I don't mean a 65,000 feet overview. I want to understand the inner workings of a web server.

What are some good resources to learn the nuts and bolts of how a web server works?

like image 879
Kapil Avatar asked Jan 17 '09 19:01

Kapil


2 Answers

If you really want the nuts and bolts of how a web server is supposed to work read the HTTP Spec.

A good tool would be be fiddler. Using this tool browser about the net and examine the conversation between the browser and the servers. Combined with a reading of the HTTP spec this will give you some good insight into what is really going on on the net.

If you want to go further you need to decide which web server you spcecifically want to understand better. For example, if you want to understand IIS6/7 then David Wang's blog is a good place to search for under-the-hood details.

like image 176
AnthonyWJones Avatar answered Sep 22 '22 06:09

AnthonyWJones


Web servers are very simple to implement, and there are several tutorials on how to build one.

Here is such a tutorial for C#: http://www.codeguru.com/csharp/.net/net_general/article.php/c4603, this tutorial is nice because it implements the server down to raw sockets and HTTP header passing, so you learn a lot about the HTTP Spec. Unfortunatly, some tutorials and libraries abstract this away.

Implementing on yourself allow you to touch many topics:

  • Socket programming
  • HTTP Protocol (GET / POST)
  • Multi-threading

And once you get a basic webserver built you can extend your server and protocol into your own web-framework. should make a really cool pet-project.

I have done just this for Java, C++, and Python.

like image 43
mmattax Avatar answered Sep 19 '22 06:09

mmattax