If you have ever completed a long run of more than 2 hours without ingesting the proper amount of nutrition, you may have experienced a painful phenomenon in the late stages of that run called glycogen depletion.
Essentially, when the body runs out of carbohydrates, it instead tries to utilize fat for energy, which is far less efficient than burning carbs. Once the body runs out of glycogen (a type of carbohydrate), hard aerobic exercise becomes almost unbearable. Your legs feel like lead and the pain in your muscles seems impossibly deep, as if acid was running through your veins.
One way to help curtail the effects of glycogen depletion is to take in calories during a run, and there is perhaps no more convenient form of nutrition while running than energy gels.
Energy gels are essentially what you would expect, small packets of flavored gel that an athlete can ingest mid-run to replenish the glycogen and calories lost during the activity. I carry gels on all training runs over 75 minutes, just in case I start feeling excessively tired at some point. For activities shorter than 75 minutes, though, most runners will not find them useful. For longer runs over 2 hours, it is recommended that athletes take in one gel every 45 minutes to 1 hour. You need not ingest gels more often than that. If you take them too frequently, you risk upsetting your stomach.
During races, typically, people do not go into a state of glycogen depletion until the very late stages of a marathon, around mile 20. However, gels can be useful for distances shorter than that as well. Half marathoners often begin to feel sluggish in the final miles of the race, though they are not in total glycogen depletion. Taking a gel around miles 6-7 can help prevent that feeling and improve race performance.
Race-day nutrition can be a bit of a balancing act, but you never need to over-complicate it. Before the race, try eating solid food rather than a gel, so that your stomach has something substantial in it before the gun goes off. The food should be simple and contain sugars that can be burned easily while running, such as toast with jelly or oatmeal.
During the marathon (or ultramarathon), take a gel every 45 minute to 1 hour, especially in the early stages, before your stomach has a chance to become upset. If later in the race, you feel that your stomach is too tumultuous to take in more gel, perhaps stop at an aid station and drink an electrolyte drink such as Gatorade. Those drinks will still contain calories to give you energy, but they won't be as heavy as a gel.
Choosing an energy gel is a personal decision. Each is different: some contain caffeine, some do not; some tend to be less viscous while others are thicker; etc. Go to a local run specialty store to ask about the specifics of each different type of gel and pick a few to test on training runs. Choose the gel that feels most natural to you. If you find that the texture of gels bothers you, there are many alternatives such as energy gummies or waffles that typically have the same effect as gels.
Whichever form of race-day nutrition you use, make sure you practice using it during training runs so that your stomach becomes accustomed to the taste and feel of that particular form of nutrition. Good luck in your next running endeavor!