Hacker News new | ask | show | jobs
by mabbo 997 days ago
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 doesn't need to- you can scale anything with enough partitioning.

3 comments

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.
That's like saying the leading F1 team is investing in optimizing side mirrors, therefore they believe side mirrors are the component with the most opportunity for improvement.

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

> The fact is that performance oriented organizations optimize everything unless they have math telling them it isn't worth optimizing.

Most companies don’t have unlimited budgets. Performance-oriented organizations profile and then spend money where profiling tells them to. Shopify isn’t hiring people to contribute to MySQL or Redis internals. They hired a full team to work on Ruby internals, not just creating YJIT, but also on CRuby’s memory layout, hiring the lead on TruffleRuby, and funding academic programming language research on Ruby.

No company has an infinite budget to “optimize everything”. It is clear where internal performance testing pointed Shopify (at Ruby) and with double digit gains being extracted year after year, their profiling didn’t lie. And other Ruby on Rails shops are seeing similar double digit performance wins, not on fake benchmarks, but on actual page load times and traffic that can be handled by a server.

Disclaimer: I'm a member of the Ruby & Rails infrastructure team at Shopify and Ruby committer.

> Shopify isn’t hiring people to contribute to MySQL or Redis internals

You are not wrong, but the main reason is that contrary to Ruby, MySQL and Redis are used by a lot of huge companies and are themselves owned by companies with full time people on it.

In comparison Ruby is still mostly a volunteer ran project that receive little funding and effort relative to its importance.

As for why trying to make Ruby faster at all in the first place. It's not because it was too slow, it's mostly just that at our scale, the engineering time spent on optimizing the runtime pretty much pays for itself.

But that's nothing specific to Ruby, in most very large software companies you will find similar efforts. e.g. I remember Twitter had a team working on the JVM, etc.

thank you for that insight! If I had to guess, early on shopify had a choice to say jump to Java or a JVM-based language and scrap Ruby altogether, but they chose that the benefits of ruby outweigh the benefits of java's performance. So now given that shopify is large enough spending $1MM to win $5MM on infrastructure yearly is easily worth it.

In any case, I am very grateful to Shopify because I think if they decided to switch over to java back in the day, ruby may actually be a mostly dead language by now.

Most companies don’t have unlimited budgets. Performance-oriented organizations profile and then spend money where profiling tells them to.

The bizarre part here is that anyone who paint themselves into a corner with ruby, then decide that they need to implement an entire new fancy VM instead of just find targeted bottlenecks and rewriting them in C++. They writing complicated native programs to make a VM that is only 15% faster when they could rewrite specific sections that are slow and speed those up by 200x or more.

I understand that it's a metaphor but F1 teams did really optimize side mirrors more than once, leading to controversies

Mercedes 2022 https://www.the-race.com/formula-1/mercedes-2022-f1-car-make...

Williams 2019 https://www.autosport.com/f1/news/williams-modifying-front-s...

Ferrari 2018 https://www.autosport.com/f1/news/how-ferraris-formula-1-mir...

Of course, most teams do. Some teams have had 2 revisions to side mirrors this season.. and of course it didn't decide the WC, which is my point. Organizations don't merely optimize "the bottleneck" they optimize everything worth optimizing.
It's easy to believe (and probably true) that there are some low-hanging fruits in a place nobody looked at before.
No one disputes that Ruby is slow.

But you picking “mirrors” in your analogy makes it sounds like a premature optimization.

The reason why perf isn’t typically an issue with Rails is the design pattern is to leverage heavy caching.

The use of caching is to address the slowness of Ruby.

The two major areas where caching is used in Rails are:

- database queries

- template rendering

First one because round trip to db + running the query + allocating ORM result objects that otherwise get thrown away.

Second one because allocating a ton of strings that get join'd and thrown away.

> No one disputes that Ruby is slow.

I am, because the blanket statement doesn't make sense without context. Also that view is largely biased by the typical assumption that Ruby == Rails.

Well objectively, one could say both Ruby and RoR are slow. The first via The Computer Language Benchmarks Game[0], and the latter via TechEmpower Web Frameworks Benchmarks[1].

In practice though the database is doing most of the work, most of the time so is typically slower than both.

[0] https://en.wikipedia.org/wiki/The_Computer_Language_Benchmar...

[1] https://www.techempower.com/benchmarks

> "Also that view is largely biased by the typical assumption that Ruby == Rails."

Given that the predominate / vast majority use case for Ruby is for web development and Rails being the dominate Ruby web framework ... it's a fair assumption & characterization for people to make that the Ruby == Rails use case.

No, they both matter. The database can handle X shops per partition, and the rails host can handle Y shops per partition.

If rails were half as fast, you'd need twice as many rails hosts (but no more databases).

> but no more databases

Sort of. Twice as many rails hosts means more DB connections which generally means more load/memory on the DB or more load/memory on the external connection pooler.

It's only a bit of incremental load, but it's easy to overlook how many other systems need to run to make Rails scale.

No he’s his examples he’s talking 50 stores over 10 machines vs 50 stores over 5 machines. Both would require the same DB count, but the second would save on server costs for stores.
I think the above means (if I do get the point) that databases scale in terms of both requests per second and number of active connections.

Having 1000 connections doing 1 request per second isn't the same as having 1 connection doing 1000 requests per second.

But, and I could be wrong, the larger factor is the number of requests per second.

This entirely depends on the database you are using, and if you are using a connection proxy in front of your database.
There are of course a lot of things that cross store partitions, e.g. ShopPay.
>That's not on a per-host basis.

I'm sorry, but this is one of the silliest nit picks ive ever seen on this site. Of course 1 million rps and 3TB/s isn't coming from a single host. 3 TB/s is far beyond the throughput of any network I've ever seen, considered or thought of, short of maybe a data center (and I don't work in that domain). 1.3 million requests per second is far beyond the capacity of pretty much any hardware available right now.

The second paragraph explains the argument. Seems spot on and relevant to me.
The point is, it's not Rails that is scaling here.