TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

We 30x'd our Node parallelism

202 点作者 bjacokes超过 5 年前

24 条评论

kevstev超过 5 年前
I was building scalable node applications a few years ago for a very large e-commerce player- millions of customers. I think node.js is a great platform, but its apparent simplicity means there are hordes, and I mean like 90+% of the community, that can &quot;just get things done&quot; without understanding what is going on under the hood at all. And to be fair, for most startupy types of companies that need to iterate fast, that is what you want to optimize for.<p>My interview screening question was pretty simple- &quot;Is node.js single threaded or multithreaded?&quot; And to most, they spit back the blogspam headline- &quot;Single threaded!&quot; I think the most correct answer is &quot;its complicated&quot; but would accept that because most people would say that is the &quot;right&quot; answer. So I would follow up with- &quot;what exactly happens in a default installation if we have say... 5 requests come in at exactly the same time to just return some static content from disk?&quot; (Node&#x27;s default threadpool is 4). And here is where you could see their understanding just fell apart. Some would say they would be handled entirely synchronously, others completely in parallel- but then had no idea what the cause of the parallelism was. Very few actually understood that node is an event loop executing javascript backed by a threadpool for async operations.<p>Before reading this post, I was like eh this is a waste of time- its typical medium bullshit- they almost certainly found they were doing some blocking call in the event loop and then removed it and voila, 30x speedup. It was interesting because it was a lot worse! They spent all this time and hard work figuring out everything but what was taking so long in the event loop, and it seems that was the last place they actually looked.<p>Anyway, node can be a highly scalable platform (<a href="https:&#x2F;&#x2F;changelog.com&#x2F;podcast&#x2F;116" rel="nofollow">https:&#x2F;&#x2F;changelog.com&#x2F;podcast&#x2F;116</a>) but you need to understand it or else it will bite you in the foot. When I was last doing this stuff, upwards of 80% of our time was being spent essentially just JSON.parse()&#x27;ing, and we were looking to move to protobufs to avoid that.
评论 #21783337 未加载
评论 #21783412 未加载
评论 #21786582 未加载
评论 #21783217 未加载
评论 #21784634 未加载
评论 #21783223 未加载
评论 #21787241 未加载
评论 #21784255 未加载
评论 #21785195 未加载
评论 #21787027 未加载
评论 #21783675 未加载
spamizbad超过 5 年前
The only way this makes sense to me is if they have to contend with lots of expensive parsing, event sequencing, and throttling requirements. Payment APIs, bank websites, etc can be quite byzantine. I could understand how one might code yourself into a corner with a monolithic node app and basically just say &quot;F-it, we&#x27;re doing this synchronously!&quot;<p>I don&#x27;t even think it&#x27;s a terribly <i>bad</i> thing to do assuming it favors feature velocity.... but at that point, I&#x27;d recommend moving away from Node towards something like Python. And if you wanted to dip your toes back into async plumbing land, explore Go or Elixir.
评论 #21784713 未加载
评论 #21783650 未加载
评论 #21782936 未加载
评论 #21782546 未加载
评论 #21782668 未加载
评论 #21782763 未加载
评论 #21782937 未加载
rauchp超过 5 年前
That was an interesting read, thanks for linking to it. It&#x27;s hard finding articles online discussing Node and performance, most people just dismiss it as an unviable option due to scale and speed concerns. 30x really is quite the jump though.<p>&gt; Each Node worker runs a gRPC server<p>Not going to lie, this kind of surprised me. When I think of a Node backend I think of ExpressJS. Not because I think Express is better, but because it&#x27;s been pushed around in the past few years as the fastest, simplest way of running a backend.<p>Yet, if you&#x27;re going to be running a gRPC server, why not use a more performant language with better multithreading support? I thought this article was about them optimizing a grandfathered-in solution (such as Express), but I can&#x27;t tell why they built out a gRPC server in Node in the first place.
评论 #21782780 未加载
评论 #21783302 未加载
7777fps超过 5 年前
&gt; We were running 4,000 Node containers (or &quot;workers&quot;) for our bank integration service. The service was originally designed such that each worker would process only a single request at a time. This design lessened the impact of integrations that accidentally blocked the event loop, and allowed us to ignore the variability in resource usage across different integrations. But since our total capacity was capped at 4,000 concurrent requests, the system did not gracefully scale.<p>I can&#x27;t be the only person who reads stories like this and wonders how they arrived at that solution in the first place?<p>Failing to scale because their previous approach to scaling was a worker per request, a model which was roundly moved away from, because that&#x27;s how CGI and Apache modules worked and it didn&#x27;t scale well.<p>I thought one of the key selling points with Node was an fully async standard library, enabling better scaling in process.<p>But then you read stories like this, and I find it hard to relate to the original problem.
评论 #21782621 未加载
评论 #21783243 未加载
评论 #21782790 未加载
评论 #21782479 未加载
评论 #21782372 未加载
评论 #21783476 未加载
评论 #21782644 未加载
评论 #21782620 未加载
评论 #21783014 未加载
评论 #21782580 未加载
评论 #21782402 未加载
评论 #21782571 未加载
评论 #21782378 未加载
评论 #21782498 未加载
评论 #21782860 未加载
评论 #21782874 未加载
mnutt超过 5 年前
I’d be curious to hear more about the circumstances that ended up with a blocked runloop. Are there hundreds of junior engineers, or perhaps third parties writing code that you don’t control? I have seen people accidentally write blocking code, but not at such an egregious rate that we couldn’t catch it in code review, or at worst the runloop detector would alert on it in prod and we would roll back the deploy.<p>For instances where you actually know you need lots of CPU, there are now strategies for offloading that specific work, although they have taken a while to get nice and easy to use.
评论 #21783713 未加载
jdc0589超过 5 年前
On a positive note: this was a good write up.<p>On a negative note: FOR THE LOVE OF ALL THAT IS HOLY, HOW DID THIS HAPPEN.
vmarchaud超过 5 年前
I&#x27;ve encounted different issues with NodeJS services in the past (and still do) both with CPU bottleneck and Heap allocations. So i wrote openprofiling-node [0] during this summer to help me profile my apps directly in production and export the result in a S3 bucket. I believe it may help someone else here so i&#x27;m posting it<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;vmarchaud&#x2F;openprofiling-node" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vmarchaud&#x2F;openprofiling-node</a>
pdimitar超过 5 年前
...Or you could just use Erlang or Elixir, where concurrency <i>and</i> parallelism come pretty much out of the box, with very little effort required for you to fine-tune the desired policy &#x2F; strategy.<p>The insistence on using Javascript is just beyond lunacy at this point.
评论 #21789179 未加载
nosianu超过 5 年前
They write (somewhere in the middle)<p>&gt; <i>Since V8 implements a stop-the-world GC, new tasks will inevitably receive less CPU time, reducing the worker’s throughput</i><p>But there is this Google blog post vom January 2019:<p><a href="https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;trash-talk" rel="nofollow">https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;trash-talk</a><p>&gt; <i>Over the past years the V8 garbage collector (GC) has changed a lot. The Orinoco project has taken a sequential, stop-the-world garbage collector and transformed it into a mostly parallel and concurrent collector with incremental fallback.</i><p>So I guess they used an older node.js version. The current LTS version is 12.x and it is from around the middle of this year.<p>---<p>PS: If the blog author reads this, there is an accessibility problem with the Google-hosted inline images. If I try - without ad blocker - in an anonymous window I see none of the inline images. Logged into Google with my own account I can see <i>some</i> but not all the images. Apparently which images I can see depends on being logged in to my Google account? I also tried IE Edge just to see if the browser makes a difference - no inline images visible there either.
评论 #21783188 未加载
评论 #21783719 未加载
评论 #21783102 未加载
awinter-py超过 5 年前
Compared to a compiled language, node &#x2F; JIT langs make it difficult to know what will be fast in prod.<p>V8 JIT means that things like order of keys in an object or number of different calls to a function might affect whether your function gets optimized.<p>And there&#x27;s no easy way to find out if a JS function is falling back to slow mode or to tell the buildsystem &#x27;this is a hot path, don&#x27;t let me write code that deopts this call&#x27;.
bfrog超过 5 年前
It&#x27;s not clear from the article why they were only able to run one request per node process, but that alone would make it questionable why use Node at all then. The entire point of the environment has been nixed. The article is quite confounding to understand how they arrived at that point in the first place.
tyingq超过 5 年前
<i>&quot;Only 10% of Plaid&#x27;s data pulls involve a user who is present&quot;</i><p>Since they provide an API, it seems like some of the calls where they think a user isn&#x27;t present might actually have one present.
评论 #21782649 未加载
评论 #21782511 未加载
Scarbutt超过 5 年前
I don&#x27;t want to be that guy, but why did they start with nodejs for something like this instead of using the JVM or Go?
评论 #21782690 未加载
评论 #21782768 未加载
rynop超过 5 年前
I’d be curious to hear your reevaluation of moving this to Lambda after some of the major announcements during re:invent. My guess is some of the reasons you went ECS have been addressed with these announcements. Obviously some of the new features are still preview, but would be interested to hear your analysis none the less.
评论 #21784043 未加载
tyingq超过 5 年前
Does node have something similar to how apcu is used with PHP?<p>That is, an mmap based kv store so that if you choose to run more than one node process on a single server, it has a fast kv cache?<p>I&#x27;m aware you can use redis or similar, but a simple mmap kv store is simpler and faster for a single server use case.
评论 #21783399 未加载
评论 #21782437 未加载
mceachen超过 5 年前
In case anyone else gets excited by JSONStream, know that the package hasn&#x27;t been updated in over a year, and the GitHub repo was archived by the author with no link to a successor.
评论 #21783897 未加载
评论 #21783743 未加载
FanaHOVA超过 5 年前
$300k is $300k, but they just raised $250M last year, is this a really good use of time for their engineering team? That&#x27;s a little above ~0.1% of capital.
评论 #21784905 未加载
评论 #21784001 未加载
评论 #21783958 未加载
deedubaya超过 5 年前
A good example of avoiding premature optimization. I&#x27;d imagine delaying tackling this problem freed them up to tackle problems that impact users.
评论 #21782858 未加载
supermatt超过 5 年前
Ironic. Linked images failing to display due to &quot;Rate limit exceeded&quot;...
mirekrusin超过 5 年前
4k containers? That&#x27;s microservices going macro big time.
GordonS超过 5 年前
I don&#x27;t like to be overly negative, especially when a company&#x2F;team is being transparent about what they&#x27;re doing and giving insight into their engineering practices - but has anyone else&#x27;s estimation of Plaid&#x27;s engineering team just gone down the toilet?<p>This blog post gives me the impression that either Plaid is filled with either junior or incompetent engineers - to scale to 4k containers serving 1 request each for an API workload is absolute insanity.<p>These engineers are building stuff for <i>banking</i>. <i>Banking</i>!! There is literally no way I&#x27;m going near Plaid with a very long bargepole after reading this.<p>It I was someone senior at Plaid, I&#x27;d be pulling this blog post before it harms reputation any further.
评论 #21784786 未加载
评论 #21785833 未加载
评论 #21784785 未加载
评论 #21785522 未加载
评论 #21785016 未加载
评论 #21785236 未加载
评论 #21786978 未加载
评论 #21785136 未加载
评论 #21784983 未加载
评论 #21785201 未加载
CyanLite2超过 5 年前
TLDR: How to spend millions of dollars of our investors&#x27; money because we hired junior devs who chose a framework that was trendy but couldn&#x27;t scale.
Phil_Latio超过 5 年前
&gt; We were running 4,000 Node containers<p>LOL
PixyMisa超过 5 年前
Nobody involved in this project should be allowed to ever be in the same room as a computer again.
评论 #21786962 未加载
评论 #21783427 未加载
评论 #21784056 未加载