66 points · by telemachos · 15y ago · 55 comments
Really though, everything shown can be easily replicated with a bit of Connect middleware, and it'd be cleaner. I don't see the point?
For an example of using ejs with Strata, take a look at the source to the Strata website: https://github.com/mjijackson/stratajs.org
https://github.com/LockerProject/Locker/blob/master/Ops/webs...
And tends to end with around 40 lines of checking URLs and other various bits of information to know which middleware can be chained in, and in which order that doesn't cause them to conflict with one another.
If Strata can solve this mess, then it's definitely a step up in my opinion.
And it's much nicer to use than the http module: layerable middleware, streaming responses, routing...
What I don't get, is you have to fight with Rack to get anything close to async, yet here comes a web framework for an async environment modeled after Rack, go figure.
I assume (meaning I'm about to make an ass out of u & an ass out of me) the answer is to pass a stream in place of the "Hello world!" string, but that would cause hell with any middleware expecting a completed response.
The main advantages/differences over Connect/Express at this point are:
- Patterned after WSGI/Rack. This implies some significant differences in the API.
- Built on node 0.4; takes full advantage of streams.
- Built-in support for streaming multipart parsing/file uploading (uses node-formidable's parser).
- Built-in support for gzip encoding, URL rewriting, and URL mapping.
- RFC-compliant support for content negotiation using the Accept, Accept-Language, Accept-Encoding, and Accept-Charset HTTP headers.
- A specification with middleware to enforce it.tjholowaychuk has done extensive testing/benchmarking of Connect/Express. I'd really like to see some benchmarks and code coverage.
Strata gives you a sane environment modeled after the WSGI/Rack/CGI model, which has been the backbone of web servers for years.
Also, Strata's API matches the WSGI/Rack model. This may seem small, but in practice it's a significant benefit.
Add to that the list of features cited in the release email, including native support for streams in node 0.4.
From what I understand, a Node/V8 instance really only utilizes a single CPU, yes? As a request does I/O, some other piece of code is executed until (some time after) the async I/O completes. A CPU can be effectively timesharing over several pseudo-threads, but to use a SMP chip/server, you have to run multiple instances, with a front-end load balancer. I guess this would drive one towards an external session data solution, barring some kind of sticky session and a reason to be sticky.
I'm no fan of Node, but even if you have $100k machine running the JVM with a thousand threads you will (if successful) eventually need a second machine, and a third, etc. Not to mention persistence (what if you need to restart the app server?).
Sessions belong in a database of some kind unless you can get away with signed cookies.
for java and scala
I'd love to hear the reasoning for the differences between the two.
(Disclaimer: I started JSGI)
This is an API incompatibility that cannot be ignored. The most developed lib I've seen up to this point to get JSGI working on node (https://github.com/kriszyp/jsgi-node) isn't able to get asynchronous responses working properly. Instead, it just does a body.forEach (see https://github.com/kriszyp/jsgi-node/blob/master/lib/jsgi-no...) to write each piece out to the response synchronously.
Copied and pasted from https://github.com/mjijackson/strata/issues/2.
In fact, by connecting an input stream to an output stream (forEachable objects), the underlying code automatically enables Node's pipe like behavior.
Check out this example: https://github.com/olegp/common-node/blob/master/examples/ht...
There have been lots of discussion on asynchronous/streaming in JSGI, but perhaps it hasn't made it's way into the specs you've looked at. Promises are one way, fibers are another.
Foreach-able "streams" w/ promises and Node streams are pretty much equivalent (and yes, JSGI w/ promises can handle back pressure, though I'm not sure if there are any public implementations yet)
Server nginx/0.7.67
I can't tell if it's the case here, but I get a little unnerved when a web framework doesn't even use it for their website.The Server header reports nginx because it's sitting behind a reverse proxy on Heroku.