There are two basic concepts here:
1- Adapt your speed: If you decide to race at a certain speed, you have to make sure that you have already trained at that specific speed. That way, it would be something your body has done and is completely used to.
2- How to breakdown the intervals: The most common practice here, whether you’re having a swimming, cycling or running workout, is to speed up for one interval and slow down for two. This will improve your speed and cardiovascular fitness, and still give you the chance to recover before the next set. After a certain period of time, you’ll need less time to recover, so you’ll be able to increase the fast interval.
The fast intervals don’t have to be full sprints, and the slower intervals should be done at a pace that you can maintain for an extended period of time.
Below is a small paragraph from active.com about the Fartlek concept:
Fartlek is a Swedish term that means “speed play.” Fartlek workouts help the athlete learn how to feel different paces, and this skill is important if you want to run at your fitness level in a race, rather than going out too hard, then slowing down as the race progresses. Learning what pace you can sustain for a given distance is important, and is much better than looking at your GPS watch every two minutes to see what pace you’re running.by