User-friendly way to generate a URL from the user name?

I would like to create a page upon registration on my site based on user name, e.g. http://example.com/john-doe

My concern is though it’s need to be unique in the most user-friendly way. E.g. you could add john-doe-2 but it’s not cool for second John Doe (“why am I second?”).

How can I make sure it’s unique? I’d still want to have name in URL. Should I add a random number? How small should it be?

Is there a better way?