Some people think that when a spark plug fires, the fuel/air mixture explodes instantaneously, driving the piston down. If this really happened, engines would last only a few minutes before they literally explode.
Looking at the dynamics involved from the moment that the intake valve is fully open. With the piston moving down the bore, cylinder volume increases, cylinder pressure decreases, allowing the higher pressure in the intake tract to push the fuel/air mixture into the cylinder. As the piston starts back up and the intake valve closes, cylinder volume decreases and cylinder pressure increases.
When the crankshaft reaches about 30 degrees before top dead center (TDC), the spark jumps the gap between the spark plug electrode. The purpose of the spark is to raise the temperature of a very small portion of the fuel/air mixture above its ignition temperature. This is the point where true combustion begins. As the reaction starts, the mixture directly adjacent to the spark plug is also ignited and the process progresses out from the spark plug in a roughly spherical shape.
At about 20 degrees before top dead center (BTDC), the rate of heat release causes the cylinder pressure to rise above the compression line which is what the cylinder pressure would be at a given piston position without ignition. Notice that it has taken 10 degrees of crank rotation to generate this pressure level. This is known as the ignition-delay period.
The rate of pressure rise is a function of the rate of energy release vs. the rate of change of combustion space. The rate of energy release is directly related to the flame propagation rate and the area of reacting surface. The flame speed is dependant on fuel/air ratio, charge density, charge homogeny, fuel characteristics, charge turbulence and reaction with inert gasses and the combustion chamber, cylinder walls and piston.
No two combustion cycles progress at the same rate or uniform rate. Some start slow and end slow, some start slow and end fast, some start fast and slow down. Generally, only the ones that end too fast will lead to detonation / knocking / pinging as the rapid pressure rise may happen too soon with the cylinder volume still decreasing or not increasing fast enough. Usually, not all cylinders will detonate / knock / ping at the same time or on the same cycle because of this.
By the time the crank is at about 5 degrees after top dead center (ATDC), the cylinder pressure is about double that of the compression line. From this point to roughly 15 degrees after top dead center (ATDC) the combustion process is fast due to the increasing area of inflamed mixture and the high rate of energy release. The peak cylinder pressure (PCP) occurs between 10 and 20 degrees after top dead center (ATDC) on most engines and the combustion process is complete by 20 to 25 degrees after top dead center (ATDC). The peak temperature within the combustion gasses will reach somewhere around 5000 degrees Fahrenheit and pressures may be anywhere from 300 to 2500psi depending on the engine.
Obviously it is very important to have the crankpin at an advantageous angle before maximum cylinder pressure is achieved in order that maximum force is applied through the piston and rod to the crankshaft. If the mixture was ignited too early, much of the force would simply try to compress the piston, rod and crank without performing any useful work. In a worst case scenario, the cylinder pressure would be rapidly rising before the piston reached top dead center (TDC) which would have the cylinder volume decreasing at the same time. This will often result in detonation/knock/ ping which is counterproductive to maximum power and engine life.
Detonation, knock or pinging is defined as a form of combustion which involves too rapid a rate of energy release producing excessive temperatures and pressures, adversely affecting the conversion of chemical energy into useful work. Detonation usually involves ignition and literal explosion of the end gases, these are the gases not in contact with the initial spark or the progressing flame front.
If peak cylinder pressure (PCP) is achieved too late, again, less work would be performed. Most of the useful work is done in the first 100 degrees of crank rotation. Most combustion must be done with the piston in close proximity to the chamber so that the minimum amount of heat (energy) is lost and the maximum amount of energy is delivered to the crankshaft.