398 points · by Impossible · 6y ago · 362 comments
This is way less in HW than most people in the trade (from web devs to devops) seem to think when asked about it.
SO ranks #36 in Alexa right now: https://www.alexa.com/siteinfo/stackoverflow.com
I guarantee you the bulk of traffic to SO is hitting a page and performing zero writes.
this isn't a lot. Helps that site is mostly text data.
I know of a relatively small cloud security system that transfers petabytes/month to/from a handful of customers.
4 ingest pods, 8 pipeline pods, 7 time-series db servers, 2 sql servers
Compared to other similar sites like Reddit or Quora which are far slower yet running on more hardware, it shows what proper efficient architecture and code can do.
For example, at work, our entire analytics ingest workload (HTTP) for a few hundred million users runs on 8 core VMs on GCP, written in Rust/Go, each node doing ~40k events/second.
Our RTC infra sustains >1m PPS per node on 4 core 3.9ghz 2014-2017 xeons.
(SO and DailyWTF are very much into Microsofts ecosystem)
There's significant difference between ASP.NET and ASP.NET Core
https://meta.stackexchange.com/questions/316278/the-road-to-...
Looking at the specs of the machines, they are actually pretty basic as far as servers go. A server isn't barely worth the cost of it's chassis and motherboard if you put less than 64 G ram and 24 CPUs in it.
In other words, these are about the lowest specd proper servers you can get. So yeah, even their modest hardware is still overspecd for running their website.
Also, of course, the total cost per hour for 9 servers with 3 year depreciation is in cents.
Ultimately, their service is (most likely) not compute-bound.
It would rank way higher if they would be more webscale. It needs more Kubernetes, GraphQL and Golang /s
We've become so accustomed to extremely inefficient software systems that we've lost all perspective on what is possible.
Are you saying this can be optimised to fit inside a single 10 core server in terms of compute loads?
You use a cluster when your data and compute requirements are large and parallel enough that the tax paid on network latency trumps the 10-20X speedup you get on SSD and 1000X speedup you get from just keeping data in RAM.
250 Gigs is tiny enough that you could probably much get better performance running on high memory instance in AWS or GCP. You'll generally have to write your own multiprocessing code though which is fairly simple - your existing library may also be able to support it.
I once actually ran this kind of workload on just my laptop using a compiled language that performed better than pyspark on a cluster.
However, even if I could load it all into memory at once, and assuming it takes 200 gb, I'm still using a master's student access to a cluster. So I get preempted like it's nobody's business. Hence why I prefer a smaller memory footprint even if I take up cpus at variable rates through a single execution.
I did try to write my own multiprocessing code for this, but the operations are sometimes too complicated (like groupby) for me to rewrite everything from the ground up. If I'm not reliant on serial data communication between processes (like you'd need to sort a column), I can get it done pretty easily. In fact, I wrote my data cleaning code with this and cleaned up the entire file in half an hour because single chunks didn't rely on others.
However, if you have some idea of how to run these computational loads in parallel in python or any other language on single compute instances (like the size of a laptop's memory of 16 gb), I'd really love to see it. Thanks.
Nowadays there's another reason to use clusters: to autoscale your expenditure wrt workload. A little inefficiency might be acceptable if you don't have to pay for a huge beefed up server idling at, say, 30%.
Segmenting your raw data and using memory mapped files will let you work with large data sets without needing huge amounts of RAM. From there it's a question of your single system's processing speed and IO capacity. This is only necessary if your processing needs random access to the entire dataset.
If your CSV data is more like a streaming data source, you're processing each record as it's read in, you can just stream it in through `stdin`. At 1GB/s you're looking at five minutes or so to process your 250GB of raw data. A SATA SSD might take twenty minutes to stream that raw data.
It's important to note that often your disks aren't directly attached to your compute. That's frequently the case in (particularly cheap) cloud instances.
Nit: 1GB/s is ok, not even solid let alone fast.
A fast SSD pretty much saturates 4x3.0 links (which explains why they universally tend to cap out at 3.5GB/s). In fact there are now a few PCIe4 SSDs (e.g. Corsair's MP600) which close in on 5GB/s.
Obligatory read: https://aadrake.com/command-line-tools-can-be-235x-faster-th...
I'm currently employed to write software which does DNA analysis. DNA is known for being Big Data.
Some applications are very compute intensive and others are very data-relation intensive. The very compute intensive applications process about 1GB of data in about 30 minutes on a 32 core Xeon 6xxx with 32GB of RAM assigned to it. The data-relation intensive application processes about 350GB of data in 15 minutes on a single core of the same CPU but with 700GB of RAM assigned to it.
Both are heavily optimized but in different ways. So without knowing more about what you're doing with that data, it's hard to say.
While I hope that each 250GB chunk has everything in order and I can separate it cleanly, I don't trust it. So I broke up all the files by stock in an embarrassingly parallelised code I wrote and got 500 separate files. However, the problem is, I'd want to process these 500 files parallely so each stock gets only so much memory (and hence, my original constraint remains). And for each stock, I want the data to be queried on timestamps, so I need a way to quickly say "I have data at 9am on Thursday, I want data from 4pm Wednesday to 8am Thursday to create a model".
I figured the best way to do this efficiently was to have the code create a massive database for all the stocks and query it efficiently in SQL. But I'm stuck there due to a lack of tools.
I'm curious as to why this seems like a common mistake (I've seen it a few times already in this comment section).
Biased: you might want to look into DOE libraries. For IO I suggest ADIOS2 [0]. There's python bindings too.
One of the biggest things you can do is use a different storage type like BP (ADIOS) or hdf5. These are readable but binary. But to really determine how to speed up your problem you have to know where the bottleneck is. Is it IO or compute? With 100 workers (threads or nodes?) you aren't highly parallelized. I mean that could be a single node if it's threads.
If you have some good indexes and do some push-down work (give the database aggregation tasks to do instead of your python code), you should probably be more than fine.
For a 250Gb file.. should be ok.. maybe add some partitioning too.
If your latency requirements are slack, then you can get away with one machine, because you can reboot or reprovision it and carry on processing without meet your requirements.
If your latency requirements are tight, you don't have time to fail over anyway, so you might as well run one machine and make sure you can deal with failing to meet your requirements.
Go back to two when maintenance is done.
https://www.usenix.org/system/files/conference/hotos15/hotos...
I’m a C++ veteran btw and understand the point but big data is about how to process petabytes of I/O not how to consume CPU.
There's an incredible number of gigabyte and even terabyte scale problems that are consuming racks of blades when a little thinking and understanding of the problem being solved can be done pretty nicely on far fewer resources.
What's really happening is that to many people they think it's "easier" to simply rack more equipment into the cluster and end up shifting the complexity into cluster administration rather than programmer time.
Sometimes, that is the right thing to do. The problem is when the cluster solution also adds to the programmer-time complexity.
> I’m a C++ veteran btw and understand the point but big data is about how to process petabytes of I/O not how to consume CPU.
I'm not sure this is cut-and-dry. Back when I was working on Spark workloads, there was some interesting research being done on where the bottlenecks were for jobs. I think it turned out for a lot of jobs, infinite disk / network io didn't give as much of an improvement as you'd expect.
https://databricks.com/session/making-sense-of-spark-perform...
These are not big data problems, however, by definition.
1) We always wait for database, so performance of our code does not matter. This comes from places where ironically the whole database can fit into RAM. 10+ gbps connectivity - well it is almost commodity for business so the latency is not much of a bottleneck. Fast IO to store data - well imagine array of Optane drives. Not very cheap but really peanuts for normal business. All this means that purposely built data server which is a heart of many type of business residing on decent computer, can be blindingly fast and most of the businesses will never ever outgrow it. I've written quite a few of such servers serving loads of businesses in NA so hopefully my experience is not irrelevant.
2) Scripting languages are so convenient to use and save so much time and this is what matters as the salary is a main expense. - Personally I use those mostly for management/deployment/etc.etc type of scripts and maybe to quickly test some small ideas. I clearly see their benefits there. Anything that resembles a product that would actually run business. Sorry but experienced developer can implement those just as fast as in any scripting language and it will save a ton on maintenance.
3) And finally do not do premature optimization mantra . - In my opinion switching from scripting language to something like C++ has nothing to do with premature optimization. Developer can be very productive with compiled languages as they also have megatons of libraries for any imaginable task.
My guess, essentially holding their finger to the wind. Most orgs can't afford to do real engineering.
We were going to go all in on Snowflake with everyone on the team being for it. I sat down, read the original whitepaper, wrote a simulation of what the costs would look like with the current read/write statistics and tested a small batch of data on it to double check.
Turns out we would have paid between x500 to x10,000 what we were currently paying for using Postgres. I moved on three months ago, and last I heard they were trying to use Snowflake again.
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.
We implemented our own reference counting system to keep some of our sanity, and to at least try to avoid the worst memory leaks.
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.
This is because the allocator itself can have an unbounded runtime that takes milliseconds, causing you to drop.
In the past I've replaced malloc with an implementation that asserts if called on certain threads after init time.
For constant time allocations, try TLSF: http://www.gii.upv.es/tlsf/
It's one benefit of a gced language with compaction, allocations are typically bounded (except when they trigger a gc).
You should not be doing any memory allocation in the critical path anyway, so garbage collection is hardly a relevant factor.
"Capable" is plausible.
Sorry, I doesn't make the rules.
If you're backing things up to the same server, that's not enough. If the HA instances are running in the same server, that's not enough.
If there are other things besides that one physical server and it's power/network, you didn't include them in the cost, so the comparison is disingenuous there.
But the fact of the matter is quite simply is that any single physical server solution will never be satisfactory for backups or HA purposes.
You can't store your backups in the same place as your data and call it good - what do you do when you have multiple disks fail and your RAID can't be rebuilt? This happens. What do you do when operator error accidentally destroys the array? This happens. What do you do when there's a datacenter fire and the server burns up? This happens. None of these things should be a business ending event, but if you only have a single server handling quintuple duty, that's what it has a real chance of being.
If you need HA, a single server isn't good enough even if you've got multiple VMs running the service. What do you do when the utility power is out and the generator fails to kick on properly or they run out of fuel? Both of those happen pretty frequently. What do you do when there's a network outage at the DC? This happens. When someone fucks up BGP somewhere and now the prefix you used is being routed to god knows where? This happens. When you have any sort of physical server failure that brings your single box down? This happens. Any of those situations will take you offline and render your HA meaningless.
I'm not saying that any of these things are impossible to do when colocating your hardware - but they're not free, and they're not mentioned even at a high level in this story. And since we're not talking about running benchmarks on price/performance and instead talking about a service that a business needs to keep available to their customers to make money, these are important aspects to talk about. Everywhere I've worked, keeping our services available and being able to recover from hardware failure are far more important priorities than being able to optimize performance. And doing those things properly takes more than one physical server.
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.
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't look so funny any more. And then traffic doubled again.
Isn't that the conceit underlying this whole argument, though? Many systems won't ever get to the point where you have to scale in that way, if you build them efficiently in the first place.
Perhaps more importantly, for many applications, you'll be able to see the limit coming some way ahead, and if you've reached a size where you do need a fundamental restructuring in order to start scaling horizontally, that's going to be a nice problem to have and you'll also have the resources to do it.
I know several online systems that are handling significant traffic volumes perfectly well on a simple, single-server basis. They don't get bogged down in infrastructure and tooling issues, ever. They don't get confused by complicated cloud hosting issues, ever. They are free to spend almost their entire development budget on actually developing useful functionality, which is like a breath of fresh air in today's dev culture.
Obviously in the more serious cases they probably also have some redundancy for backup/failover purposes, but even that is simple and if necessary can probably be handled manually when you only have a handful of servers to manage. Here I do slightly disagree with one of Carmack's later tweets, in that I would argue 100 servers instead of 1000 is just accounting, but 100 down to 10 or fewer is also more of a qualitative change (albeit not exactly the same qualitative change as 10 down to 1).
You must have had significant in-memory shared state to encounter that problem. Right?
Had you adopted a less stateful model, you'd have looked rather pretty with two Java servers.
"Significant" is in the eye of the beholder. The core of the system was easy to make shardable. But you'd be surprised how many implicit assumptions creep in, how easy it is for ancillary parts to end up sharing state when it's easy. Also note that just because your state's in a database doesn't mean having two instances of the thing that accesses it will work, you can easily end up with an access pattern that assumes only one reader (for example) even though on paper there's no in memory state.
> Had you adopted a less stateful model, you'd have looked rather pretty with two Java servers.
Maybe. At the point where we're running 4 or 8 servers we'd have been facing much the same ops problems that they were. Java bought us an extra year or two of not having to deal with that, but also a significant amount of migration work when it just became impossible to stick to the single process model. At the end of the day we still kept the 5x latency advantage, which is definitely not nothing. But there were also definitely features that they brought to market quicker, and I'm pretty sure Ruby played a part in that.
Tradeoffs, tradeoffs everywhere. I left before the final outcome of that fight (for all I know it's still ongoing), but I don't think either company was being dumb.
Yes and no.
You'd need some ops work, but you'd need to worry a lot less about managing your infrastructure provisioning to keep costs low, e.g. reserved instances, dynamic scaling, etc. and putting out fires when you inevitable exceed your tight perf margins.
You could overprovision 24/7 by 50% and write it off. Your competitors couldn't.
Maybe he really meant to say 'application server'. I.e that there was server side code with non trivial compute/memory requirements for running business logic.
Back when people were writing their backend business apps in C++, COBOL, Java, etc, if there was ever a performance problem, you could usually just get a slightly bigger machine and grow your thread pools a bit. But once the web took off and Ruby exploded onto it, you couldn't do that, because it's an order of magnitude slower, and doesn't really do multithreading. But, as long as you follow twelve-factor discipline, it scales horizontally like a champ. So, we took to horizontal scaling over multiple VMs (and caching things in Redis instead of local memory or Hazelcast or whatever), and that's been the unquestioned way to do scaling ever since.
I'll bite. I think it actually counts not only that, but also the probability that the product will actually get to be developed, and not need to significantly pivot, therefore throwing all developer time spent on perfomance to garbage.
I remember reading about their routing debacle and realizing just how much work went into trying to get ruby to scale.
http://web.archive.org/web/20111108170021/http://david.heine...
Modern C# in net-core 3 can even match C++ at manually vectorized numeric code: https://github.com/dotnet/coreclr/issues/27909#issuecomment-...
You can JIT Python also using https://www.pypy.org/ but it's not the default and it's not 100% official and compatible.
Back around 2001 or so, I was hired at an online travel agency to assist in porting their entire system from C++ to Java. Management at the time was frustrated at how long it took to add new features in the C++ codebase - it could take months to get something working in some cases, and they blamed the programming language. Once we got everything working in Java, we found that we could, in fact, turn around feature requests much faster than they could in C++. The trade-off was performance problems: they (we) found that in the old C++ codebase, if you fucked something up, the whole thing crashed, and you had to fix it before you could get it to run. In Java, programmers could paper over their fuck-ups pretty easily so that they wouldn’t be noticed until they had created a snowball effect that caused everything to slow down. Since management was pushing for more features faster, they were incentivizing developers to do as little testing as possible and kick the can down the road. For the most part, management was OK with this: they just bought more, and more, and more servers to make up for the performance problems we were having from the quick-turnaround features they wanted.
totally agree. if all your backend server is mostly complex serialization & de-serialization, and pushing bytes to other sub-systems, i think many other languages have advantages over python.
wondering why no mention of go or rust though...
https://blog.acolyer.org/2015/06/05/scalability-but-at-what-...
Type hints made large python codebase switch from "Any change will blow up to my face" to "I can touch it carefully with protection gloves".
Through, it is still pretty easy to fool mypy and very far of the compile time guarantees that provide most static typed AOT compiled language.
And unfortunately, it also does not bring any advantage in term of performance.
At that point it makes more sense to use a statically typed language.
Much of code's performance isn't really reflected on to the scalability since mostly a tiny part of code is really ran a lot of time, and the other parts are just glues or management stuff or rarely used(not used in scale) features.
Of course, it won't work out to replace 1000 Elasticsearch servers - that's where the advantage of a true "big data" tool will show - but none of the clients really have data "that big".
That'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.
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...
I had a funny such experience lately in a job interview. I told the interviewer his misconception could be falsified with ~10 LOC summing a list with 2 threads.
If any operations were GIL-bound (which is extremely common, even if not intentional, by reliance on bytecode instructions dealing with CPython API under the hood, like attribute lookups or iteration special methods), then execution is probably interleaved serially and constrained by the interpreter’s GIL allocation, and slower than just summing serially.
I’ve seen a lot of people who are cocksure they know some contrarian “actually you can use threads” trivia about Python and just naively use the threading module or naively use the newish ThreadPoolExecutor stuff not realizing that no, in fact, it’s not somehow magically always GIL-avoiding to do so.
By having multiple concurrent IO requests from multiple threads? Can probably log detailed timestamps to see if IO requests were happening in parallel.
# main.py
import random
from concurrent.futures import ThreadPoolExecutor as Pool
items = [random.random() for _ in range(10 ** 7)]
def run(items, n):
step = len(items) // n
with Pool(max_workers=n) as ex:
res = [ex.submit(sum, items[i*step : (i+1)*step]) for i in range(n)]
return sum(r.result() for r in res)
if __name__ == '__main__':
import timeit
import sys
n = sys.argv[1] if len(sys.argv) > 1 else 1
time = timeit.timeit('run(items, %s)' % n, 'from __main__ import run, items', number=10)
print("%s\t%.3f" % (n, time / 10))
$ for x in `seq 1 16` ; do python3 -m main $x ; done
1 0.172
2 0.170
3 0.166
4 0.155
5 0.149
6 0.142
7 0.144
8 0.140
9 0.136
10 0.135
11 0.135
12 0.137
13 0.135
14 0.136
15 0.136
16 0.136(2) You're not measuring what you think you are measuring.
Take out the Pool altogether:
def run(items, n):
step = len(items) // n
res = [sum(items[i*step : (i+1)*step]) for i in range(n)]
return sum(r for r in res)
and the results are similar: 1 0.170
2 0.170
3 0.147
4 0.145
5 0.142
6 0.142
7 0.138
8 0.137
9 0.135
10 0.138
I have some guesses why it improves, but I'm not certain. It's definitely nothing to do with multithreading.EDIT: As an aside, you can speed this up 20x by using Numpy:
items = numpy.array([random.random() for _ in range(10 ** 7)])
def run(items, n):
return numpy.sum(items)
1 0.007
Supporting the original point that running code in low-level languages produces amazing speedups vs fancy parallelism methods.I’m pretty sure the time “savings” you are seeing here come from somewhere else. At a first glance, your copying the huge list while submitting it to the thread pool, this has overhead. Maybe lots of smaller copies are faster on your machine.
Been a while since I've used Python, but as far as I remember the GIL only affects Python objects. So if you use Numpy for operations, you can avoid the GIL.
Spawn a thread and handle disk or socket IO requests there? You can get fancy and use a thread pool so maybe 15 lines of code.
Not sure why you used the word “supposedly”. Threads have been in the standard library for a very long time.
I had multiple of those experiences. Even then people wouldn’t believe me so we had to look at Python C code and read about threads and IO operations in C and such. The other alternative is to write a deliberately slow socket server that takes say 5 seconds to respond then then write a threaded client to issue requests and seeing how they complete in parallel.
There are a lot of ways to handle the IO intensive scenario in python:
* Threading - Works with python libraries written in C, but now you need to add locks to your code to prevent race conditions. Not good for CPU heavy work because it’s switching context every ~100 instructions.
* Gevent - Requires minimal code changes, but it usually blocks when running code from python libraries written in C. This uses event loop style concurrency and automatically patches internal python libraries to switch context when IO occurs. This means less time spent unnecessarily switching context, so it can scale better than python’s threading.
* multiprocessing - Better for CPU intensive work, but requires more memory than other solutions. You don’t need to worry about race conditions since the processes are separate.
* asyncio - Requires code changes and using compatible libraries. It does event loop style concurrency that allows you to specify specifically when to switch context. Like with gevent, this means less time spent unnecessarily switching context.
* ...And there are probably a bunch of other ways I’m missing.
I’ve heard that this sort of stuff is simpler in Go.
https://erikengbrecht.blogspot.com/2008/06/what-does-io-boun...
The hard part is always that you have more data than can fit into memory, and need complex prefetch solutions to parallelize getting the next batch of data while one batch’s numerical linear algebra computation is in progress.
Many libraries handle this transparently for the user in an extension module, such as Keras & PyTorch.
I think it’s misleading to act incredulous that this is the bottleneck ... it doesn’t have anything to do with Python, GIL, etc. (and there are easy-to-maintain solutions for this in Python).
This person was actively arguing with me about what it was. It's one of many battle stories for why I pretty much just assume everyone on reddit is stupid unless shown otherwise.
Neither of these are usually the case for web application servers.
If the choice is between hiring one good C++ programmer or 15 really dumb Python "backend engineers" (and a team of QA's and sysadmins to support them), what do you think your pointy-hared corporate boss would chose?
Personal productivity is generally going to be slower in C++ than it is in Python. In most situations you would gain more productivity out of a similarly skilled Python dev as you are a C++ dev, so you'd probably need to hire more C++ developers.
Unless your argument is "C++ devs are smart and Python devs are dumb", in which case, let's not start calling people names over the language they use.
No, it entirely depends on the skill and experience level of the programmer.
> In most situations you would gain more productivity out of a similarly skilled Python dev as you are a C++ dev
No, a good programmer with equally good knowledge of both languages will code equally fast in both.
> This is a false dichotomy. You don't have to choose between 1 C++ developer and 15+ package of Python developers.
You failed to see the point. Large teams of clueless programmers doing things slowly and badly is a feature of the system, not a bug. KPI's for managers don't include lowering headcount and cost cutting as an incentive. (And trust me, you really wouldn't like it if they did.)
> Unless your argument is "C++ devs are smart and Python devs are dumb", in which case, let's not start calling people names over the language they use.
Yet that's effectively what you just did in your specious 'productivity' argument.
Last round, for the second best candidate who we hired at 130% the salary we initially offered, after the best candidate was snatched under our nose for what we were told was twice the salary we were offering:
>"Last question, I saw that you wrote a 100 line function here, is this because you ran out of time?"
>>"No. I don't like to break up my functions. Having many small functions is confusing and bad practice."
>What am I doing with my life?
128GB/sec? sure! and 256GB/sec is coming.
With 10Gb, 40Gb and 100Gb internet links becoming mainstream the roadblock to having cool stuff is developers to make it.
Opting for a performant but not scalable solution is basically an acknowledgement that:
- The project will only succeed up to a certain point.
- 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.
Not many projects are willing to accept either of these premises. Nobody wants to set an upper bound on their success.
Also, it should be noted that no language is 'much faster' 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's not fair to say that a language is slow because some of its default advanced operations are slow.
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.
Time complexity of any given algorithm is way more significant than the baseline performance of the underlying language.
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.
Said that, I believe Rust has a great future in data processing. Just take a look at Apache Arrow Rust bindings and Ballista (https://news.ycombinator.com/item?id=20456273)
That said, I think the benchmarks could use some tweaking. I'm not sure they are representative.
https://www.reddit.com/r/rust/comments/ap2047/john_carmack_w...
I think it’s a valid point that the reasons why C++ is good for perf - compiled, statically typed, low-level, manual memory management, high degree of control over memory layout - would also apply to Rust. If they don’t then that would really call into question positive claims being made about Rust.
IIRC, his conclusion was mixed: a lot of it was obviously beneficial and worth having turned on, but much of it wasn't, and going forward he intended to make it a limited but continual part of his toolchain.
So my interest in whether he'd tried Rust was whether he'd compared Rust's changes like the borrow checker against his earlier conclusions on writing good C/C++. Cute that he's tried and liked it, but I'd really like to see a more in-depth comparison from him.
2. Horizontal scalability is too much complexity/work. Just apply the correct amount of optimization when you initially write the code.
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.
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.
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?
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.
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.
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.
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.
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.
[1] https://blog.pragmaticengineer.com/distributed-architecture-...
Most companies or startups or even bigtech are not big enough for these problems.
All these complexities are horrible, but good for the AMZN stock price, as devs keep spooning up a ton of VMs
Python programmers are much easier to hire, though - you already need a good C++ programmer on the team to hire another one, because HR and corporate management can't into proper hiring process.
This last factor is the overarching most important one for BigCorp Enterprise Inc., not development speed or cost.
This is obviously not strictly true, always. A skilled programmer will use the proper tools for the job.
If you for example is tasked with writing a backend service exposing a GraphQL API, I think it would be foolish to do this in C++, and would bet that the average Python programmer would do it quicker than even a top-tier C++ programmer (if the latter would be hellbent on doing it in C++).
Especially when working with MVP's (or new projects in general), the ability to leverage already existing tools and frameworks are key to rapid progress. This doesn't necessarily have to be scripting languages, but the Python/Node/Go/etc developer would have a working GraphQL server up and running connected to a database of choice within an afternoon while the skilled C++ developer would have to spend at least a few days implementing a GraphQL server mostly from scratch [0].
[0]: A quick Google show that schema parsers exists for C++, but nothing matching the frameworks/library available for more web-fashionable languages.
a) Writing a schema parser is not rocket science. In fact, for a good programmer implementing their own GraphQL library would be quicker than integrating some third-party library. So your first point ("average Python programmer would do it quicker than even a top-tier C++ programmer") is absolutely wrong.
b) There's no value in an MVP that does something generic that is already available in off-the-shelf libraries. Your GraphQL example is pretty pointless because it doesn't actually do anything.
> ...the Python/Node/Go/etc developer would have a working GraphQL server up and running connected to a database of choice within an afternoon
Well, no. By the end of the week they'll still be arguing about which package manager to use, whether TDD is a good idea, what makes a microservice 'micro' and how to configure Kubernetes.
I'm hiring 25 D programmers, so I suppose it very much depends on what you mean by practically!
At single-node scale, development costs dwarf hardware costs of scaling horizontally.
Modern SW trends are horrific
The second tweet of the discussion:
> 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.
I'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.
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's engineering background however, it is unsurprising why Java/C#/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 'Hadean' is using Rust for their platform.
This really is just not true.
Financial, real-time style High Frequency Trading apps are often written in Java - not C++.
Much of the JVM is not a VM, it compiles to machine code - in an optimised manner. For starters.
Given how difficult it is to develop safely in C++ I can hardly think of a reason to ever use it on the backend.
Generally, for a 3D game manual memory management and explicit data layout are critical. For example, it's common to use custom memory allocators with a region for each frame, a region for each loaded level, etc... This is then much cheaper to simply drop on the floor than any kind of object-by-object cleanup, whether that is reference counting, garbage collecting, a traditional heap, or whatever. Even Rust can't yet compete with this!
Similarly, many game engines use ECS systems or in-memory columnar data layout to (structure of arrays instead of arrays of structures) to enable SIMD instruction sets such as AVX.
Java can be coerced into doing much of the above, but it generally takes a ridiculous effort to approach what comes nearly effortlessly with a language like C++ or Rust.
Even C# is a better choice than Java, as it monomorphises more code and recently had a range of extensions[1] added to reduce GC pressure such as stackalloc, Span, Memory, MemoryPool, SequenceReader, ValueTask, etc...
I've bought and played several games written in C#, but other than Minecraft I'm not aware of any popular real-time games written in Java in the last 15 years or so. Meanwhile, Minecraft is not at all smooth on my very high end gaming PC in 2019 despite being 8 years old. (I'm sure this can be eliminating by tweaking some settings, but it's indicative of the problem.)
I say this as someone who used to professionally develop browser-based Java games back in the early 2000s and had to personally jump through hoops to reduce heap allocations to avoid GC pauses.
[1] https://docs.microsoft.com/en-us/archive/msdn-magazine/2017/...
They're written in a very specific style of Java, where you take pains not to allocate, which looks a lot more like C++ than idiomatic Java. Operationally, strange rituals are followed to avoid recompilation or other otherwise normal runtime activity during trading hours. The app will be started on sunday night, and the team spends the week praying it doesn't need restarting during the week.
You can do HFT in Java, but it's a dancing bear.
No. That is high level language propaganda and simply not true.