thephoeron / LLTHW

Learn Lisp The Hard Way source-code and full book text
MIT License
344 stars 56 forks source link

Migrate LLTHW Web App to Asynchronous Server #11

Open thephoeron opened 9 years ago

thephoeron commented 9 years ago

The user experience for LLTHW could be vastly improved with an asynchronous web application; currently the application runs on Hunchentoot—a thread-per-request server—which is inherently greedy in terms of system resources. While useful for web applications that need to validate and process arbitrary user data in an isolated environment, LLTHW only needs to serve up content. An asynchronous web application will thus be able to maximize available system resources and provide a faster, stabler experience for all users even under the heaviest traffic spikes (such as the Hacker News fiasco this past July), and buffer against DDoS attacks.

This will also allow for a more sensible use of 3bmd to provide live-updated content, without specifically re-parsing each Markdown document for each user on request; only one copy of each parsed Markdown document needs to live in memory, which can be accessed sanely by all clients. As such this ties in with issue #3 to reduce application memory usage.

The most mature Common Lisp asynchronous server and web application framework appears to be Wookie. It is still in Beta, but it seems to be worthy of production use-cases, such as the official Wookie documentation, and the Turtl platform.

Alternative suggestions are welcome.

priyadarshan commented 9 years ago

woo could also be a possibility? https://github.com/fukamachi/woo/

thephoeron commented 9 years ago

Yeah, I've been looking at Woo and I think it might be a better choice; the switch to the new libuv backend on CL-ASYNC has tripped me up on a few projects, and caused me trouble at work. Woo is still listed as "alpha-quality", but the performance is looking good. It will be worthwhile to spool up a demo of LLTHW running on woo---and since it's the holidays I might even have time to do that this week!

priyadarshan commented 9 years ago

Neat, I can't wait to see the demo!

Thank you so much for llthw. It is extremely helpful.

priyadarshan commented 9 years ago

By the way, this simple thread was quite helpful in clarifying to me the differences between woo, wookie et al. https://www.reddit.com/r/lisp/comments/2ofkfh/newbie_writing_a_small_lisp_program_for_work/cmn06l4

thephoeron commented 9 years ago

Alright, reading over the source code for Woo---and it looks like I can get up and running with a dispatcher app function, same as Clack, and the request handler functions simply need to return a list of status code, content-type, and body of the response. Shouldn't take too long.