Numerous ecological roles exist. These include microscopic, small, medium, and large-sized herbivores, producers, predators, scavengers, and parasites. There are an estimated 7 million plant and animal species on the planet today, most of them insects, occupying every conceivable niche. The most popular niches appear to be herbivore and parasite, with predators being the smallest niche. However, it also seems that, among all ecological roles, that of predator captures the popular imagination the most.
All the major ecological roles have been almost continuously occupied since at least the Cambrian Explosion, a major episode of evolutionary diversification roughly 542 million years ago. Some paleontologists have postulated that the evolution of predation is partially responsible for the evolutionary diversification that occurred during the Cambrian. In any case, by the end of the Cambrian, all major ecological roles were populated, except the largest organisms were only about a meter in length. During the next period, the Ordovician, a few animals (such as nautiloids) as long as 3.5 m (11.6 ft) evolved, and by the Carboniferous the size range of organisms was similar to today's.
Although animals are generally highly specialized to their ecological roles, some animals share roles, and some evolutionary lineages can evolve from one ecological role to another. For instance, the ancestors of whales evolved from mid-sized land predators to whale-sized (literally) aquatic filter feeders. Predators evolved out of herbivores, and many predators are also scavengers. Many predators become big and tough not just to take down prey, but to compete with other large predators for a scavenged kill. The upper size of predators is determined by the quantity of prey available. In excellent evolutionary circumstances, such as those experienced from time to time by crocodilian predators in swamps, predators can balloon to huge sizes, as much as seven times larger than their recent ancestors.
Ecological niches work in a pyramid-based format, with producers like plants on the bottom, herbivores in the middle, and predators at the top, with apex predators like tigers at the very top. The higher the animal is up the pyramid, the less biomass is generally devoted to that species, and the more rare it is. Animals high on the pyramid are generally also more susceptible to extinction, but not always. In some historic extinctions where most plant life was wiped out, the animals that survived were actually scavengers rather than dedicated herbivores or carnivores.