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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

A lot of complex “scalable” systems can be done with a simple, single C++ server

398 点作者 Impossible超过 5 年前

36 条评论

IndrekR超过 5 年前
A site for proof. It keeps amusing me on what hardware&#x2F;software Stack Overflow&#x2F;Stack Exchange is running on: <a href="https:&#x2F;&#x2F;stackexchange.com&#x2F;performance" rel="nofollow">https:&#x2F;&#x2F;stackexchange.com&#x2F;performance</a><p>This is way less in HW than most people in the trade (from web devs to devops) seem to think when asked about it.<p>SO ranks #36 in Alexa right now: <a href="https:&#x2F;&#x2F;www.alexa.com&#x2F;siteinfo&#x2F;stackoverflow.com" rel="nofollow">https:&#x2F;&#x2F;www.alexa.com&#x2F;siteinfo&#x2F;stackoverflow.com</a>
评论 #21909966 未加载
评论 #21910094 未加载
评论 #21911458 未加载
评论 #21909385 未加载
评论 #21912760 未加载
评论 #21909987 未加载
评论 #21912891 未加载
评论 #21910210 未加载
评论 #21910198 未加载
jandrewrogers超过 5 年前
Many developers severely underestimate how much workload can be served by a single modern server and high-quality C++ systems code. I&#x27;ve scaled distributed workloads 10x by moving them to a single server and a different software architecture more suited for scale-up, dramatically reducing system complexity as a bonus. The number of compute workloads I see that actually need scale-out is vanishingly small even in industries known for their data intensity. You can often serve millions of requests per second from a single server even when most of your data model resides on disk.<p>We&#x27;ve become so accustomed to extremely inefficient software systems that we&#x27;ve lost all perspective on what is possible.
评论 #21910676 未加载
评论 #21908973 未加载
评论 #21912524 未加载
sriram_malhar超过 5 年前
This is precisely the point made by McSherry, Isard and Murray in their lovely paper, &quot;Scalability! But at what COST?&quot; (Usenix HotOS &#x27;15). They demonstrate how much performance headroom there is in modern CPU and memory, and show how simple cache-sensitive batch algorithms running on a single core can outperform hundreds of cores running distributed map-reduce style jobs.<p><a href="https:&#x2F;&#x2F;www.usenix.org&#x2F;system&#x2F;files&#x2F;conference&#x2F;hotos15&#x2F;hotos15-paper-mcsherry.pdf" rel="nofollow">https:&#x2F;&#x2F;www.usenix.org&#x2F;system&#x2F;files&#x2F;conference&#x2F;hotos15&#x2F;hotos...</a>
评论 #21911406 未加载
评论 #21910962 未加载
评论 #21913320 未加载
8fingerlouie超过 5 年前
As someone who has implemented a complex system in C++ in this decade, I’d say he’s not wrong, but you need to carefully weight the pros and cons.<p>In our case latency and real time demands mattered a lot (NASDAQ feed parser), to the point of the (potential) slowdown of a garbage collector kicking in was enough to rule out Java and .NET. It runs entirely in memory and on 64+ cores.<p>We implemented our own reference counting system to keep some of our sanity, and to at least try to avoid the worst memory leaks.<p>This was an edge case, and for almost everything else you’re probably better off implementing it in something that handles memory for you. If performance is an issue, least try it in Go or Rust with a quick PoC before jumping the C++ wagon.
评论 #21909972 未加载
评论 #21908836 未加载
评论 #21910410 未加载
评论 #21908835 未加载
bsenftner超过 5 年前
I&#x27;m 15 years in writing high performance Internet servers in C++, and I can confirm higher level languages provide an illusion of capability, but once you&#x27;re talking high performance with high compute requirements and scaling your service, the cost efficiency of C++ is exponential better than any other language. The higher level language ecosystems are bloated beyond repair. I was able to use one 32-core physical server running a C++ http server I wrote providing a rich media web service and replace an AWS server stack that cost my client 120K per month. The client purchased one $8K 32-core server and co-located it behind a firewall at a cost of $125 per month. And the C++ server ran at 30% utilization, plenty of room for user growth. Their AWS stack of a dozen C#, Python, PHP and Node apps were peaking their capacity too. If course, my solution caused existential questioning by the non-geek CEO and the CTO, but they were in crisis and needed to radically revise how they provided their service or close.
评论 #21912008 未加载
评论 #21995659 未加载
评论 #21910619 未加载
评论 #21995653 未加载
lmm超过 5 年前
Horizontal scalability carries a lot of overhead. Probably a factor of 10, easily. But the clue is in the name: eventually you&#x27;ll get to a point where you have to scale.<p>Back in 2010 I worked for a company whose system, in Java, ran on a single web server (with one identical machine for failover). We laughed at our nearest rivals, who were using Ruby, and apparently needed 60(!) machines to run their system, which had about 5x the average request latency of ours.<p>Then traffic doubled, and suddenly we were having to buy six-figure servers and carefully performance-optimize our code, and our rivals with the 120 Ruby servers didn&#x27;t look so funny any more. And then traffic doubled again.
评论 #21910477 未加载
评论 #21911674 未加载
评论 #21910402 未加载
评论 #21910472 未加载
ummonk超过 5 年前
Yes, I’m always shocked by just how much performance overhead most languages have compared to C and similar lower level languages. It is a price worth paying for better language ergonomics, but I do wonder whether Rust might be able to give us the best of both worlds here.
评论 #21909137 未加载
评论 #21910348 未加载
评论 #21913642 未加载
评论 #21908951 未加载
blondin超过 5 年前
not how i read his tweet. he was lamenting that python is too slow for some server side development use cases. and he gave cpp as an alternative that would be simpler and faster. he even followed up citing java and csharp.<p>totally agree. if all your backend server is mostly complex serialization &amp; de-serialization, and pushing bytes to other sub-systems, i think many other languages have advantages over python.<p>wondering why no mention of go or rust though...
twic超过 5 年前
What&#x27;s that, Frank McSherry? For horizontally scaled systems, we should ask what the Configuration that Outperforms a Single Thread is?<p><a href="https:&#x2F;&#x2F;blog.acolyer.org&#x2F;2015&#x2F;06&#x2F;05&#x2F;scalability-but-at-what-cost&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.acolyer.org&#x2F;2015&#x2F;06&#x2F;05&#x2F;scalability-but-at-what-...</a>
评论 #21910549 未加载
rossmohax超过 5 年前
Carmack is moving to AI and inevitably has to deal with a lot of Python, which still bottlenecks process here an there despite all the effort to move computation to C extensions. I have a really high hope that he detours a bit and creates very-very good non-python tooling for ML.
评论 #21911878 未加载
kitsuac超过 5 年前
I&#x27;ve been programming C++ and assembly for 23 years. Few years ago I became a huge fan of Python. In my opinion Python is amazingly well suited for rapid first revision and can then be swapped out for C++ &#x2F; asm.
评论 #21910011 未加载
评论 #21927105 未加载
anovikov超过 5 年前
My good friend built whole career doing exactly the same. &quot;Replace a cluster of 10 Elasticsearch servers with 1 running a custom built C app and in-memory database&quot;.<p>Of course, it won&#x27;t work out to replace 1000 Elasticsearch servers - that&#x27;s where the advantage of a true &quot;big data&quot; tool will show - but none of the clients really have data &quot;that big&quot;.
fxtentacle超过 5 年前
Many people don&#x27;t know about Python&#x27;s GIL <a href="https:&#x2F;&#x2F;wiki.python.org&#x2F;moin&#x2F;GlobalInterpreterLock" rel="nofollow">https:&#x2F;&#x2F;wiki.python.org&#x2F;moin&#x2F;GlobalInterpreterLock</a><p>That&#x27;s the reason why you need to go multi-process if you want to reach a similar level of concurrency in Python as multi-thread in C++. And that surely adds a lot of complexity.<p>As a very practical example of this, TensorFlow has a dedicated page with advice on how to make the Python part that reads the files from disk less slow. Think about that: The bottleneck for training a highly advanced AI with millions of parameters is in the 20 lines of Python code to read in a binary file...<p><a href="https:&#x2F;&#x2F;www.tensorflow.org&#x2F;guide&#x2F;data_performance" rel="nofollow">https:&#x2F;&#x2F;www.tensorflow.org&#x2F;guide&#x2F;data_performance</a>
评论 #21908567 未加载
评论 #21908083 未加载
评论 #21908700 未加载
评论 #21918246 未加载
评论 #21908378 未加载
BalinKing超过 5 年前
From the next tweet in the thread: “JAVA [sic] or C# would also be close, and there are good reasons to prefer those over C++ for servers.”
评论 #21914603 未加载
jacobsenscott超过 5 年前
You can choose a language that optimizes your hardware, or you can choose a language that optimizes your programmers. 99% of the time optimizing the programmers is the right call.
评论 #21911552 未加载
评论 #21911303 未加载
评论 #21911241 未加载
useful超过 5 年前
PCI-e 4.0 and 5&#x2F;6 enables consuming absolutely insane amounts of data. I can&#x27;t think of many applications that need that.<p>128GB&#x2F;sec? sure! and 256GB&#x2F;sec is coming.<p>With 10Gb, 40Gb and 100Gb internet links becoming mainstream the roadblock to having cool stuff is developers to make it.
评论 #21912220 未加载
cryptica超过 5 年前
Scalability and performance are very different.<p>Opting for a performant but not scalable solution is basically an acknowledgement that:<p>- The project will only succeed up to a certain point.<p>- After the initial launch, no further changes will be made to the project since new additions are likely to cost performance and lower the upper bound on how many users the system can support.<p>Not many projects are willing to accept either of these premises. Nobody wants to set an upper bound on their success.<p>Also, it should be noted that no language is &#x27;much faster&#x27; than any other language. Benchmarks which compare the basic operations across multiple languages rarely find more than 50% performance difference. The more significant performance differences are usually caused by implementation differences in more advanced operations and in any given language, different libraries can offer different performance characteristics so it&#x27;s not fair to say that a language is slow because some of its default advanced operations are slow.<p>Usually, performance problems come down to people not choosing the best abstract data type for the problem. Some kinds of problems would perform better with linked list, others perform better with arrays or maps or binary trees.<p>Time complexity of any given algorithm is way more significant than the baseline performance of the underlying language.
slx26超过 5 年前
the title is misleading. sure, it advocates for C++, or Java, or C#, or others above Python, but clarifying the context: &quot;a lot (not all!) of complex “scalable” systems can be done with a simple, single C++ server.&quot;, which I take as: &quot;sometimes it&#x27;s better to write a simple server in a low level language, than a complex server in a higher level language&quot;.
评论 #21908311 未加载
arcticbull超过 5 年前
I&#x27;m not sure there&#x27;s any such thing as a simple C++ server ;)
buboard超过 5 年前
people will bike to work to &quot;save the environment&quot; but won&#x27;t use C direct on metal to reduce the carbon footprint of their code.<p>For a guy like Carmack, it may be quite frustrating working with the constraints of pytorch etc. He ll probably end up making his own pytorh frontend in C, which as a bonus people will use to deploy models.
评论 #21910018 未加载
评论 #21913007 未加载
qaq超过 5 年前
Keep in mind a modern commodity x86 server with 128 physical cores 4 TB RAM and decent amount of SSD storage and dual 100 gbe nics is about 70K. Ability to use something like Rust also changes equation significantly.
评论 #21912147 未加载
fatbird超过 5 年前
Has Carmack looked at Rust? I&#x27;d be very curious for someone like him to look at it in light of his experience with C&#x2F;C++ and high performance systems.
评论 #21907724 未加载
评论 #21907741 未加载
评论 #21907762 未加载
wruza超过 5 年前
<i>Morals of this story: 1. Always use the most performant language available to you. (What if your program gets a few million users?)<p>2. Horizontal scalability is too much complexity&#x2F;work. Just apply the correct amount of optimization when you initially write the code.</i><p>If you, like me, read this on mobile and did not click [more answers] link under that, then do it. That may save you a minute or two of derealization time.
评论 #21908823 未加载
评论 #21910067 未加载
api超过 5 年前
This has been a repeated point since &quot;enterprise&quot; Java (a.k.a. Jabba) became a thing in the late 90s and early 2000s. A ton of enterprise code is comically inefficient and held together with scotch tape and used chewing gum.<p>It ends up boiling down to the fact that compute power is a lot cheaper than developer time and really good developers are more expensive and harder to find than inexperienced ones.
gregdoesit超过 5 年前
From this thread, I feel a lot of people misunderstand what a scaleable system means for a scale-up startup or BigTechCo. It doesn’t mean cost-efficiency. It means the ability to solve scalability issues at 10x, 100x, 1000x load by throwing money at it (aka buying more instances&#x2F;machines).<p>Yes, John Carmack is right that a bunch of scaleable systems that see reasonable load, with well-understood traffic requirements could be rewritten more efficient ways. But how long would it take? How much would the extra work cost? And what would happen if traffic goes up, to another 10x, 100x? Can you throw still throw money at that problem, with this new and efficient system already in-place?<p>One of my memorable stories comes from an engineer I worked with when we rewrote our payments system[1]. He told me how at a previous payments company, they had a system that was written in this kind of efficient way, and needed to run on one machine. As the scale went up, the company kept buying bigger hardware, at one point buying the largest commercially available mainframe (we’re talking the cost being in the multi-millions for the hardware). But the growth was faster and they couldn’t keep up. Downtime after downtime followed at peak times, making hundreds of thousands of losses per downtime.<p>They split into two teams. Team #1 kept making performance tweaks on the existing hardware to try to get performance wins, and increase reliability during peak load. Team #2 rewrote their system in a vertically scaleable way. Team #1 struggled and the outages kept getting worse. Team #2 delivered a new system quickly and the company transitioned their system over.<p>What they gained was not cost savings: it was the ability to (finally!) throw money at their growth problems. Now, when traffic went up, they could commission new machines and scale with traffic. And they could eventually throw away their mainframe.<p>Years later, they started to optimise the performance of the system, making millions of $ in savings. The new system - like the old one - cost millions to run. But that was besides the point. Finally, they stopped bleeding tens of millions in lost revenue per year due to their inability to handle sudden, high load.<p>It’s all about trade-offs. Is cost your #1 priority and are you okay spending a lot of development time on optimising your system? Go with C++, Erlang or some other, similarly efficient language. Is product-market fit more important, with the ability to have high uptime, that you can buy? Use the classic, horizontally scaleable distributed systems stack, and worry about optimising later, when you have stable traffic and optimisation is more profitable over product development.<p>[1] <a href="https:&#x2F;&#x2F;blog.pragmaticengineer.com&#x2F;distributed-architecture-concepts-i-have-learned-while-building-payments-systems&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.pragmaticengineer.com&#x2F;distributed-architecture-...</a>
评论 #21911446 未加载
评论 #21911453 未加载
coderunner超过 5 年前
What about in the context of trying to get to an MVP? Is the dev time speedup of using a dynamic programming language and stack significant over using a c++ backed? You wouldn&#x27;t care much about performance when you&#x27;re trying to figure out if you&#x27;ll get traction.
评论 #21911583 未加载
zem超过 5 年前
vibe.d is well worth a look: <a href="https:&#x2F;&#x2F;vibed.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vibed.org&#x2F;</a>
评论 #21909095 未加载
rbanffy超过 5 年前
OTOH, we can assume one doesn&#x27;t need to worry about using C++ unless they have many millions of users.
ungerik超过 5 年前
This is why Google developed Go. Python like productivity with C++ like performance...
tyuioyjj超过 5 年前
What if those &quot;scalable&quot; systems were designed to &quot;just work&quot; and then after it succeed it was changed into pseudo &quot;&quot;scalable&quot;&quot;?
lonelappde超过 5 年前
A single server cannot be made reliably available, though.<p>At single-node scale, development costs dwarf hardware costs of scaling horizontally.
easytiger超过 5 年前
Been saying this for years.<p>Modern SW trends are horrific
fnord77超过 5 年前
wow, so much speculation, zero empirical evidence.
评论 #21911777 未加载
amelius超过 5 年前
The catch is: until you can&#x27;t.
kyledrake超过 5 年前
The analogy here is one of the best ice climbers in the world proposing an ascent of the Matterhorn. Please use testable, easy to prototype with, memory managed languages for production servers unless you are solving a very specific problem and <i>really</i> know what you are doing.
评论 #21910807 未加载
rvz超过 5 年前
&gt; ...My bias is that a lot (not all!) of complex “scalable” systems can be done with a simple, single C++ server.<p>The second tweet of the discussion:<p>&gt; JAVA or C# would also be close, and there are good reasons to prefer those over C++ for servers. Many other languages would also be up there, the contrast is with Really Slow (but often productive and fun) languages.<p>I&#x27;m afraid that Carmack has sided with his own anecdotal experiences of the 1990s to justify the use of C++ for server-side development for the 21st Century. This probably made sense at the time due to the availability of more C++ devs and less language choices, but today in the 2020s? I remain totally unconvinced by his argument.<p>He goes on to suggest Java or C# which still makes sense for many companies for generic server-side development if you are after a more secure backend. Kotlin is pretty much the most sensible for this. But for the sake of Carmack&#x27;s engineering background however, it is unsurprising why Java&#x2F;C#&#x2F;Kotlin are technically unsuitable for high-performance gaming platforms if one was to create one. So what credible languages could be used to compete with C++? I hear Discord is having a great time with using Elixir (Erlang could also be used) and another gaming platform called &#x27;Hadean&#x27; is using Rust for their platform.
评论 #21907978 未加载