News for hackers. Stuff that matters.
Re:Using Postgres for Everything by ndriscoll on Monday May 20, 2024 @04:24PM (#40419883)
Where big iron might be something between a raspberry pi with an NVMe hat and a gaming PC.

My 6th gen i5 (4 cores) can render ~15k page views per second with database queries, or several times that serving cached pages from nginx. 150 requests/second wouldn't be noticeable if I were using it for gaming at the same time.

Re:Using Postgres for Everything by kgeist on Monday May 20, 2024 @04:57PM (#40420289)
Another team's product at our company runs inside a Kubernetes cluster which consists of lots of microservices. CPU's are at 80% all the time. Redis, RabbitMQ, MySQL, Elastic Search etc. There's no number crunching, mostly CRUD with some business logic on top. It requires a separate operations team to manage it (otherwise this goldberg machine easily explodes).

A few days ago I asked our ops team, what's our rps? ~500. Out of curiosity, I ran a few benchmarks to stress test my monolithic pet project in Go with a single DB for everything and it easily handled 15k/s on my home computer, too, without any special optimizations. I understand its load is totally different from our production server, and my benchmark is most likely flawed, but the order of magnitude of difference is interesting.

I was told the production cluster also has additional 500 rps just for communication between the microservices. I suspect there's just too much overhead in their setup: communication between services, serialization of data between different DBs, etc. If it was a single modular monolith with a single DB, I suspect it could be faster and easier to maintain... Another issue is that they also sell it as an on-premise solution. And with the complexity growing, it now often fails to run on clients' infra.

Re:Using Postgres for Everything by Nextgrid on Monday May 20, 2024 @07:05PM (#40421652)
I bet those CPUs are mostly busy just de/serializing JSON, processing HTTP and TLS for all the various intra-service calls.
Re:Using Postgres for Everything by ndriscoll on Monday May 20, 2024 @05:19PM (#40420544)
We had pretty much the same deal at my last job. We had somewhere around 50 services that ought to have been one. Batch processes would take hours as they made 10s of millions of internal API calls (which could also fail of course) instead of running for a minute or two just doing the work with a couple SQL queries. Who knows how many hours wasted debating the boundaries and contracts between services when those layers didn't need to exist in the first place. Millions a year spent on hardware. All in the name of "scalability" when we also had a few hundred rps, and the thing obviously had scaling issues exactly because it was being done that way. Very frustrating.
Re:Using Postgres for Everything by Scarbutt on Monday May 20, 2024 @08:22PM (#40422437)
Not to disagree, but if your company has around 300,000 LoC in business logic and your pet project has 1,000 LoC, the processing times are going to be significantly different.
Re:Using Postgres for Everything by kgeist on Thursday May 23, 2024 @01:36PM (#40457597)
It has more business logic, true, but the average request is just the usual "retrieve an object from the DB, modify a few columns, and save back". Just like in my project. They have a higher LoC because they have more use cases, but a single use case alone is not very complex and is comparable to my project's code in its complexity. So I think it's fair to compare the two when it comes to rps.
Re:Using Postgres for Everything by earnesti on Monday May 20, 2024 @05:09PM (#40420444)
But imagine how many billable hours were created with this thing
Re:Using Postgres for Everything by Nextgrid on Monday May 20, 2024 @07:16PM (#40421797)
Unless it's a consultancy project it's less about billable hours and more about internal busywork and resume fodder.

In a ZIRP/startups environment this kind of BS was rewarded by the market and thus "engineers" would take any opportunity to build up such unproductive over-engineering skills to polish up their resume for the next opportunity.

Re:Using Postgres for Everything by rovr138 on Monday May 20, 2024 @05:03PM (#40420368)
At first I was "eh, if it runs okay and can just be scaled, it's fine as long as they know the limits, how it scales, and it's maintained".

> And with the complexity growing, it now often fails to run on clients' infra.

then I saw this and... yeah completely different beast

Re:Using Postgres for Everything by SavageBeast on Monday May 20, 2024 @04:42PM (#40420099)
Thanks for the metric - I wouldn't have naively assumed that kind of through put was possible on such a setup.
Re:Using Postgres for Everything by ndriscoll on Monday May 20, 2024 @05:41PM (#40420753)
There are some caveats to that, like you can't get anywhere near that with TLS unless you have hardware offload (I've seen claims that it's ~1% overhead, which seems to be 15 years out of date. For cached content, TLS handshakes cause more like a 90% reduction in throughput on my computer). Unfortunately Intel segments this, so that offload isn't on consumer chips. You might be able to use a cheap firewall device with QAT as a reverse proxy to terminate TLS though (it is on some cheap atom processors). I don't have one to measure what it can do. Obviously that's not something a large corporation would do, but for a small bootstrapped project, it ought to take you way farther than you could need.

Also batching database queries is important for high throughput.

Re:Using Postgres for Everything by vineyardmike on Tuesday May 21, 2024 @01:03AM (#40424336)
> Where big iron might be something between a raspberry pi with an NVMe hat and a gaming PC.

At my last startup (with ~3 technical employees), I was talking to the CTO about our cloud spend and planning for properly scaling infra after we got our first customer. We weren't "a SaaS website", but (hand-waving) we did complex physics modeling and analytics on data streams. The (physicist) CTO had heard of k8s and cloud stuff and wanted me to investigate how we should scale our cloud. He was convinced it'd be expensive to do "all those physics calculation with 64 bit numbers".

I showed him our entire cloud - gateway, database(s), physics modeling, metrics collection, log aggregation, etc - running at 1000x estimated 1-customer load from a MacBook. I offered to set him up a personal raspberry pi to stress test before a k8s cluster.

We ended up with a sensible single medium EC2 instance running everything, with some extra stuff for fail-over. AFAIK the only change made after I left was using a cloud-vendor DB.