This is typical for my campaign: the party consists of 7-10 players, but number of PCs on each session ranges from 2 to 6. I use the following rules and it runs well:
Episodic playing
Most adventure should last one session, starting and ending at some point when PCs can freely come or leave, usually with some downtime between sessions. I will return to the exceptions later.
Have somewhere to hide those who don't play
We have started as "a baron and his party", so we had a base of operation from the very start (the baron's manor). Most adventures took place outside the base, so PCs could easily stay home.
Another way how to achieve this is to require each PC to have a personal agenda. This agenda should consist of adventurous (plot hooks when the player is there) and non-adventurous (excuse to be somewhere else when the player is absent) tasks. This is even better than the "base of operations", because it can easily explain why characters who would be unlikely to stay home when some adventuring opportunity occured are not there - they were away for some other agenda. This "agenda" scenario is harder to think out, but if the GM cooperates with the players, this can enhance the game by itself, even if the players are usually present. When a player leaves the campaign, such an agenda can send the PC away from the party.
We combine both in our campaign and it works fine. All the PCs have some agenda, and bases of operation multiplicate - most of the original PCs are barons now, having their own manors. Players of two most powerful of the PCs (and only two got married) left, so they left adventuring and took politics as a full-time job.
An example: player of our ranger Wrax was often absent. Wrax was a corporal, so he was expected to participate in most military sessions. I NPCed him few times, but mostly he had an agenda: as a skilled ranger, his duty was to guard a deserted village with surrounding woods and rocks, conquered by the party in one of the first sessions. He could advance his taming agenda (he tamed several squirrels, a good but stubborn horse, a bear etc.) and he was freed from duty in regular army, serving in battles lead by other PCs. When the player left for good, Wrax joined an allied mercenary unit, and then appeared as an NPC few times.
Few exceptions from the "episodic playing" rule
In my campaign, most sessions were like a TV series (1 adventure per session), but I had some longer chains too. There are few rules for them:
always have some idea how to hide the PCs of absent players. Most of such chains were either military campaigns (warriors could serve with a different unit, non-warriors just kept silent if I didn't offer them some special task to solve), or longer espionage/investigation missions (PCs of absent player got compromised and watched so thoroughly that they couldn't help). I plan to start some naval travels soon, but it is essentially combination of the two categories mention (military campaign for battles with "pirates" sent by Evil Empire and diplomatic/ espionage/ investigation in ports).
the more active the player is (and the higher the chance he will play in the next session), the more active role their PC should have. I could usually rely on some (not all, even not most) players that they will play every session in next few months, so I could make them important.
An example: ending of a war, half a year of playing, about ten sessions. I could rely on two players: one played warrior named Framan (sergeant who got knighted during the campaign), the other played Alexander, a noble spymaster. Players of other two warriors, our original baron Shalafi and dwarf Zudra, also played quite often, and another regular player playing mage named Melkan joined in the middle of this chain.
Shalafi, never defeated commander of many small battles, got promoted and lead a big operation, or better, two subsequent operations with very few time in between. Alexander was his second-in-command, so when Shalafi was an NPC, we left leading the army on Alexander, assuming their views on strategy are the same (and they were usually similar, so no problem). Spotlight was often on the front line, where Framan and Zudra (and sometimes Shalafi too) competed in killing enemies. Other players usually could play only during intermezzos in cities. The second intermezzo expanded to a chain of three sessions, because Alexander and Melkan were happy with their espionage/investigation agenda and Zudra's and Shalafi's players were absent, so we waited with the advance of military campaign for their return. Only significant problem was that Shalafi was absent for the final battle, but I stated that he was injured in the siege; strategy was partially set by the NPC king, partially by Alexander, and Framan, Zudra and Melkan enjoyed lots of fighting, including boss fights with enemy general and king. No problem!
Prepare adventures suited for different PCs
I usually prepared two adventures at a time: one based on war (if warriors came) and another based on espionage/investigation (when magi and a thief came) or on arcane mysteries (when magi and priestess came). I also prepared arcane subplots in battles and fights in mysteries that could occur when any PC with specific abilities was there. Players usually let me know if they come or not few days before, so I could spice each session by their personal agenda and challenges suited especially for them.
You usually have more and less active player, and perhaps also players who usually come at once. Don't be afraid to change any adventure (even a module) so that absent players' PCs will never be crucial and present players' PCs will be able to show off. In episodic structure, it is often possible to prepare more adventures, which can be played in any order and suppose different party builds - this is ideal, because you can run a game even if other players than you expected come. To some extent, this is possible in a chained game too, as long as sessions are not very tightly joined together.
In the last example, I could insert a session consisting mostly of hunting enemy spies between any two battle sessions if different players came, and I changed plan and prolonged a city adventure into a three session subcampaign, just because I had the right party build.
In GURPS I have it easy - "party build" means just that some PCs are more skilled in combat and others in investigation, so all I need is to assure than players of non-combat character are not bored during battle and vice versa, and not to require roles not included in the current party (don't require lockpicking if you don't have a thief). In longer skill-based campaigns you can expect PCs to become well-rounded. Party encountered few locked doors with no one with lockpick skill, and our mage had to waste valuable mana on it? Next time warriors will have a point or two in something like "breaking blow" and the mage will learn basics of lockpicking. In our campaign, we have already handled few adventures focused on an absent player's PC just because these background skills sufficed for challenges that would be easy for the specialist PC.
It is more difficult in games that suppose some cooperating party of specialists in different roles. For example, a group consisting only of strikers and controllers would be weak in comparison to a well-balanced party of the same number of PCs and slightly lower level. But if enemies have no healers too, their groups mostly consist of weak minions and strikers' non-combat skills usually allow them to start combat with initiative and enemy commander outside their force and next to one of the PC damagers, it's no longer a problem!
Just make the adventures to suit the party, don't try to make the party suit your adventures. And if you try to, use NPCs.
Use henchmen, not GMPCs
Few years before start of this campaign, I had a bad habit of involving GMPCs - NPCs overshadowing the PCs. So if you need to fill a gap in party build with PCs, prefer more weaker ones to one strong one. Players will clearly feel the difference between a PC and an NPC, which is good for immersion.
Some player might try to abuse the NPCs, or PCs played as NPCs this session. For PCs of absent players, try to hide them, so that they didn't appear on the tactical map (see previous points on how to do it). For pure NPCs, make them valuable and make them living.
In my campaign, we started with some 20 NPC soldiers. It wasn't easy to recruit more, and if yes, the new ones were either disloyal, much weaker than the original ones, or had some dirty secrets (finding that one of them is a werewolf made other NPCs use silver weapons against the party and throw wolfsbane into their beer). After first few battles, I made names and exact statistics for the soldiers, and some players started to love them more and more, as their personalities became more and more detailed. Also, the casualties decreased rapidly - named soldiers were killed only on major lost battles and other story peaks, or when the PCs made some mistake.
Some "named henchmen protection" rules are fine. In my GURPS campaign, unnamed NPCs die at 0 HP, while named can go down to more than -HP (as PCs do). In other games, ressurection may work on named NPCs only. In DnD 4e, only named NPCs may have healing surges etc. This rule encourages players to be interrested in their henchman, while not letting them overshadow the PCs.
Of course, PCs don't have to be the strongest heroes in the universe. But showing a single NPC victoriously returning from a dungeon too difficult for the party is much better then to give them some NPC tank doing more damage than any of the party damagers.