I have a requirement to integrate a web server into an embedded device running Linux and am in the process of evaluating OSS and commercial offerings.
System requirements at not particularly tight: – Memory running set of up to 10MB, – Can spare 20%+ of a 300MHz ARM and more in bursts, – UI will be in jQuery and JSON, so would like to feed several hundred KB pages linking a dozen CSS and JS files in well under a second.
Feature requirements: – HTTPS support, – A 10+ concurrent connections, – Well-tested against DOS attacks.
Would much appreciate an integrated XML parser to base a SOAP implementation on.
Not a fan of PHP, but not certain about server-side Javascript either, and unfamiliar with Lua. So looking for suggestions for templating solutions, perhaps a Python-based stack.
Already reviewed discussions on SO and lists on Wikipedia. Am aware of thttpd, Mongoose, Cherokee, Appweb.
At this point I invite detailed technical suggestions and discussion of implementation choices, based on first-hand experince in production quality deployment.
When it comes to a simple python server stack, the combination I’ve heard most often from within the community for lightweight implementation is CherryPy (to provide the thread-pooled WSGI server) with Werkzeug (to create the basic structure of the app) Both are very slightly different takes on WSGI that speed development time considerably.
There some pretty good notes outlining basic python framework comparisons (albeit not in an embedded environment, but the emphasis was on lightweight deployments.) at this question, in which Alex “the Machine” Martelli weighed in for these two.
If you can afford the overhead of the python interpreter (which I am assuming is ok as you included it in your eligible list), werkzeug is an excellent way to setup an app that consists of simple endpoints. Responses can be mimetyped inline to aid in outputing your UI libs (Jquery, etc). There are awesome examples on the Werkzeug docs.
One of the best resources I’ve been able to find on comparing WSGI servers (to satisfy your need for high concurrent connections and DOS survivability) can be found at Nicholas Piel’s blog post on the subject, where CherryPy ranks in as one of the best “bang-for-your-buck” resources to speed-wise. The WSGI server in Cherry is deployment ready, and this can be used as the server process providing the environ to your Werkzeug app so you don’t need to implement something heavier like Apache with mod_wsgi. Cherry is easily capable of an average around 2000 r/ps with response times well under a second while under moderate load.
Since I don’t know what kind of device you will be deploying this on, I should mention of course that both of these platforms are regularly updated, so this too should be considered if for whatever reason allocating network resources to update the device is impractical.
By combining python’s
minidommodule (v2.6+) with the endpoint routing in Werkzeug, you should also benefit from very good development speed. Constructing a complex url schema is simple using Werkzeug’sMapfeature, and the tutorial at their documentation page gives an awesome rundown on this. Between the two, it shouldn’t be too difficult to get your web service up and running.