It's Amazon's world.

Amazon Inc. (AMZN - Get Report) shares hit a record high Friday after the global online retailer posted much-stronger-than-expected second quarter earnings and said aggressive cost-cutting and higher-margin business would deliver forecast busting profits over the summer months.

Amazon said earnings for the three months ending in June came in at $5.07 per shares, more than double the consensus forecast of $2.48 and up from just 40 cents a share over the same period last year. Group sales rose 39% to $52.89 billion, the company said, a figure which fell modestly shy of Street forecasts.

The Seattle, Wa.-based group said it sees net income for the three months ending in September, its fiscal third quarter, coming in between $1.4 billion and $2.4 billion, again firmly ahead of analysts' forecasts of around $840 million, thanks in part to the performance of the group's high margin cloud computing business, Amazon Web Services (AWS).

"A big contributor to the quarter and the last few quarters obviously has been strong growth in our highest profitability businesses and also advertising," CFO Brian Olsavsky told reporters on a conference call late Thursday. "We've seen a greater-than-expected efficiency in a lot of our spend in things like warehouses, data centers, marketing."

Amazon shares were marked 3.26% higher in the opening 30 minutes of trading and changing hands at $1,866.93, an all-time high that would extend the stock's year-to-date gain to around 59% and value the group at just over $910 billion. Apple Inc. (AAPL - Get Report) , the world's most-valuable company, will report its fiscal third quarter earnings on July 31. Its shares were marked 0.35% higher at $194.88 each, valuing the Cupertino, Ca.based group at around $950 billion.

"Overall, we think this was another really good quarter for the company," said Jim Cramer and the Action Alerts PLUS research team. "The revenue miss and soft guidance does raise some red flags about top-line growth, but what impressed us the most is how quickly Amazon can turn up profitability thanks to an increase sales mix towards AWS, subscriptions, and advertising."

AWS revenue rose 49% year-over-year to $6.11 billion, matching the first quarter growth rate and topping a consensus estimate of $5.98 billion. In addition to AWS's performance, Amazon's EPS got a boost from the fact that the North American segment's operating income, which has been pressured by heavy spending, more than quadrupled to $1.84 billion.

"We're very happy with the results we're seeing, and the backlog that we see, and the new contracts and new customers and the expansion of existing customer business that we see," Olsavsky told investors on a conference call. "Again, the business has accelerated the last three quarters, and we're seeing great signs in a number of areas.

"The operating margin itself will fluctuate quarter-to-quarter, a very strong performance this quarter," he added. "Obviously, part of that was in the capital leases being flat year-over-year, and the team's ability to really run the data centers at a higher efficiency."

Amazon's total North American sales rose 44.2% to $32.169 billion, the company said, well outpacing the 27% growth rate seen from its international operations, which generated net sales of $14.6 billion. 

Online services were the group's biggest bottom-line contributor, with sales of $27.615 billion, up from $23.75 billion in the same period last year, while physical store sales were tabbed at $4.3 billion. Advertizing and "other" revenues, the company said, rose more than 130% to $2.2 billion.

"I would say that, in addition to the operating efficiencies, advertising is also starting to make an impact on gross profit, although advertising is smaller in International segment than it's in North America, it's growing at a same rapid clip year-over-year," Olsavsky said. 

"Even while in International, we're continuing to invest in a lot of areas, we continue to frontload Prime benefits for the newer geographies, we continue to launch new countries as we launch Prime in Australia recently, he added. "We've launched devices in multiple countries, Echo and Alexa were launched in France."