So in your DNS zone you can tell it to route all accounts that start with the letter 'a' to server with IP 1.1.1.1, letter b to IP 2.2.2.2, etc. Server with IP 1.1.1.1 will not only run a headless web app but also route SQL queries to a db shard (all relational data for users starting with the letter a).
This level of "user" partitioning can be deeper. So it's not just the first letter of the user but two or three more letters/numbers. So joe.threewords.me would be on a different server than j4mes.threewords.me (That's j.o.threewords.me vs j.4.threewords.me).
Regards
Joe