Let's do this.
1 - Characters come in three flavours.
Okay there are certainly more once you get into sub-types and stuff, but for the moment we're trying to keep things simple.
The first, and most obvious, are the Main Characters. These are the folks who drive the plot; whenever they perform an action the plot is moved forward in some way as a result of what they do (or, in some cases, don't do.) The ideal amount is generally between 2 and 5 - that's not to say you can't have more or less than that, but if you do you're making your job a lot harder. Main Characters most obviously include the protagonist, the antagonist and the POV character, but can also include love interests, sidekicks, mentors and shadows.
Next we have the Minor Characters. These are just as important to the plot as Main Characters and can even have their own agenda within the plot, but their role is merely to assist (or hinder) Main Characters in moving the plot forward - they don't have any direct effect on plot events themselves. Gollum in Lord of the Rings is an example of a minor character, because even though he constantly schemes to get the One Ring back (which could otherwise paint him as the Antagonist to Frodo, a Main Character) he's doing it for his own reasons and not as part of the overall plot of defeating Sauron and ridding Middle-Earth of his evil influence. For Minor Characters, between 5 and 10 is usually the most manageable amount. Having more than 10 is... not impossible, but certainly harder to micro-manage, and having less than 5 is fine - as long as it doesn't leave you with more Main Characters than Minor ones. If that's the case it's highly likely some of those Mains aren't really Mains after all, and need demoting for the good of the plot.
And finally we have the Extras, otherwise known as walk-ons or, in Star Trek parlance, Redshirts. These guys are mostly used for the practical stuff of filling space and performing background grunt work while the Main and Minor characters get on with plot stuff. Crowds are extras, along with retail and service staff in places your characters visit, police and emergency service crews and any other random strangers that pop up for one scene and then vanish, never to be seen again. There's no limit to how many of these you can have, so long as you recognise the expendability of their role. Which brings me neatly on to:
2 - The Extras are supposed to be nobodies.
You can make them quirky, you can give them a personality - but don't make them interesting, and definitely don't make them more interesting than a Main or Minor Character. Lots of us do it; make a walk-on we kind of fall a little bit in love with, so that when he finally gets his big moment we give him a killer line of dialogue, or have him do something super-quirky and memorable, because we want our readers to love him as much as we do. And that's the problem. Succeed and what you have is a frustrated reader, getting distracted from the real story and the real characters because they're too busy wondering what happened to that cool walk-on that showed up for five seconds and then disappeared into the ether.
So curb the love and treat 'em mean. Don't even give them names in most cases; there's no reason for a janitor to become Fred the Janitor if all he'll be doing is scrubbing toilets in the background while the other characters do the cool stuff. Extras should be little more than walking and (occasionally) talking meat-props. That's why in movies and tv shows they only appear in the end credits rather than the opening ones. Showbiz. It's brutal.
3 - Serve up your characters like you'd serve up a good meal.
As in one course at a time, not the entire three courses dumped on one massive plate. In other words, don't introduce too many new characters at once in a single scene. Imagine you're at a party. You know the host, but you don't know any of the other guests invited, so he offers to introduce you to them. "Here they all are," he says, rounding them up into one giant herd. "This is Jim and his wife Sally, and this is Mark, Jim's boss, and that's Mark's flatmate June, and this is Frank who works with Sally and that's his wife Shelley, who's actually Mark's sister-in-law..."
How much of that did you actually take in? Next to nothing, probably. That's because it's too much information too fast - and, crucially, too early. You don't know any of these people yet, so you have no reason to care about them one way or the other. The host would have done better to let you meet Jim and Sally first, allowing you to speak with them for a while, then bringing in Mark and June a little later, and then waiting for a while after that until Frank and Shelley came over to talk to Sally and then introducing them...
The reader doesn't need to know who everyone is right off the starting blocks, so the best time to introduce any new character is at the first point they do something important in the plot. That usually limits things to, ideally, no more than three per scene. Extras don't count toward that quota, and you can also get away with including characters the reader has already met - but go easy on the number of 'active' characters you have in any one scene at a time. Because then you'll need to...
4 - Beware of Character Jump-Scare Syndrome.
This commonly happens in novels and short stories, when dialogue occurs between two characters while there are other characters in the scene as well (who aren't extras, because again, extras don't count.) These non-participating characters might be avid spectators of the exchange between the two speaking characters, or they might be ignoring them and doing their own thing in the background. Either way, the longer the focus stays on the dialogue between the two speaking characters, the more the non-speakers disappear into the wallpaper as far as the reader is concerned (since they're only 'seeing' what's being described on the page.) This means that when they finally do pipe up and make their presence known again, the effect is similar to them suddenly popping up out of the floorboards like Fenella from Chorlton and the Wheelies - "Whoa! Where did he come from? Was he still there all this time then?"
There are some little touches you can employ to lessen this effect. One is to have the non-participators join in a bit - even if it's just the odd line here and there to agree or disagree with something one of the speakers has just said. Another is to have the POV character observe and comment on the non-speaking characters' reactions to whatever has just been said (and if that POV character is also one of the speakers, that might in turn influence the way she responds to what's been said.) Alternatively if the non-speaking characters are ignoring the speakers and doing their own thing, the POV character could equally comment on that (might she be annoyed they're not interested when they should be - or alternatively worried that they might hear something she thinks they shouldn't?)
But if none of the above tactics work, or they just aren't plausible for the situation... why are these non-participators there at all then? Their input clearly isn't needed, so get 'em offstage. As a boss, you wouldn't pay an employee to just hang around in the background doing nothing, and there's no reason to let your characters to get away with that either. If they've got nothing to do, find some excuse for them to leave or even don't put them there in the first place. Make them work for their moments in the spotlight. Speaking of which...
5 - Some characters are just third wheels.
Why have just one jokey sidekick when you can have a wisecrackin' double-act for compadres? One jobsworthy minion when you can have a jobsworthy minion and his jobsworthy boss? More character goodness just multiplies the fun, doesn't it? Erm....no, actually. The only thing that gets multiplied is the wage bill - and as the boss of your story you already know that's not good business sense. There's no point in having two characters on the same side of the battle perform exactly the same function, because no matter how interesting they are to write, they're not interesting to read. It's like being made to eat two Full English Breakfasts when you've only got room for one. It typically happens in the form of comedy/villainous duos and loyal companions - either on the hero's or villain's team - and while they might help to beef up the buddy tally, if they're not bringing anything useful to the plot they're dead weight.Fortunately there's an easy way to spot those kinds of unnecessary duplicates. Take the dialogue attributed to both of the suspect characters and swap them around, so A is saying all of B's lines and vice versa. It should sound weird and like they're both acting completely out of character, saying and thinking things they would never normally say or think. If it doesn't... they've just secretly cloned themselves, and your story would be made stronger by eliminating one of them.
Another variation of this is the Soundbite Dispenser. They're easy to spot as well - most often minor characters, they hang out in the background until their moment comes to deliver a whip-smart, uber-wise or hil-ariously funny line, before slipping back into the shadows again until their next killer bit of dialogue. They're basically an extra with delusions of grandeur, who contributes absolutely nothing to the plot but somehow got awarded all the perks of being the resident smart-ass/wise person/comedy loser without actually putting in any of the hours. And yeah, I'll admit it here because I can - it hurts taking them out of your story. Been there, done it, worn the *sadface.* But if slicing them out doesn't change a single detail of any plot or sub-plots going on in your story... face it, he's wasted meat-space and he needs to go.
Like I already said, showbiz is brutal, baby. But on the bright side, at least you can divvy up his cool lines amongst the remaining cast members.
_______________________________________________________________________________
As a writer, your job is to be the most horrible boss in the world to your characters - and that's a hard thing to do when you also love them all to bits. No wonder we're all a little bit bonkers. But if the end result is a stronger story, your little pretend people will forgive you. So be hard, be ruthless and be cruel. Like the evil little story-maker you were born to be, bwa ha haaaa......
*vanishes in a puff of purple smoke. To cackle and eat chocolate.*