Skip to content

Instantly share code, notes, and snippets.

@zimbatm
Created June 28, 2010 21:41
Show Gist options
  • Save zimbatm/456395 to your computer and use it in GitHub Desktop.
Save zimbatm/456395 to your computer and use it in GitHub Desktop.
A mongrel2 evening, investigating a bug

== In short ==

I only found how to reproduce the bug with more details. A patch is not provided.

Chromium on 1st request, only loads the page at the given url as expected.

On refresh, it will first issue a GET /favicon.ico request, which is forwarded to the nginx proxy. Then GET /tests/index.html is issued. Because the connection is kept-alive by nginx and because mongrel2 doesn't inspect the traffic (I guess), the GET /tests/index.html will be forwarded to nginx on the same channel, bypassing the mongrel2 routing.

== In long ==

First I had to install a proper OS. ArchLinux in a VM did the trick.

Tools used: chromium, wireshark and netcat

Start chromium and wireshark, start listening with wireshark, make the two http requests, stop listening in wireshark => analysis

Use "follow tcp stream" on the packets to get the details of the tcp connections, write the connections to files.

Strip the http responses from both connections and use netcat to reproduce the bug:

cat dump1-headers.txt | netcat -t mongrel2.org 6767

cat dump2-headers.txt | netcat -t mongrel2.org 6767

I tried to use telnet first to make the requests by hand, but apparently mongrel2 doesn't understand headers that terminate only with \n. The connection is then kept alive for an indeterminate time. I think the connection should be dropped if the request is not understood or at least in a short time unless the connection is promoted to keep-alive or ajax-like streaming or flash-socket or ...

== Github is my blog ==

mongrel2 is interesting to me because I think people should have the option to self-host easily. There is very few people selling web software for the mass. The only example I have and that I use is feedafever.com . Things like that should be much easier to install and language-agnostic. So I'm keeping an eye on mongrel2 even if I'm not sure if it's the direction zed wants to take.

Regarding mongrel2 design, I think I'm supposed to rant on the routing mechanism, but I won't because it looks actually pretty sane to me. I'm just not convinced pattern-matching is necessary, but I view mongrel2 as a reverse-proxy, not having understood the 0mq approach. What I find more controversial is the sqlite3 serialization. Not that I favor configuration files, but because I think mongrel2 is potentially dynamically configurable over it's various communication channels. I guess sqlite3 is the influence of fossil.

Finally, mongrel2 makes me think of haproxy for some reason. Haproxy is a layer 4+7 proxy that uses epoll and friends and is more mature than nginx. It doesn't serve files except the 40X and 50X pages but does have more options wrt backend communication. It also has a configuration format that is non-recursive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment