In a virgin state, oil-producing reservoirs generally contain a great deal of energy, imparted to them by one or both of: i) naturally occurring water; and: ii) natural gas which is generally in solution in the oil. In the early life of an oil well, this natural reservoir pressure is sufficient to drive the reservoir fluids to surface via the tubing placed in the well when it is completed. Thus, the well will flow on its own very much like an Artesian water well. In time, this energy is expended and so "artificial lift" is then required in the form of a pumping unit, which functions for the remaining life of the well.
The pumping unit typically has to be a very large, relatively massive piece of durable machinery because it has to support a long, very heavy steel "rod string" that extends all the way from surface to some distance above the producing formation. It also has to last the life of the well, which can be many, many years. If the oil zone is 4,000' from surface, then the rod string will have to be usually in excess of 2,500' in length, which is nearly one-half mile below ground. This rod string is enclosed in steel tubing, which acts both to contain the rod string and provide a pathway for the reservoir fluids to be pumped to surface.
The bottom end of the rod string is connected to a hollow plunger, or piston, which is contained in a stationary barrel. This assembly is commonly referred to as the "downhole plunger & barrel". At the bottom end of the barrel is a ball check valve that allows the fluid to flow up into the barrel, but not fall back from the force of gravity. There is also a ball check valve at the top of the plunger. This plunger is actuated in a reciprocating motion inside the stationary barrel by the rod string which is being reciprocated at the surface by the pumping unit. The downhole assembly is "double-acted" in such a way that fluids are pumped to surface during both the down stroke and the upstroke of the rod string and plunger.
At the surface, the energy to reciprocate these connected parts is imparted by a gas engine or electric motor that drives a gear-reduction sequence in the gear box of the pumpjack. So inside this gearbox, the rotary motion of the motor or engine is converted to the reciprocating motion of the pumpjack head (often called the "horse's head"). These gears are very heavy-duty, as are the bearings, because the torque and loads placed on them are considerable. The horse's head is connected to the rod string by means of a heavy-duty cable that is always tangential to the arc of motion of the horse's head as it translates this into true vertical, reciprocating motion.
In summary, the lost reservoir energy is replaced at the surface by the energy of the pumpjack motor as it carries out its arduous, lonely, long-lived work fueled by electricity or by burning a small amount of natural gas that is normally available from the wellstream fluids.