« Reading List: Men in Black | Main | Tom Swift in the Caves of Ice Now Online »

Monday, May 30, 2005

Solar System Live Goes Stateless

For more than a decade, the dynamic image generation resources at this site: Earth and Moon Viewer, Solar System Live, and Your Sky, have returned custom Web pages with dynamically generated embedded images by returning HTML including a link to an image kept in an ephemeral files directory. Images in this directory are intended to be immediately fetched when the requester's browser displays the page, and are purged automatically after a decent interval has elapsed.

This architecture has worked well, but it has some drawbacks. First of all, despite every standards-compliant way to inform downstream caches that the dynamically generated images are ephemeral and should not be cached, many of them (hello, Acephalics On-Line!) attempt to cache the images anyway and generate thousands of moronic HEAD requests to see if the images remain in the cache long after they've been downloaded by the users who requested them and consigned to the bit bucket. Then there are the "creative" users who, unable to figure out how to request a dynamically generated image delivered directly to their Web application, parse the HTML returned from the request and embed the temporary image name in a Web page or, even worse, automatic retrieval program which hits the site over and over. One particular idiot has been requesting a long-gone image from Earth and Moon Viewer every five minutes for more than three years; and the fact that I've blocked the IP address from which these requests originate has not deterred them from raining upon my firewall.

These are more or less minor annoyances compared to the constraints the temporary image architecture imposes on deployment of a server farm. When user requests are load-balanced across two or more servers, absent some scheme for session persistence, there's no way to ensure the reference to the dynamically generated image referenced in a reply page will be directed to the server on which it is actually stored. One can cope with this (as I currently have) by session persistence gimmicks, but doing so adds complexity to the load balancing process, constrains the ability to spread load across servers, and marginally reduces the fault tolerance of the server farm.

Today, I put a new version of Solar System Live into production which replaces the temporary image scheme with entirely stateless dynamic image requests--all information required to generate the image embedded within a reply page is encoded in the URL specified as the src= of the image inclusion within it, and hence the image can be generated by any server to which it is directed. This eliminates the need to cache temporary images on the server, and removes the temptation for users to dig their locations out of reply documents and make foredoomed links to them.

This is a major re-architecting of this Web service--I've kept the old version around in case somebody has a legitimate need to access the cached images until they update their client program. The new version also returns 100% compatible XHTML 1.0, and all the static documents and help files associated with Solar System Live have been validated as XHTML 1.0 compliant. If all goes well, I'll migrate Your Sky and then the biggie, Earth and Moon Viewer, to the new architecture.

Posted at May 30, 2005 00:41