The author of Nginx on why V8 is not suitable for web servers
translate.google.com
translate.google.com
Handling out of memory errors is a hard problem. At the point when you can't allocate more memory you are busted in most languages. For example in C a slightly deeper function call depth can cause the stack to expand at any point. If that point coincides with you running out of memory then you are busted. No program can keep running with a broken stack.
If V8 were capable of recovering from out-of-memory errors then you would still have to go through all of node and all the native libraries that it uses and check that they can handle any allocation failing.
And if V8 handled out-of-memory errors with exceptions then you have two choices. Either make the exceptions uncatchable, in which case the JS program running in the server has no way to recover and is probably in an inconsistent state. Or make the exceptions catchable, in which case there is no guarantee that any memory will ever be freed up and you are back to square one.
I think it's possible to make V8 more resistant to out of memory situations. I don't think it's possible to make it bulletproof, and I don't think there are many server apps that have this property. Do people run Java servers in such a way that they are often getting out of memory exceptions, recovering, and then continuing to serve? I don't think so.
In practice the way most servers work is that you give them plenty of memory and you write your server app in such a way that it does not use unlimited memory.
If there are non-out-of-memory errors that V8 is failing to recover from then these are bugs and should be reported. I can't think of any examples off-hand.
As far as the other comments go they seem to assume that you will want to use a V8 context per connection. Node uses one V8 context for all connections, so the comments don't apply. Context creation has been speeded up a lot since the article was written, but this is only for the browser. Node doesn't need it.
node.js (one process for many requests) is a different model than the author is considering; no matter its (dis)advantages, integrating it into the server is not nearly as advantageous as for a process-per-request model (like mod_php).
1) The fact memory allocation might crash the process is a serious problem. Is this still the case?
2) The fact that garbage collection is still stop-the-world may be a problem for server availability. Are we able to call the generational collector from node, or no?
Things that don't involve node:
The ability to create multiple objects in different contexts. Sysoev is thinking of the "scripting" model, like PHP, which is not how Node does things. Node just runs one process to handle thousands of requests, not thousands of processes or threads. There is no need.
for (int i = 0; v8::V8::IdleNotification() && i < 3; i++);
to: for (int i = 0; v8:: V8:: IdleNotification () & & i <3; i + +);Edit: By 'code tags' i mean literal <code> tags.
I still remember being able to play a game with one of my friends where we'd translate a sentence to German then back to English and laugh at how mangled it was…
"Number of games: We, and I have learned how to use the means for translating the German text in English is still a way of encoding their friends to play with a smile. .."
Before I actually noticed that, "snapshot'ov" actually made me laughed, genuinely (mis)taking it for some sort of pun.
Edit: This was written when the title was "The author of Nginx on node.js and why V8 is not suitable for web servers". It's since been changed.
Remember, 'does rails scale'? :|
Nginx and Nodejs are very different. Nodejs was built on V8 from the beginning, while it would have to be grafted into Nginx somehow. Nodejs isn't Chrome but it's willing to pretend that it is - nginx isn't.
Seems like process isolation a la fastcgi is the practical way to go, unless the V8 team itself wants V8 to be embeddable in a "reliable" way (meaning, it recovers from its own errors without corrupting the process it's embedded in).
For more traditional uses that want something less hackish, erlang for example, crashes only a single thread not the entire vm. Functional programming languages in general like haskell and erlang are interesting for backend core services.
Everything is always a work in progress.
Granted thats assuming you can actually run a fastcgi/v8 setup, I've never looked. I wonder how hard a mod_v8 for apache prefork would be.
malloc says no if you set a ulimit in your shell. I do this on the desktop to stop myself from shooting myself in the foot. (Recent kernels also let you turn off the overcommitting behavior.)
I remember when nginx first came out (the web server that the author built) and the biggest barrier to adoption was the fact that all the documentation was in russian. Online machine translation did not produce understandable content at that time.
There is a word "integration" that the author of the post forgot to put in.
Why is Google V8 is not yet suitable for integration into servers.
Does someone want to change the title to be clearer?
He has his own set of requirements which by no means applies to _all_ webservers.