29 May 2017

Everyone should build a webserver

A great way to get good at writing server side code is to write server side code. I suggest everyone try to create a web-server. You can start by just trying to serve some documents with a simple application that leverages tools like Sinatra or Flask. However, if you really want to learn something, start from the Socket layer and work your way up. It is a lot more difficult than it sounds, but its not so difficult as to be impossible.

What you will gain from an experience like this is a very deep understanding of how most servers work (more or less). The more sophisticated you make your web-server the more your are going to learn. First you have to deal with the basics, like the HTTP protocol, locating files, sending files back to users, etc. Then you need to handle more complicated things like non-ascii content, multiple simultaneous requests, following symlinks, etc. The list of things you would need to compete with a tool like Apache or NGINX is very long. But if you can develop insight in developing those features it will go a very long way to growing your overall skill set as a developer.

If you don't feel like finding your own path on this topic I suggest you read Concurrent Programming in Java the examples result in a simple web-server.