Using node.js in production? - javascript

To those in the business of web development, is node.js ready for production use? How reliable is it?

Node.js is absolutely ready for production in terms of things like system stability, power, and performance. However, some features might still change before version 1, and there are a lot of mature tools on other platforms that don't quite exist yet for node (though new things are popping up on node every day).
Several businesses are already using node.js in production. For a few, check out https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node

outloud.fm uses it, seems to work pretty well
I don't run that site though, so I can't speak from personal experience

Does it do what you want?
Does it run like you want it to without crashing for your needs?
Then it's production use ready.

Related

Is there a way to use jsdom in a foolproof sandbox?

I'm using jsdom to load web pages with my Node.js application.
Sometimes, I don't get the full DOM because some web pages use scripts to load their content dynamically after the onload event is triggered.
jsdom deactivates the execution of these scripts by default because it would cause a security flaw, as stated in their documentation:
The jsdom sandbox is not foolproof, and code running inside the DOM's < script>s can, if it tries hard enough, get access to the Node.js environment, and thus to your machine
I was wondering if there was a way to make it foolproof using some workarounds? I'm kind of new in Node.JS development and as it is a single threaded environment, I'm not sure how I can create a secured sandbox.
NodeJS does not have this kind of security out of the box. If you'll be running untrusted, 3rd party code in your Node engine, you'll need to use operating system tools to isolate and secure it.
Things you could look into:
Using a chroot jail.
Using a virtual machine.
Using a Docker container.
Using the jailed sandbox library (haven't used it myself, but it has good reputation).
Do some research on these approaches and their limitations, and see which suits your purpose best. A virtual machine will offer the greatest isolation and least chance for error, I think, but it has the greatest overhead. All approaches could be made to work.

Audio manipulation using node.js

My team has been using the Web Audio API/Getusermedia in a product and we are going really well with our chrome and firefox users. But we still have a large base of users that we would love to reach, but due to technology barriers, we still can't (mostly, those are IE users), as their main browser does not support the technology, and they do not or can not change to a modern browser.
We are planning to get to those users, but we don't want to go to Flash, Flex, Silverlight or anything similar.
So, thinking about solutions, I thought that maybe I could pass by this difficulty if I moved the audio manipulation, from the browser to the server. NodeJS was the first answer when trying to figure out how to do it.
Would it be possible to be done using NodeJS? Are there any libraries available that would help us accomplish this? Are there any other technologies that would allow me to do this?
Thanks anyone that could help.
It could easily be done. Node is simply an IO engine designed for rapid response. If it needs to happen in real time then I imagine latency would be a usability-breaking issue due to networking restraints. If it doesn't, then I think it would be a great solution! :)
Either way here are a couple related resources
https://www.npmjs.org/package/webrtc.io <- latency optimization library intended for work with media streams
http://wac.ircam.fr/ an upcoming conference (Jan 2015) dedicated to the types of problems you are dealing with.
http://www.sitepoint.com/5-libraries-html5-audio-api/ A few web libraries for use with audio. #3 and #4 look like they are related to what you are trying to do
You can try using this (is in development):
Node Web Audio API
https://github.com/sebpiq/node-web-audio-api
Installation
npm install web-audio-api
Demo
node test/manual-testing/AudioContext-sound-output.js

How can I debug/step-through/watch my Node.js in Windows?

Sorry, maybe this belongs in programmers stack exchange, but I'm trying to get in to Node.js web development, and I really need to ability to step through my code in order to gain a deeper understanding of just what is happening in all the tutorials I'm using.
I've done some googling, but it looks like everything is written assuming you're in a *nix or OSX environment.
I've tried node-inspector, but I'm being greeted with errors whenever I try to run process._debugProcess() with the PID.
JetBrains WebStorm is relatively inexpensive IDE you can use with Node.js, which is quite feature rich considering the price.
Watch the demonstration video and you should get an idea to see if it's the kind of thing which could be helpful.
http://www.jetbrains.com/webstorm/
Alternatively you could use Eclipse and get this up and running.
https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger

How much does it cost in terms of performance to use console.log in nodejs and in browsers?

Let's say you log certain things on your nodejs app or on a browser.
How much does this affect performance / CPU usage vs removing all these logs in production?
I'm not asking because I'm just curious how much "faster" would things run without it so I can take that into account when developing.
It can cost a lot, specially if your application is hardly based on a loop, like a game or a GUI app that gets updated in real time.
Once I developed an educational physics app using <canvas>, and with logs activated withing the main application loop the frame rate easily dropped from 60fps to 28fps! That was quite catastrophic for the user experience.
Overall tip for browser applications is: Do not use console.log() in production for loop based applications specially the ones that need to update a graphical interface within the loop.
For Node: is node.js' console.log asynchronous?
I imagine it's implemented similar in some of the browsers.
I'm not familiar with node.js, however it's typically not a good thing to log anything except critical errors in a production environment. Unless node.js offers a logging utility like log4j, you should look at something like log4js (haven't used, just first google response)

Executing JavaScript with Python without X

I want to parse a html-page that unfortunately requires JavaScript to show any content. In order to do so I use a small python-script that pulls the html-code of the page, but after that I have to execute the JavaScript in a DOM-context which seems pretty hard.
To make it even harder I want to use it in a server environment that has no X11-server.
Note: I already read about http://code.google.com/p/pywebkitgtk/ but it seems to need a X-server.
You can simulate a browser environment using EnvJS. However, in order to make use of it, you will have to embed some kind of JavaScript runtime (e.g. Rhino) in your program (or spawn one as an external process).
You could try using Xvfb to have a fake frame buffer, so you won't need to run X11 (though it may be a dependency of Xvfb on your system). Most rendering engines don't have a headless mode, so something like Xvfb is necessary to run them. I used this technique successfully using XULRunner to navigate web pages, though not from python.
I'm still trying to figure this out myself, so take my answer with a grain of salt.
So far, I found http://blog.motane.lu/2009/06/18/pywebkitgtk-execute-javascript-from-python/, which describes the use and the quirks of Pywebkitgtk by someone who has similar needs to what we do.
Later, however, the writer of that blogpost discovered that he can't get it to work with Xvbf, so he hunted some more and found a Qt webkit (possibly in Qt itself, if I understand correctly) http://blog.motane.lu/2009/07/07/downloading-a-pages-content-with-python-and-webkit/. Apparently it's a much better solution than PywebkitGTK.
Naturally, I'll be looking into the other solutions offered here--but I wanted to bring up the Qt solution, because to me, it seems the most likely candidate for what I want to do...and if not, then perhaps it will be for someone else, looking for an answer to this question! :-)
I use VNC or Xvfb for this purpose, combined with Firefox. After experimenting with the two, I settled on XTightVNC. We use it to create screenshots on demand for various test purposes. It's nice to use one of these because you're executing it in an actual browser, same as a user would be (though most users probably won't be using the same OS as your server).
The handy thing about using VNC is that you can connect remotely to set up and test the browser when needed.
This might help: http://code.google.com/p/pyv8/

Categories

Resources