directorger.blogg.se

What is js node
What is js node












Node.js is also finding more and more non-service uses.

what is js node

For a somewhat humorous and unabashedly negative take on this, see this guy. But as soon as you try to put big time load on your service and have it run 24/7, you'll quickly discover the motivations that push big sites to have well baked, hardened C-code like Nginx fronting their site and handling all of the static content requests (.until you set up a CDN, like Amazon CloudFront)).

what is js node

For lower-load services and development, that's probably fine. "app.use(express.static(_dirname + '/public'))". Reading frameworks like Express makes it seem like the standard practice is to just serve everything through one jack-of-all-trades Node.js service. I've yet to find a Node.js serving framework that seems fully baked it may exist, but I haven't found it yet and still use ~150 lines in my hand-rolled "production.js". 2) Using a framework like Unicorn that will manage the worker processes, recycle them periodically, etc. For requests that hit the actual node service, the webserver proxies the request through. The webserver can efficiently serve static content, access logging, rewrite URLs, terminate SSL, enforce access rules, and manage multiple sub-services. It is solved via two complementary mechanisms: 1) Putting Ruby on Rails/Node.js behind a dedicated webserver (written in C and tested to hell and back) like Nginx (or Apache / Lighttd). To be fair, Ruby on Rails has this exact problem. For a "serious" production service, you also need to be prepared to throttle incoming connections and do all the stuff that Apache does for PHP. With Node.js v0.6.x, "cluster" has been integrated into the platform, providing one of the essential building blocks, but my "production.js" script is still ~150 lines of logic to handle stuff like creating the log directory, recycling dead workers, etc. Node.js in production is definitely possible, but far from the "turn-key" deployment seemingly promised by the documentation.

what is js node

There's an enormous energy of ideas flowing into Node.js right now, and working in it exposes you to all this thinking - great mental weightlifting. And you will daily rethink your own understanding of "best practice" and the patterns of well-structured code. JavaScript, despite its oddities can be a great language to code in. Forced to choose one word to describe Node.js, I'd say "interesting" (which is not a purely positive adjective). I use Node.js at work, and find it to be very powerful.














What is js node