4 ms·
That’s assuming CPU bound workloads. C++ spends just as long as Ruby waiting on a database query.
by Retric 5y ago
That’s assuming CPU bound workloads. C++ spends just as long as Ruby waiting on a database query.
- omegalulw 5y agoNot always. C++/C are also typically better in memory footprint. You can run more threads in the same server, so better qps.
- jzoch 5y agoUntil the data store you grabbed is written in Ruby too :)
- PragmaticPulp 5y ago> That’s assuming CPU bound workloads. C++ spends just as long as Ruby waiting on a database query. Some of the TechEmpower benchmarks have a significant database component as well. Obviously if you have database queries taking 0.5s or more then it's a different story, but in my experience the server language/framework still has a large impact on total performance even with the database in the equation. In my experience, memory footprint is also a huge variable. For example, I rewrote a certain gRPC service in Rust and cut the memory usage by almost 80% relative to the initial implementation in a higher level language. We weren't bottlenecked on requests/second performance but being able to scale down our memory usage had a huge impact on cloud costs.
- yen223 5y agoThere's the Fortunes benchmark, that involves reading off a database: https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=fortune https://www.techempower.com/benchmarks/#section=data-r20&hw=... Something to observe from those benchmarks is that "fast" languages are still fast in those benchmarks. The server isn't waiting on I/O 100% of the time - it still has to do serialization and parsing and all other CPU-bound tasks, and those still benefit from a "faster" language.
- tylerhou 5y agoYou can hide latency with sufficient parallelism. Since read requests are trivially parallelizable, as long as your database queries are mostly reads the database latency is probably not the limiting factor for throughput. (Even if your C++ program processes too many requests for one replica to handle, it's not hard to round-robin to multiple database replicas.)
- ksec 5y agoFiltered in Fortunes Cookies, Full Stack, ORM Only, MySQL / Postgres DB, and Realistic Approach, the difference is still 50x. That is already lower than the RAW SQL approach from 100 to 150x. And if we just look at .Net and ASP, these were done before all the optimisation came in latest .Net and ASP.net version.
- ezekiel68 5y agoThis is a good point, and there are ways to take advantage of this. The c++ frameworks that beat rust advertise in their repos that they are using a forked PostgreSQL DB driver which has been re-written to be asynchronous. There's a js framework named just-js which tops the current (nightly) DB Update benchmark on TechEmpower and I suspect they are doing the same. Additionally, Java, python, and ruby frameworks tend to gobble RAM (I work in a large corp with many deployed Java web services). This requires instances to autoscale based on mem usage or to use instances with more mem. Rust and c++ frameworks often utilize a fraction of the memory for the same service (yes, we've tested this). So we can use smaller and/or fewer tasks/instances in our autoscaling pools.