Live data from Hacker News

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

twitter.com

121–130 of 376 posts

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

#121
post #114

Earlier quoted context omitted.

Out of curiosity, what is the field for which you find this to be true?

If you are writing C++, any field! Just use std::shared_ptr and std::unique_ptr from the standard library, along with std::make_shared and std::make_unique.

std::shared_ptr uses CAS atomics, which in heavy multithreaded code (multiple threads operating on the same pointers), can have surprising overhead in some situations.

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

#122
post #114

Earlier quoted context omitted.

Out of curiosity, what is the field for which you find this to be true?

If you are writing C++, any field! Just use std::shared_ptr and std::unique_ptr from the standard library, along with std::make_shared and std::make_unique.

C++ shared_ptr unfortunately is artificially slowed down by multithreaded synchronizations. The count in the control block is always updated atomically. But I frequently need to use them not because my data is shared by multiple threads, but because the ownership situation isn't static. Consider for example implementing a single-threaded persistent tree.

This means people frequently need to reinvent their own reference counting mechanisms.

Rust does this right. Rc and Arc.

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

#123
post #60
post #41

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.

I semi-seriously think the entire modern shape of the cloud is a result of Ruby being really slow. 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…

Never forget "It's boring to scale with Ruby on Rails" (2005)

http://web.archive.org/web/20111108170021/http://david.heine...

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

#124
post #114

Earlier quoted context omitted.

Out of curiosity, what is the field for which you find this to be true?

If you are writing C++, any field! Just use std::shared_ptr and std::unique_ptr from the standard library, along with std::make_shared and std::make_unique.

This is the quickest way to kill your performance in C++. I guarantee it wasn’t what Carmack was talking about.

I used sharedptr extensively in a game engine. Whoops: suddenly 20% of the frame time was gone, never to be recovered. Once that performance is gone it’s almost impossible to get it back, short of rewriting every system.

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

#125
post #75
post #60

Earlier quoted context omitted.

I semi-seriously think the entire modern shape of the cloud is a result of Ruby being really slow. 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…

The push for the need of scaling out started with Ruby and Python's lack of performance. The reason being pushed at the time was, "developer time was more expensive than hardware." Well, that didn't count the amortization of developer time over the lifetime of the product once the product was developed.

If hardware speeds and capacities had continued to increase as rapidly as they used to, there might have been some truth in that. Buying a computer with a faster CPU or a bigger disk or more RAM was a relatively cheap solution to a lot of performance problems for a long time, in no small part because it typically required zero changes to the software itself. However, once you're talking about qualitatively different hardware architecture (scaling out instead of up) and therefore also qualitatively different software architecture, it's far from obvious that the premise still holds or that we should even expect it to.

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

#126
post #97
post #54

A site for proof. It keeps amusing me on what hardware/software Stack Overflow/Stack Exchange is running on: https://stackexchange.com/performance 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

> That means we transfer 55 TB data / month 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

[deleted]

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

#127
post #105
post #96

Earlier quoted context omitted.

There is a significant amount of question submission, commenting and voting going on on SO.

A slim subset of humans typing things is not what I would label "write heavy". Write heavy is more like 100k+ devices out in the field sending their current position every 10s. That's still very manageable, but requires some thoughtful design.

10k simple updates per second is hardly high bandwidth. I knew people handling similar workloads on a 1U server 10 years ago.

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

#128
post #42

Earlier quoted context omitted.

> I'd like to see these 10 lines that supposedly avoid the problems with 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.

>Threads have been in the standard library for a very long time. Yes and still run the risk of running into GIL problems. You claim to have shown 10 lines to an interviewer that proved he was wrong about the GIL still being an issue and I've yet to see an example of it not being one when using pure python. Yes there are certain cases where you don't hit the GIL, no that doesn't mean it isn't still an issue when deali…

I just meant that one way to make threads "work" is to use IO, so I assumed the OP did a trick along those lines. Basically two threads can receive data or read from disk a the same time. Same thing can be accomplished with a select/epoll setup but threads would just be less lines of code.

Otherwise another trick is to identify a call which uses extensions or releases the GIL once it goes into C.

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

#129
post #67
post #51

Earlier quoted context omitted.

> How did you ensure those threads would actually execute concurrently? By having multiple concurrent IO requests from multiple threads? Can probably log detailed timestamps to see if IO requests were happening in parallel.

Summing lists isnt IO

You're right of course. I assume the OP used a trick by going via IO somehow. Though granted, it might require having a forking server to do the actual summing or using another language, which would be more than 10 lines of code

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

#130

I'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'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 ser…

This sounds like an amazing war story that I just want to hear more of. Is there any more? What's your c++ stack like?
Post reply on HN