It might be hard to imagine, but Amazon (AMZN -1.01%) began only 30 years ago as an online bookseller. Now the site sells a wide range of goods. The business has grown quickly and includes the popular Amazon Prime subscription service, electronic devices, and Amazon Web Services (AWS).

The shares have also generated a lot of wealth for investors. Investors who bought shares a decade ago, and held them, would have seen an increase of almost 1,000%.

Trouncing the market

Amazon had its initial public offering (IPO) in 1997, when its sales were about $148 million for the year. The figure grew to nearly $575 billion last year.

But you didn't have to buy the shares at the IPO price to make a lot of money. Over the last decade, Amazon's shares have appreciated 945%. That easily bested the S&P 500's 227% total return.

Even starting with a relatively small $1,000 just 10 years ago, you would now have about $10,500. Placing the same amount in the S&P 500 would've resulted in about $3,300.

Amazon's stock will likely have a hard time reproducing those kinds of returns over the next 10 years, but that doesn't mean they aren't worth buying.

Amazon shares have a price-to-earnings (P/E) ratio of 39, much higher than the S&P 500's 27 multiple. That suggests the market has high expectations for Amazon's growth.

Cloud computing business AWS remains the company's main profit generator. The unit's sales grew 18.6% to $26.3 billion in the most recent quarter, and operating income went from $5.4 billion to $9.3 billion. It also has the highest operating margin, 36.5%, among the company's three segments. Prospects look good given business's demand for data, and the artificial intelligence push could give the business a further boost.

However, with the relatively high valuation, you may want to employ dollar-cost averaging to purchase shares over time. That way, you invest small sums at regular intervals, and you won't have to worry about timing the market.