SAN FRANCISCO — Imagine building an enormous beach resort, maybe the best in the world. Instead of renting the rooms, you charge guests based on the grains of sand they touch. You charge very little per grain, but if they lie on enough of them, it adds up.

That is one way to think about what is going on at the world’s biggest cloud-computing companies. Instead of grains of sand, think about computing cycles, the activity that goes on in a computer server that is running software. For a price, think about one line of software code for two one-millionths of a penny.

When tolls that tiny are paid often enough, they can make a billion-dollar business. At Amazon Web Services, which pioneered this method late last year, there is no charge for the first million times a customer runs code. Thereafter, A.W.S. charges by the million times, or for the hundreds of milliseconds the computer is used.

“The scale at which we operate allows us to do innovative things,” said Matt Wood, general manager of product strategy at A.W.S. “When we get better economies of scale, we’ll use that to our advantage.”