Whales are mammals and they need to breathe. Their bodies are highly adapted to the ocean environment, enabling them to breathe only once every several minutes. However, unlike all terrestrial mammals, they must actively decide when to breathe.
Terrestrial mammals can breathe subconsciously, but whales cannot. They must decide when to surface and breathe.
For whales, sleep also seems to be a problem.
Different kinds of whales use a variety of ways to solve this problem. Each type possesses one or several special skills related to sleep.
For instance, the rhythm of whales active in the deep sea is almost completely detached from the day-night cycle. They can be active at any time, day or night.
Some whales have mastered another skill. They can sleep in small increments, achieving deep sleep for tens of minutes, several times a day.
Of course, the most magical and common skill is "letting half the brain rest."