rubyherokusubdomainlinguistics

How can I programmatically generate Heroku-like subdomain names?


We've all seen the interesting subdomains that you get automatically assigned when you deploy an app to Heroku with a bare "heroku create".

Some examples: blazing-mist-4652, electric-night-4641, morning-frost-5543, radiant-river-7322, and so on.

It seems they all follow a adjective-noun-4digitnumber pattern (for the most part). Did they simply type out a dictionary of some adjectives and nouns, then choose combinations from them at random when you push an app? Is there a Ruby gem that accomplishes this, perhaps provides a dictionary which one could search by parts of speech, or is this something to be done manually?


Solution

  • Engineer at the Heroku API team here: we went with the simplest approach to generate app names, which is basically what you suggested: keep arrays of adjectives and nouns in memory, pick an element from each at random and combine it with a random number from 1000 to 9999.

    Not the most thrilling code I've written, but it's interesting to see what we had to do in order to scale this:

    With so much work going to scale this approach we had to ask whether there's a better way to generate names in first place. Some of the ideas discussed were:

    Excited to see what we'll do next time the collision alert triggers!

    Hope this helps anyone working on friendly name generation out there.