Flutterby™! : web servers

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

web servers

2003-10-02 15:21:27.938903+00 by Dan Lyke 9 comments

A few years ago, Tom Duff said something about writing one's own web server, and I thought "why, there are so many out there already?" Yesterday afternoon at 3:30 I realized that for any given request to my motor controller I had 3 select() loops running, one for my controller daemon, one for my CGI scripts which communicated with it, and one in the web server which was running the CGI scripts. And I had reason not to trust the web server.

By 8:30 yesterday evening, including a commute through post-Giants game traffic, a stop at the bookstore to pick up the latest from Neal Stephenson[Wiki], and dinner, I had the fastest damned web server I've ever seen (it serves all its static pages internally). This morning on the ferry I (think I) finished integrating the motor control code into it.

Something about the way Tom says things often makes my first reaction "that's silly!", and yet every time I've had that reaction he's been right. Thanks for the kick.

[Edit: Made the times Tom's been right more emphatic.]

[ related topics: Dan's Life Software Engineering Work, productivity and environment ]

comments in ascending chronological order (reverse):

#Comment Re: web servers made: 2003-10-02 20:41:21.401534+00 by: ebradway

Did you implement it in C? I've got code around here someplace that implements a HTTP 1.0 server in Perl in about 20 lines (well documented and non-obfuscated). In C it takes a little more because parsing the requests is a little more challenging.

Making your own webserver makes alot of sense when your server is just front-ending something. It's even easier when it is unlikely that you'll get more than one user at a time. Session management becomes easy and alot of the stuff that's annoying about writing CGIs goes away entirely.

Makes you re-appreciate the protocol and wonder, once again, why IE takes up 50MB of disk space...

#Comment Re: web servers made: 2003-10-02 20:55:15.619646+00 by: Dan Lyke

I did in C++ because I had a few different type of request objects, files, objects which queried the system state, and objects which then responded to devices.

But a C version would be really easy now that I've got this much done, there are only a few places I use virtual functions, other than that it's all C.

And the object system understands interrupted calls (if two requests want to move the motor at the same time), stuff like that.

What blew me away most was that programming yesterday afternoon was just a matter of laying down the code as fast as I could type. I haven't really hit that stage in a long time. Sure, there were a few times when I was doing totally brainless stuff for clients during the Coyote Grits[Wiki] days, but it's been writing video codecs in assembly language back in '95 or '96 since I've been that so totally in the flow.

Charlene commented that it wasn't like I was withdrawn or anything, I was able to help with dinner and stuff, but I was soooo focused.

This is why I became a coder. Damn I need to get back there. Good code is a drug.

#Comment Re: web servers made: 2003-10-02 20:58:21.267355+00 by: dws

Ah, but can it send email?

#Comment Re: web servers made: 2003-10-03 11:26:53.941318+00 by: meuon

Good code is a drug - Flow Happens.

What I find amazing is your ability to get in the flow in spurts, in traffic, etc.. I'm at nowhere near your level, yet it's something I can only do in long sessions, headphones (or the Fenders) cranking.. and little interruptions can kill it. Kudos on your webserver.

#Comment Re: web servers made: 2003-10-03 20:17:29.495263+00 by: Shawn

meuon; I have pretty much the same problem with interruptions - with everything in life, not just coding. That's why I started my BrainBox project. (A ToDo List/Task Tracker.) The idea is that I can come back to anything and pick up pretty much right where I left off, at something near the same speed. Of course, this doesn't help with the little interruptions, but I think having a structured plan to refer back to will help even with that.

And I'll second the kudos.

#Comment Re: web servers made: 2003-10-03 20:45:36.1226+00 by: Dan Lyke

Dws: Snicker. That was kinda the point, despite being a lean and mean web server relative to Apache, webfsd had evolved nearly that far.

#Comment Re: web servers made: 2003-10-03 21:44:49.557231+00 by: Dan Lyke

Of course, duh, it's only now that I realize that Tom gives away the source for his.

#Comment Re: web servers made: 2003-10-05 03:41:35.021364+00 by: TheSHAD0W

Writing a web server in Python is a surprisingly easy task. The reference tracker server for BitTorrent runs like a modified web server.

#Comment Re: web servers made: 2003-10-05 04:12:33.670176+00 by: markd

I like the bizarro language webservers, such the one in postscript or the one in awk.