(Reuters) - Amazon.com Inc AMZN.O on Tuesday briefly joined Apple Inc AAPL.O to become the second $1 trillion publicly listed U.S. company after its stock price more than doubled in a year as it grew rapidly in retail and cloud computing.

Its shares traded as high as $2,050.50 before easing a little to end the session at $2,039.51, up 1.3 percent and just short of the milestone level of $2,050.2677.

If the online retailer’s shares keep up their recent pace, it would be a matter of when, not if, Amazon’s stock market valuation eclipses that of iPhone maker Apple, which reached $1 trillion on Aug. 2.

Apple took almost 38 years as a public company to achieve the trillion dollar milestone, while Amazon got there in 21 years. While Apple’s iPhone and other devices remain popular and its revenues are growing, it is not keeping up with Amazon’s blistering sales growth.

Amazon has impressed investors by diversifying into virtually every corner of the retail industry, altering how consumers buy products and putting big pressure on many brick-and-mortar stores.

“It says a lot about Amazon and its ever-increasing dominance of segments of the retailing world as well as the web services business,” said Peter Tuz, President Of Chase Investment Counsel In Charlottesville, Virginia. “They have a tiny share of the worldwide retail sales market so there’s a lot left to capture there.”

(Graphic: Amazon vs. Apple: reut.rs/2PwtdRg)

Slideshow ( 5 images )

Amazon also provides video streaming services and bought upscale supermarket Whole Foods. And its cloud computing services for companies have become its main profit driver.

“Amazon’s a little bit more dynamic than Apple because the iPhone has become more mature. Amazon’s cloud business is an extra growth driver that Apple doesn’t have,” said Daniel Morgan, portfolio manager at Synovus Trust in Atlanta who describes Amazon’s cloud services as its “crown jewel.”

In the second quarter the unit accounted for 55 percent of Amazon’s operating income and 20 percent of total revenue, according to Morgan.

Apple started trading in December 1980 but its stock did not truly start to take flight for another 25 years, spurred by the iPhone, the breakthrough device that left competitors in the dust.

Amazon - founded as an online book-retailer in Chief Executive Jeff Bezos’ garage in 1994 - started trading on May 15, 1997 at $1.50 on a split-adjusted basis.

By October 2009 it had risen to $100 and the stock hit $1,000 for the first time on May 30, 2017. It has held above that level since Oct. 27, 2017.

Slideshow ( 5 images )

Just 10 months later, on Aug. 30, Amazon shares hit $2,000 for the first time, just $50 per share away from giving the company a $1 trillion market value.

(Graphic: Analyst Price Targets: reut.rs/2NHwHQq)

The stock is up 74.5 percent year to date. In comparison, Apple has risen about 35.0percent in 2018.

Analysts expect Apple’s revenue to jump 14.9 percent in its fiscal year ending in September, according to Thomson Reuters data, a hefty rise but still far short of Amazon’s expected revenue growth of 32 percent for 2018.