News for hackers. Stuff that matters.
Re:Node.js in Flame Graphs by remon on Wednesday November 19, 2014 @12:21PM (#8631259)
I wonder what the thought process was behind moving their web service stack (partially?) to node.js in the first place. For a company with the scale and resources of Netflix it's not exactly an obvious choice.
Re:Node.js in Flame Graphs by personZ on Wednesday November 19, 2014 @12:33PM (#8631343)
Netflix seems to operate like a tech start-up that is trying to glue together a ragtag collections of often unsuitable solutions because of limited funding. It is a deeply perplexing company.

Similar is LinkedIn, as an aside -- despite being fairly formidable now, I regularly have entire feeds disappear, their caching is abhorrent, they can't markup text properly, and so on. It seems very amateur hour, yet they regularly publish "how it's done" documents that see wide applause despite often completely contradicting their prior missives.

Re:Node.js in Flame Graphs by general_failure on Wednesday November 19, 2014 @12:52PM (#8631466)
Netflix overhires quite a bit. They also pay their (very good) engineers very high salaries (possibly highest in the valley) which results is very low attrition.

The net result is a lot of engineers having a lot of time and all these engineers experiment away on technology. In fact, they have quite a bit of NIH syndrome internally because the engineers have nothing to do.

Re:Node.js in Flame Graphs by eikenberry on Wednesday November 19, 2014 @01:03PM (#8631530)
I don't think you have those reasons in proper order. I think the ability of the engineers to experiment and use new tools is why they have the high level of retention. I've seen plenty of places that pay much higher than the competition yet have very high turnover due to the a conservative culture which dictates the tools and doesn't encourage experimentation.
Re:Node.js in Flame Graphs by general_failure on Wednesday November 19, 2014 @01:50PM (#8631812)
"An idle mind is a devil's workshop". I have seen this over and over again when you give engineers a free run. They micro-optimize things. They start rewriting javascript to c++ and c++ to c and asm when the speed improvements are at best marginal and the cost of maintenance of produced code is extremely high.

Don't get me wrong, I am not saying that these optimizations are bad. In fact, these engineers measure things properly and then rewrite. It's just that there is no business case for all this time spent. It's like writing web servers in C. Sure, it's possibly the faster than everything else but seriously? Who maintains all this.

Re:Node.js in Flame Graphs by meddlepal on Wednesday November 19, 2014 @01:10PM (#8631570)
Experimentation is good, but perhaps there is too much going on at some companies? Finding the right balance is a hard problem.
Re:Node.js in Flame Graphs by aturek on Wednesday November 19, 2014 @01:11PM (#8631577)
Curious, do you have some anecdotes about that? I've generally heard from coworkers who were at Netflix that they have pretty high attrition at the lower levels, with the "fire the bottom 10% every X months" rules.
Re:Node.js in Flame Graphs by general_failure on Wednesday November 19, 2014 @01:53PM (#8631823)
The bottom 10% has it hard in any company, let alone netflix. Almost every company I know has stringent rules for the bottom 10% (read: a step by step approach until they get fired). But if you are a decent engineer you have nothing to worry about.
Re:Node.js in Flame Graphs by laughinghan on Wednesday November 19, 2014 @02:05PM (#8631928)
I know I'm being a cocky asshole, but, are their engineers that good?

> It’s unclear why Express.js chose not to use a constant time data structure like a map to store its handlers.

Well, it was blindingly clear to me and the top commenter in this thread.

I'm not judgmental that it was unclear to the author of this article, after all, I'm unclear on things that should've been stupidly obvious to me all the time. I am totally judgmental that no one on the team proofread the blogpost before publishing it and was like "uh, dude, what would the keys in the map be, regexes?"

Re:Node.js in Flame Graphs by general_failure on Wednesday November 19, 2014 @03:27PM (#8632402)
Well, the same engineer who didn't figure that out went ahead and profiled things, drew some pretty graphs, actually bothered to write a blog post to put his thoughts for public review. IMO, that is all some good engineering :-)

But you made me think what I said. I would say this sort of gets into the programmer / engineer debate. Netflix has good progammers like most companies. Good engineers (in my books) are very hard to find. These people are good at being at peace with tradeoffs and understand the requirements of a business at a much deeper level than programmers. Programmers just want to have fun with computers (and there is nothing wrong about that).

Re:Node.js in Flame Graphs by guiomie on Wednesday November 19, 2014 @12:58PM (#8631502)
NIH ?
Re:Node.js in Flame Graphs by general_failure on Wednesday November 19, 2014 @12:59PM (#8631510)
Not invented here. Redoing stuff which already exists.
Re:Node.js in Flame Graphs by surganov on Wednesday November 19, 2014 @06:28PM (#8633405)
Sometimes it's okay to eliminate dependencies: http://www.joelonsoftware.com/articles/fog0000000007.html
Re:Node.js in Flame Graphs by yourad_io on Wednesday November 19, 2014 @12:45PM (#8631422)
What are the arguments against node.js in their use case?

Not looking to start any wars, but I was under the impression that if you know what you're doing* node.js is pretty awesome.

This particular bug had to do with a misunderstanding regarding the express API.

* for the most part: understand async and closures/memory leaks.

Re:Node.js in Flame Graphs by yourad_io on Wednesday November 19, 2014 @12:58PM (#8631500)
To give some arguments in favour:

- "Here we see our latencies drop down to 1 ms and remain there after we deployed our fix." <- Performance (from TFA)

- They can hire from a vastly larger pool of developers. Since they've got both budget and brand recognition, they should have no problems hiring high end JS guys & gals.

Re:Node.js in Flame Graphs by remon on Wednesday November 19, 2014 @01:11PM (#8631578)
Why are these arguments in favor of Node.js over their current Java based stack? Java is both considerably more speedy for this sort of workload and there's a significantly larger pool of high end Java server developers compared to high end JavaScript server developers. Budget and brand recognition are not necessarily in favor of node.js over other stacks. That simply helps with getting the better engineers in general.
Re:Node.js in Flame Graphs by yourad_io on Wednesday November 19, 2014 @01:26PM (#8631666)
They are arguments in favor of node.js being a reasonable tool for the job.

> Java is both considerably more speedy for this sort of workload

They're quoting 1ms latencies, that's pretty speedy. Maybe Java could do <1ms and/or support slightly more concurrent requests. How much difference does it actually make when you're already responding after 1 millisecond?

> there's a significantly larger pool of high end Java server developers compared to high end JavaScript server developers

Oh, I would have thought there are far more JS* folks out there than Java.

> Budget and brand recognition are not necessarily in favor of node.js over other stacks. That simply helps with getting the better engineers in general.

That's what I meant - them being in favour of Netflix as an employer - they aren't "Bob's Digital Agency" so they can have their pick of the litter of node devs.

* I'm not sure if the "server" distinction is meaningful here - if you know JS, you know node.js - simply a matter of familiarizing yourself with node-specific APIs.

Re:Node.js in Flame Graphs by remon on Wednesday November 19, 2014 @05:22PM (#8633062)
I'm not sure if I agree. Responding after 1ms is not the same (or even very much related to) routing a request taking up 1ms of cpu time. Although there are a ton of nuances that make the following a small oversimplification it does basically mean that purely for routing alone you have a hard cap on 1k lookups/sec/core. And building server software in any language takes a whole different set of skills and knowledge than knowing how to build front ends. I'm not arguing one is harder or more involved than the other but they are different enough to make language and paradigm familiarity and the only real gain when moving from front-end JS to node.
Re:Node.js in Flame Graphs by mnutt on Wednesday November 19, 2014 @11:49PM (#8634469)
The parent (and the article) are both talking about 1ms request latencies, not 1ms routing latency.
Re:Node.js in Flame Graphs by JDiculous on Thursday November 20, 2014 @03:20AM (#8634811)
One more advantage of Node.js over Java is that development is much faster with Node.js.
Re:Node.js in Flame Graphs by gasping on Thursday November 20, 2014 @04:24AM (#8634956)
No, just please no. Any moderately competent programmer can be productive in either Java or Javascript (+ Node.js). Javascript may help incompetent programmers feel productive because Javascript has fewer compile-time constraints but in the long run the cost of maintaining code written by an incompetent more than counteracts any perceived benefit that Javascript offers.
Re:Node.js in Flame Graphs by JDiculous on Tuesday December 02, 2014 @11:33PM (#8691920)
Well obviously the work of an incompetent programmer is going to increase the long run cost of maintaining code. That has nothing to do with the fact that Javascript is faster to develop in.
Re:Node.js in Flame Graphs by Terr_ on Wednesday November 19, 2014 @01:13PM (#8631590)
I was doing some googling about this earlier, IIRC one of the big ones was "Good when your bottleneck is I/O, not good when your bottleneck is CPU."
Re:Node.js in Flame Graphs by yourad_io on Wednesday November 19, 2014 @01:44PM (#8631777)
> "not good when your bottleneck is CPU"

99% of cases, your bottleneck will be I/O.

In the 1% of cases where your webserver's bottleneck is the CPU, you have much bigger problems than using a hipster ;) language: you're doing it wrong (tm) on an architectural level:

(a) Your processor-intensive/long-running tasks need to be in seperate worker processes and

(b) you need more webserver instances.

I usually try to avoid absolute statements, but I think this may be accurate:

The only CPU-intensive thing your web server code should ever do, is hash passwords.

Re:Node.js in Flame Graphs by yourad_io on Wednesday November 19, 2014 @01:58PM (#8631871)
I shouldn't have tried to be funny on HN* . For this I apologize.

Can I get a rebuttal to my points along with the downvotes, though?

Is someone disputing that CPU intensive tasks should be moved off the webserver?

Have you personally had experiences where your honest-to-$deity webserver bottleneck was the CPU? I'd be incredibly surprised. In most cases I'd guess you're underprovisioned and/or badly architected.

* This is where we come to somberly discuss interesting things.

Re:Node.js in Flame Graphs by nostrademons on Wednesday November 19, 2014 @02:24PM (#8632052)
You're assuming a number of things that aren't always true:

1. Your networking pipe into the server is slow.

2. You don't have a reverse proxy in front of the webserver to buffer the slow connections.

3. You don't make decisions about what information to show the user in the webserver; your UI isn't tailored for the particular user whose request you're servicing.

4. You haven't made productivity trade-offs to move work from the developer to the computer.

Google's webservers (for Search) are CPU-bound, and I can guarantee that they are neither underprovisioned nor badly architected, and CPU-intensive tasks are moved off the webserver (the total amount of CPUs for webservers is miniscule compared to the number of CPUs used for the indexing & serving system). But Google has the fastest fiber networks in the world, a massive load-balancing infrastructure, its philosophy is to serve each user only the HTML/JS that they need (to cut latency), it relies heavily on A/B tests & experimentation, and it invests significantly in developer-productivity tools so that all the bookkeeping for the last two points are done by computers rather than humans.

Re:Node.js in Flame Graphs by remon on Wednesday November 19, 2014 @01:24PM (#8631653)
I hear this more often and it is somewhat misleading. That sentence seems to imply node.js is better in terms of I/O throughput compared to other technologies, as if it's a trade off. This is incorrect and it would be more accurate to say "Good enough when your bottleneck is I/O, not good when your bottleneck is CPU.".
Re:Node.js in Flame Graphs by joshuacc on Wednesday November 19, 2014 @12:27PM (#8631294)
They went into this a bit on the NodeUp podcast: http://nodeup.com/seventyone
Re:Node.js in Flame Graphs by StevePerkins on Wednesday November 19, 2014 @12:32PM (#8631340)
Are there some salient points that can be summarized here? That's an hour-and-twenty-minute podcast episode.
Re:Node.js in Flame Graphs by remon on Wednesday November 19, 2014 @12:46PM (#8631428)
The motivation part starts around 8:30. It's hard to claim complete objectivity when it comes to things like this but it sounds particularly unconvincing to me. Node.js' sweetspot is providing an easy route to server development for front-end developers and it seems this is roughly what happened.

It's not a huge step for Netflix that already has an API approach that is very UI centric as outlined here http://techblog.netflix.com/2013/01/optimizing-netflix-api.h.... To me personally this doesn't seem like a healthy step forward but I hope someone can provide some reasons why you'd want to move to Node.js from, in the case of Netflix, Java.

Re:Node.js in Flame Graphs by bcoates on Wednesday November 19, 2014 @01:42PM (#8631763)
I'm a non-frontend dev who uses node.js for server/systems/embedded work.

My preference for node is based primarily on its sane concurrency model. I basically use it as a handy scripting language for doing rapid prototyping of libuv programs. My on-paper plan is to fall back to libuv and C if I find myself really stuck for CPU, but this is something that's never actually happened to me. (I have had to abandon or modify libraries with performance pathologies, though)

There are other libraries with in other languages the same sane model but they tend to be ecosystems within the language community that aren't compatible with the rest of the language. Doing concurrency both correctly and performantly in Java, in particular, is a pain in the ass.

Re:Node.js in Flame Graphs by remon on Wednesday November 19, 2014 @05:26PM (#8633085)
I'm not disagreeing and that's a perfectly valid reason to go for node for smaller projects or for prototyping. What many people fail to realise is that the "concurrency" model (it is solved by simply not having concurrency) isn't a magic bullet. It comes with large drawbacks. Not a lot of things are complicated because people like it that way. Some things are as complicated as they need to be to be used effectively. I agree that doing concurrency in Java can be a pain in the ass (although some microservice libraries can simplify some cases) but for the most part it's a pain in the ass because concurrency is hard, not because Java is bad. Doing it the way node.js does is as easy to do in Java as it is in node.
Re:Node.js in Flame Graphs by bcoates on Wednesday November 19, 2014 @06:53PM (#8633536)
An example of basic concurrency I have great difficulty doing correctly in Java:

  n = 0;
  avg = 0;

  function twothings() {
    thing1(function(ret) { ++n; avg += (ret - avg)/n; });
    thing2(function(ret) { ++n; avg += (ret - avg)/n; });
  }
I want to dispatch two I/O operations to run concurrently and have their completions modify some shared state in a serializable fashion, which can be read at any stage in the process and have a valid result. I shouldn't need to give up on nondeterministic simultaneous execution or faff about with locking mechanisms to get this.
Re:Node.js in Flame Graphs by necubi on Wednesday November 19, 2014 @09:20PM (#8634057)
What I think you're missing is that in JS, this is not being run concurrently. Existing JS runtimes are single-threaded—if you actually want to take advantage of multiple CPUs you must run more than one process. It's very easy not to have concurrency bugs when there's no concurrency.

In Java, you have access to real threads and can actually run two pieces of code concurrently. This introduces a lot of potential issues, but also allows you to take advantage of multiple cores.

If all you want is non-blocking IO (what node gives you), there are a handful of great libraries that provide that on the JVM.

Re:Node.js in Flame Graphs by CountHackulus on Thursday November 20, 2014 @09:48AM (#8635924)
If you're having trouble with that, I suggest you take a look at CompletableFuture, or ExecutorCompletionService, or any other number of methods to do this in Java. Just like node has it's own lingo, so does Java, and once you learn it, things become real simple.
Re:Node.js in Flame Graphs by tjholowaychuk on Wednesday November 19, 2014 @10:05PM (#8634213)
I share this thought, I'm not trolling, I really believe node is a bad solution for something like Netflix.

Node has its perks but for a money making machine that relies solely on being available and providing a good customer experience, not so much.

I can't imagine the ops nightmares at that size, one buggy code path and the entire cluster could be down. These are issues that drove me away from Node to Go, in my opinion Node has way too many issues to run in money-making scenarios.

Re:Node.js in Flame Graphs by nmjohn on Wednesday November 19, 2014 @10:46PM (#8634338)
> in my opinion Node has way too many issues to run in money-making scenarios.

You can say that about a lot of languages other than node. How many billion dollar companies have their software written in PHP - a language that many people would agree has far more glaring issues than node.

My point, is that I believe your comments miss the larger picture. There is far more involved with deciding which language to build a product with than "which language is best."

I don't disagree with you about Go being a great language - but for most companies, it is not even remotely practical to use. Hiring talented Go developers is hard because there are so few. Their current employees may or may not know Go, what do you do about that? Etc.

Re:Node.js in Flame Graphs by tjholowaychuk on Wednesday November 19, 2014 @10:50PM (#8634346)
For sure, but jumping into Node from a clean slate is probably not the best idea, legacy is different.

If anything the comment on hiring highlights the use of Node being problematic. It's difficult to write robust systems in Node even as a seasoned Node developer.

Re:Node.js in Flame Graphs by nthtran on Wednesday November 19, 2014 @10:58PM (#8634369)
Could you expand more on the ops issues you have encountered in your systems?