There's nothing special in nostr relays, they are just backend servers that can scale horizontally. If there were problems in divines relays, they could be easily solved. Nothing about nostr itself is the scale issue, there may ofcourse be bad code in a nascent protocol.
Discussion
There is nothing special in nostr relays is the exact problem. You need something special to scale.
Relays physically cannot scale vertically, even strfry, which I'll be the first agree is tight c++ code, will max out before it supports anything at scale just due to write limits. You'll always hit a write wall on the database, and no code will remove that wall for you.
Relays cannot scale horizontally either (to millions) due to coordination issues, latency issues (especially tail latency), the backplane limit, state bloat quicksand, and also just vertical maxing out of individual relays in the horizontal plane. Again no code will fix this, you're bumping up against hardware and the laws of physics.