Each ground vehicle has its ammunition stored in a series of racks. Each vehicle has its individual rack configuration and each rack carries a specific number of shells. These racks can be seen in-game with X-Ray viewing mode (be sure to bind a key to 'Show the status of the vehicle modules' under Controls/Common Controls Tab/Basic Section).
Single piece ammunition Most tanks use single piece ammunition where projectiles and propellants are in one piece.
Two piece ammunition Some high calibre cannons have two piece ammunition where projectiles and propellants are stored and loaded separately. Each piece has their own individual racks. These racks can be depleted synchronously (for example in the Jagdtiger) or deplete independently of one another (for example in the M103).
Magazines and ammo boxes Vehicles with automatic cannon(s) have their ammunition stored in magazines, clips, belts and/or ammo boxes. In the loadout screen, ammunition amount is selected in magazines. For example, the Ostwind can load up to 125 magazines instead of 1000 shells.
Multi turret and multi cannon tanks Multi-turreted and multi-cannon vehicles (for example T-35 or M6A1) have individual racks for each ammo type. Tanks like the Maus could also have three kinds of racks, 12.8 cm projectiles, 12.8 cm propellants and 7.5 cm shells.
Twin and Quad cannons Some SPAA's have twin and quad mounts for their main armament. Each of these cannon gets loaded separately. Since all of its guns are firing in more or less a synchronized manner, it may look like the cannon are loaded as one. For example, the M13 MGMC holds 2*200 rounds in its two machine guns, while the game shows it as 400 rounds loaded.
Racks vanish once all shells in that rack are depleted. For example, a rack carrying 6 shells vanishes once all of its six shells are depleted. However, see "Visual Discrepancy" below. The order in which the racks are depleted and vanish are hardcoded and can't be changed.
Ammo racks are shared for all shell types loaded. It doesn't matter which shells are used first, the racks will always deplete in a given order (assuming the ammunition is all fired from one cannon).
Currently, (Stand: 1.65 ) most tanks have a visual discrepancy of how many shells each rack contains. This may change in future patches, however the x-ray function is considered "for immersion" only, and is not intended to be dynamically accurate. See 
Optimized ammo rack loadout
The fastest way to get destroyed in tank battles is by detonation of the ammunition. Therefore, a good way to increase survivability is to reduce the number of shells loaded on the tank. Survivability is greatly reduced while shells are stored in bundles, distributed all around the tank in different locations. These racks can be seen with x-ray view, and are consumed one by one (rack by rack, not shell by shell) when all shells in the rack are fired. Once a rack is gone/depleted, it cannot explode anymore, thereby decreasing the chance of getting 'ammo racked'.
Being 'ammo racked' is the situation in which a group of ammunition takes damage from enemy fire (gets shot by another tank) and causes the explosive mass in the ammunition to detonate. Any time ammunition inside the tank is detonated, it causes catastrophic damage to the tank.
Each tank has a different ammo rack setup and therefore, there is no universal rule on how much a lower ammo count increases survivability. Ammo racks in the turret are much more susceptible to being shot, but there is no guarantee that the ammo rack in the turret is the first to be expended.
The loadout screen shows the number of unloaded shells in brackets. The number remaining to be loaded are a total of the max, and not per shell type.
Use this to gauge how much ammunition and how much of each type to bring when considering the number of ammo racks filled and survivability. Loading too little shells may result in you running out of ammunition in the heat of battle, while cramming as many shells in as possible increases the chance of an ammo explosion. Ammunition can be reloaded at any capture zone controlled by your team.
Related forum thread: http://forum.warthunder.com/index.php?/topic/246940-ammo-racks/