Earlier quoted context omitted.
Rails scales fine. People use that as an escape hatch when they don't know how to write performant code.
You don't even have to write performant code. You can just start as many instances of the rails app as you want. The bottleneck is usually the database.
Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
21–30 of 158 posts
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#22Earlier quoted context omitted.
That's not on a per-host basis. Shopify's design is, quite fortunately, one that partitions really well, as each store is completely independent of each other. Each store can be assigned to one pod, each pod can have as many hosts as it takes to optimize the use of a database instance, and then you can add more pods as the need arises. Edit: to be clear, that's not to say Rails can't scale. It can. It's just that it…
Sure.. but isn't that a database problem and not a rails problem?
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#23Earlier quoted context omitted.
This is a particularly valid concern given ruby+rails seems quite memory inefficient to begin with. I've sometimes had smallish apps on 500mb heroku dynos crashing due to memory slowly climbing and eventually slowing things down as the dyno uses swap, and eventually 500mb of swap. IME ruby+rails doesn't seem to free up memory after it uses it, and that causes problems as the hours go by until the pod/dyno crashes or…
Ruby processes don't return the memory to the system,they reuse memory already allocated. This is for efficiency - allocating and freeing system memory isn't free. Even if it did, your peak memory usage would be the same. It doesn't allocate memory it doesn't need. If your memory usage doesn't plateau you have a memory leak which would be caused by a bug in your code or a dependency. But 500 to 1gb of memory required…
That’s why good modern allocators like mimalloc and tcmalloc return memory when they notice it’s going unused, so that other services running on the machine can access resources. And this is in c++ land where things are even more perf sensitive.
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#24Earlier quoted context omitted.
Was it difficult to switch? What were the downsides / tradeoffs? (I read about jemalloc recently but don't know enough about it to confidently pursue it, but may try it on a small app if it's straight forward).
Super easy and have not had an issue with it in over 10 years of using it. There is an example here on how to do it with docker image. https://mailsnag.com/blog/optimized-ruby-dockerfile/ .
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#25Earlier quoted context omitted.
Sure.. but isn't that a database problem and not a rails problem?
Well, Shopify is investing in optimizing Ruby, so they believe Ruby was the component with the most opportunity for improvement. And the results are showing there was indeed lots of places where improvements could be made.
The fact is that performance oriented organizations optimize everything unless they have math telling them it isn't worth optimizing.
The "weakest link" belief is pure conjecture
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#26Earlier quoted context omitted.
Ruby processes don't return the memory to the system,they reuse memory already allocated. This is for efficiency - allocating and freeing system memory isn't free. Even if it did, your peak memory usage would be the same. It doesn't allocate memory it doesn't need. If your memory usage doesn't plateau you have a memory leak which would be caused by a bug in your code or a dependency. But 500 to 1gb of memory required…
That kind of thinking is a bit flawed unfortunately. You might hit your peak for 20 minutes a day but you’ve provisioned your system for that temporary worst case for the entire day and other services are paying that penalty. If it’s the only thing you’re running, maybe. But in practice there are other things you want to run on the machine to improve utilization rate (since services are not all hitting their peak sim…
But if you really do need to cheap out you can generally configure your app server to kill idle worker processes, or bounce them on a schedule to return memory to the system, and hope.
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#27Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#28> 1.27 million requests per second > 3TB/minute of traffic "rails doesn't scale"
Also what is the cost in man hours spent on optimizations and profiling.
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#29Earlier quoted context omitted.
Ruby processes don't return the memory to the system,they reuse memory already allocated. This is for efficiency - allocating and freeing system memory isn't free. Even if it did, your peak memory usage would be the same. It doesn't allocate memory it doesn't need. If your memory usage doesn't plateau you have a memory leak which would be caused by a bug in your code or a dependency. But 500 to 1gb of memory required…
That kind of thinking is a bit flawed unfortunately. You might hit your peak for 20 minutes a day but you’ve provisioned your system for that temporary worst case for the entire day and other services are paying that penalty. If it’s the only thing you’re running, maybe. But in practice there are other things you want to run on the machine to improve utilization rate (since services are not all hitting their peak sim…
Re: Ruby 3.3's YJIT Runs Shopify's Production Code 15% Faster
#30> 1.27 million requests per second > 3TB/minute of traffic "rails doesn't scale"
Ok now what is the cost of all the instances. And how many instances would be required if Go/Rust would have been used? Also what is the cost in man hours spent on optimizations and profiling.
Zero. Because Shopify would have waited until Rust came out in 2015, instead of launching in 2006, and they would never have gotten off the ground and been another failed techbro startup that instead of getting shit done, bikeshedded over languages.
PHP and Ruby apps have generated far more revenues than all the Rust and Golang code combined.