IMPORTANT: The measures listed below are NOT a guide to action. This article was written as a result of gathering information for my personal use and for you to read for entertainment. Anything you do is at your own risk.

Mountain sickness, high-altitude hypoxia, altitude sickness and other names for the condition of oxygen deficiency at high altitude. Next summer I have lots of treks planned at altitudes from two to almost five thousand metres above sea level. I decided I absolutely had to prepare for this in theory and put together a list of recommendations for my hikers, so that any symptoms of altitude sickness stay to a minimum.
Studying any illness is an incredibly interesting and exciting process. I decided to try to describe it in three ways. The first is for people with no medical background who are interested in the topic, where I'll try to explain everything in simple words. The second is for people with medical training, where I'll lay it out as it is, including the pathophysiology (and as a memo for myself). The third is a short conclusion at the very end for the TL;DR crowd. We'll even cover the specifics of the female body in the overview.
Well then, let's go!
Most of us live at sea level (0 metres), where air pressure is 760 mmHg (millimetres of mercury). But air is a mixture of gases, not pure oxygen, right? Oxygen makes up only 21%. That's about 160 mmHg. That's exactly the part we need.
The higher we go, the shorter the column of air above us, so the less it presses on us. At 1000m it's about 675 mmHg, at 2500m – 560 mmHg, at 4500m – 430 mmHg, on Everest (8848m) – 235 mmHg. The share of oxygen in the air stays at 21%, so to breathe in the same amount of oxygen as at sea level, we have to breathe in 1.13 times more at 1000m, 1.36 times at 2500m, 1.77 times at 4500m and a WHOPPING 3.23 times on Everest!

Altitude sickness is a set of problems caused in our body by the reduced amount of oxygen we breathe in from high-mountain air. It occurs from 2500m (some sources say it can start lower).
Altitude sickness can be acute or chronic. The chronic form is linked to living at high altitude for a long time, so we won't cover it.
Acute mountain sickness comes in a mild form and mainly in TWO severe forms (there are others, but these are the most important). They are HAPE (high-altitude pulmonary edema) and HACE (high-altitude cerebral edema).
This is the form of altitude sickness that the vast majority of people get.
Lack of oxygen causes problems in different body systems. Symptoms may include:

If you don't slow the pace of the ascent and altitude gain, the condition will get worse.
Here we'll dig a little into medicine, but I'll try to explain without fancy terms. Don't judge too harshly.
Our body has loads of automatic mechanisms that regulate the state of certain organs. Think of it as a system: stimulus – response. Cold outside? Skin blood vessels narrow to lose less heat from warm blood. Can you smell or taste food? Your stomach starts producing acid to digest it. It's the same here, except these mechanisms are AUTOMATIC for a reason: there's no reasoning behind them, only a trigger, so there are side effects. If these mechanisms aren't stopped, they can even KILL.

Lung capacity can be 3 to 6 litres. For each breath we use about 0.5l. So where's the rest? The thing is, at rest we only ventilate PART of the lungs – the very top. What happens to the rest of the lungs? More on that below.
When we're at high altitude, we breathe deeper and faster. The idle part of the lungs, which doesn't get much air anyway, under the influence of AUTOMATIC mechanisms, gets a spasm of the blood vessels running through it. Why? Why would we want blood in the system that has no oxygen? Right? Right. BUT! There's a problem: the vessels have narrowed, which means the pressure in them has RISEN. As a result, the blood, like passengers from a packed bus, starts spilling right out because of the high pressure. Both the liquid part of the blood (plasma) and red cells (erythrocytes) start getting into the lungs.
And here we run into a really nasty thing. The alveolus (an air sac, the basic unit of the lung) is now filled with blood instead of air, which means oxygen doesn't get into the blood. The oxygen deficit gets worse.
Fluid in the lungs is exactly what pulmonary edema is.
The symptoms follow: a dry cough (the lungs are trying to "cough out" all this fluid), coughing up pink frothy sputum (a slight admixture of blood) in very severe cases and, accordingly, low blood O2 levels.

The skull isn't made of rubber. So the whole space inside it is filled with everything it needs and nothing more. If the balance is upset and inflow to the head exceeds outflow, brain damage develops.
Here we have 2 problems:
1. When the brain is short of oxygen, its vessels dilate. Why? More blood – more oxygen! That's fair enough, but dilating the vessels also causes increased pressure in them. Which plays its part in FORCING blood into the brain tissue.
2. General inflammation, free radicals and the action of certain hormones damage the walls of the brain's blood vessels, which increases their permeability. Essentially the vessels become leaky and can't hold the fluid.
These two factors play an important role in the development of cerebral edema (fluid in the brain tissue).
Symptoms go as far as a headache that doesn't respond to painkillers. Altered consciousness, loss of consciousness, high temperature, sensitivity to light. An inadequate perception of how serious the situation is: the casualty loses the motivation to be rescued and doesn't realise how severe their condition is.
Low partial pressure of oxygen in inhaled air leads to low partial pressure of oxygen in the blood – hypoxaemia. One of the interesting names for altitude sickness is hypobaric hypoxia. The mechanisms leading to the various syndromes aren't yet fully understood, but there's a rough picture.

Pulmonary edema occurs due to hypoxic pulmonary vasoconstriction. It follows the Euler–Liljestrand reflex in response to reduced partial pressure of oxygen in the affected alveoli. Hydrostatic pressure in the pulmonary artery and capillaries rises and plasma leaks into the alveolar lumen, followed by red cells. This produces the picture of a dry cough, and then a cough with pink frothy sputum. There's also a theory that the second component of the change in vascular wall permeability is its damage by inflammatory mediators.
As you can see, to fight the main pathophysiological link of this problem, we need to fight pulmonary hypertension. This link is targeted by nifedipine (or other calcium channel blockers), albeit indirectly. By sharply relaxing vascular smooth muscle, it leads to lower blood pressure – lower venous return to the heart – lower pulmonary artery pressure. A related problem is a sharp drop in blood pressure, so keep an eye on any antihypertensive therapy being taken (don't combine!)
“An interesting point: to relieve acute pulmonary edema, it used to be recommended to use sildenafil, or Viagra. Because it dilates not only the pelvic vessels but also the pulmonary artery. Which acts directly on the pathogenesis of pulmonary hypertension.

Vasodilation in response to hypoxaemia sets the stage for edema. The HPV mechanism is absent in the brain, so other causes of blood–brain barrier disruption are being sought. One theory is excessive free radical formation due to hypoxaemia, which damages the microvasculature and causes cerebral edema (plasma retained in the interstitium). The second theory is the effect of the angiogenesis hormone (VEGF). The response to hypoxia is: we need more vessels. But the first stage of this hormone's action is damage to the vessel wall, which as a side effect leads to cerebral edema in the short term (short in the timescale of angiogenesis).
Working against the damage mechanisms and reducing inflammation are glucocorticoids, which protect the BBB and reduce vascular permeability. Acetazolamide (Diamox) works in two ways: by inhibiting renal carbonic anhydrase, it increases bicarbonate excretion, which leads to metabolic acidosis. Interestingly, the casualty will already have respiratory alkalosis (hyperventilation – hypocapnia), so the pH is compensated and breathing isn't inhibited by hypocapnia, which increases minute ventilation – more O2 intake. The second mechanism is diuretic, reducing circulating blood volume, plus reduced CSF production - lower intracranial pressure.
An interesting article on the mechanism of action of acetazolamide and dexamethasone in altitude sickness.
Don't go to the mountains. END OF ARTICLE.

But seriously, let's split prevention into two goals. Coping with high-mountain conditions to keep the body in good shape (a weakened, destabilised body is more prone to altitude sickness), and specific prevention of altitude sickness.
The first important point in keeping the body in good shape is:

Specific prevention of altitude sickness:
“High-protein diet (my guess, not backed by anything)
The mechanism that returns fluid to the vessels depends on the concentration of protein, particularly albumin, in the blood (oncotic pressure). If the concentration is low, fluid will stay in the tissues MORE, which will lead to edema faster. It's an interesting mechanism in general.At school we're taught that blood goes from the heart to the tissues, gives up O2 and nutrients there, and returns via the veins back to the heart. But people are usually surprised that roughly 20l of blood a day reach the tissues, while only 17l come back through the veins. Where did the 3l go? They return to the bloodstream with lymph through the lymphatic system (draining into the left and right venous angles). If oncotic pressure is disrupted, there will be more problems.

Data on altitude sickness and its symptoms are often based on information collected from men. Fortunately, the sports scene is changing and more and more statistics are appearing for studying the female response to hypobaric hypoxia.
The International Climbing and Mountaineering Federation (UIAA) has put forward the following data:
The menstrual cycle may change under the influence of altitude, as well as associated factors like jet lag, cold, weight loss and physical exertion.
There's no reliable evidence of an acclimatisation advantage linked to taking oral contraceptives. On a long expedition, consider the increased (but still minimal) risk of thrombosis associated with combined oral contraceptives, combined with secondary polycythaemia (the body's response to hypoxia – producing more red blood cells), dehydration and cold. The risk may be lower with second-generation COCs (as opposed to first and third). (it specifically says generations, not phases – maybe it's phases after all???)
Low serum iron can lead to poorer acclimatisation at extreme altitude. You can work on correcting iron levels well before the ascent.

A tricky point – I'm writing it for information only. Let me explain why. From my experience, on ascents people are always very ready to take medication, often without realising all the risks and nuances of drug interactions, contraindications and side effects.
As a simple example, take hikers' common readiness to take loperamide, even though with infections it's not recommended.
A major problem is differential diagnosis. The symptoms of altitude sickness are generally quite non-specific, and you shouldn't take altitude-sickness-specific drugs for every headache on a trek. Especially given that dexamethasone, for example, has a mild immunosuppressive effect (it suppresses immunity).
Differential diagnosis (a list of syndromes and diseases that can look similar): acute hypoglycaemia, anxiety disorders, brain abscess, brain tumours, carbon monoxide poisoning, diabetic ketoacidosis, subarachnoid haemorrhage, encephalitis, haemorrhagic/ischaemic stroke or transient ischaemic attack, Guillain–Barré syndrome, hyponatraemia, subdural haematoma, hypothermia, meningitis, migraine, sinusitis.
The main message is this: there are lots of similar conditions. So using any medication carries an incredibly high risk of playing into one of them and ruining things for yourself or someone close to you. Descent is the best way to fight altitude sickness.

Acetazolamide, or Diamox, tablets by mouth (contraindications are listed in the leaflet)
125mg every 12 hours (starting 24 hours before the ascent) and up to 2 days after arriving at the target altitude. Children: 2.5mg per kg of body weight every 12 hours.
Dexamethasone tablets by mouth (if Diamox is contraindicated; contraindications for dexamethasone are in the leaflet)
2mg every 6 hours, or 4mg every 12 hours.
Ibuprofen (if the previous two are contraindicated)
If the climber has a known susceptibility to HAPE/HACE, the prevention scheme is as follows:
Nifedipine retard (extended release) 30mg every 12 hours OR
Tadalafil 10mg every 12 hours OR
Sildenafil 50mg every 8 hours
Dexamethasone tablets by mouth, intramuscular, intravenous
8mg initial dose, then 4mg every 6 hours
Nifedipine retard (extended release) tablets by mouth
30mg every 12 hours
AND DESCEND, DESCEND, DESCEND!

All in all, altitude sickness in its severe forms doesn't really apply to commercial treks as such – which is what I do. HACE/HAPE is more about mountaineering and the adventures of hardcore commercial expeditions. But once I started trying to figure it out, I decided to describe everything I found on all the conditions. On my own treks I still stick to non-drug approaches to preventing and treating altitude sickness: good, comfortable rest, tasty and nourishing food, electrolyte drinks and proper acclimatisation. ❤️
I hope I managed to put together something sensible from a pile of Wikipedia articles, altitude sickness textbooks, MedScape and NCBI articles, and CDC, UIAA and other guidelines.
I can recommend two books on the topic:
If you liked it – I lead treks and run my own channel. Join in :)
Someday I'll look into genetic predisposition to altitude sickness. An interesting topic.
Thanks for reading! Talk soon 😎