The queue isn't malfunctioning, it just doesn't work the way you think it works.

There is a hard limit on simultaneously logged in players. Once this limit is hit, you get 1017s.

Once a certain number of people have logged out, the restriction is lifted and floodgates opened, but the server can only process logins so fast. So in the case where a ton of people try to log in simultaneously, this is when the queue kicks in.