For the archers, treat it as an environmental effect. "Hail of arrows"; characters whose flatfooted AC is 20 or higher are struck by 1d3-1 Small shortbow arrows per turn; FF AC 16-19 struck by 1d3 arrows per turn; FF AC 13-15 struck by 1d4 arrows per turn; FF AC 12 or lower are struck by 1d4+1 arrows per turn. These do normal Small shortbow damage. Characters engaged in melee combat or otherwise finding cover count as one category better; characters already in the best category and behind cover have a 50% chance to be struck by a single arrow each turn.
Characters struck by only one arrow in a turn are never critically hit that turn; other characters have a chance to be hit in a critical location. A character struck by 2 or 3 arrows has a 5% chance to take triple damage from one arrow, while characters struck by 4 or 5 arrows have a 10% chance. Since shortbow damage is a single die normally, you can simply roll two more of the same dice and call it a day.
This is a little complicated to write out, but super simple to do in play - ask for everyone's AC, tell them how many arrows hit them per turn, have them roll it. When someone says "can I hide behind my tower shield / this rock / the guy I'm fighting to dodge the arrows?" tell them their new arrow-per-turn count.
There's three easy methods of handling the melee combatants. Here they are in no particular order...
Squad leader, report: Have one or two "heroic NPC" stat blocks for each type of melee unit (infantry, dog rider, worg rider, etc), ignore the common goblins. Group five common goblins with a leader of that type - they count as one creature. You can have them occupy space as a Large creature if you prefer. The leader gets +5 to attack and damage, but -5 to saves against area effects. When the leader's hp is depleted, one of his minions drops and he full heals (with his crowd-fighting bonuses and penalties reducing by one). When he's out of minions and hits 0 hp, he goes down. This lets you make them more of a threat (since each goblin is "counting as" their, say, 4th-level fighter squad leader instead of a 1st-level warrior) and cut down on your number of creatures actually being tracked at once. (Special note: weak mind control effects like charm should drop a single minion and waste a turn if they hit. After killing off one minion, the goblin remembers who the real enemy is. The more powerful dominate should probably just allow a save per turn/minion wasted. Feel free to reward creativity here, depending on what orders are given. Instant kills or save-or-suck spells (hold person, ghoul touch) should scatter minions; half may join other squad leaders, while the other half should flee or die in the back-and-forth.)
Swarm tactics: Treat a squad or platoon as a swarm. Give them all a bonus based on swarm size, downgrade the swarm size when they reach half hp (maybe every quarter for very large swarms). So 5 or 6 goblins makes a 4-square swarm, which hit like a goblin with +2 to attack and damage, at half hp the bonuses go away because a few are dead or fled. 25-30 goblins should be a 9-square swarm with, say, maybe +4; reduce the bonus by 1 at 75%, 50%, and 25% hp. Let swarms merge to heal, and go ahead and let them attack adjacent squares and take AoO's even though swarms normally don't.
This obviously isn't working: If you want to give it away to them sooner rather than later that they JUST CAN'T FIGHT THAT MANY; I've used what I call the "X in play" monster rule. Put as many figures on the battlefield as you can handle; put them in groups and have a group move on a single initiative, but still be individual monsters. Each time one dies, move its figure to the edge of the battle map and have it run/charge to close the next time that group gets a turn. Never remove a figure from the mat. It sets a very clear picture: each time one falls, another replaces it. You can combine this with one of the other two options (or even combine all three, one for led squads and one for mass unorganized attacks, if you can keep up with it).
It's been a while since I've used these, but they're decent. If you don't use the X in play rule, you should probably let your PCs "advance" when they clear the same field once or twice, giving them new terrain and tougher/more bad guys. Remember that casting while taking damage from environmental effects / swarms requires concentration checks, and feel free to throw special situations in there (a squad of unarmed goblins that grapple everything they can reach, for instance, or a lone hobgoblin cleric 7 with protection from arrows striding untouched through the battlefield, getting the attention of the melee PCs while a goblin rogue 5 moves to sneak attack the vital back row...). Whatever makes it feel fun while getting the point across that they really need to flee or die....
Maybe getting captured could be fun. Maybe the person who really has it in for them wants to gloat, or the goblin leadership was worried their horde would eat the PCs and so they take them alive as proof. Maybe a goblin sorcerer with minor image and ghoul touch slips in the confusion and the tank believes he's the cleric, not resisting that "cure wounds" until it's too late. Losing this fight doesn't have to end the campaign. Waking up on the field of battle afterward could also work - especially in a combination. Maybe half the party was left for dead, but one with Heal or cure stabilized first and saved the others. Maybe an outside party saves the whole party and now the PCs owe him a favor. Whatever works for your game.
PS: All numbers can be adjusted to taste. Some of them can even be done away with. If you don't want to bother trying to figure out how many arrows should hit what AC, don't. Assume everyone is hit with 1d4 arrows and call it a day. Simplify wherever you like.