As a whole. By the rule, entire swarm is treated as one creature, though there are a lot of special rules and exceptions. Read Monster Manual, both Swarm entry in the main section and the grossaly.
The most important exception is that any effect that targets only a specific number of creatures (including single-target effects) has no effect on a swarm.
The exception to the exception is that mind-affecting effects can target the swarm as a single individual if the swarm has a hivemind.