Amazon announced its profit for the quarter was another record, with nearly double profit margins and posting five consecutive quarters with a profit.

Revenue at Amazon was up 31% with 58% coming from its Amazon Web Services segment. The e-commerce giant, which used to carry profit margins that were razor thin, managed to nearly double that number for the quarter, prompting it to post optimistic projections about its upcoming quarter.

After the earnings call by Amazon, shares of the business jumped by 2%.

One analyst said the revenue growth acceleration was a nice surprise. He added that this could create some high expectations for shareholders going forward.

The positive numbers for Amazon come after the business invested despite recording losses during the prior quarter. The most recent time the company posted five straight profitable quarters was nearly 4 years ago.

Following that, Amazon directed the majority of revenue back into its operations and its product development. The opening of new warehouses became an important element in the assurance of faster delivery times for its customers.

Amazon CFO Brian Olsavsky noted that the business remains faithful to its philosophy of investment. He pointed out over 18 additional warehouses are scheduled for construction during the ongoing quarter, which is over three times the number it built last year.

The company’s margin for operating profit increased to just over 4.2%. This is over twice as high as its 2% during 2015 and a strong signal that Amazon held a good grip on costs.

Looking at the large numbers for the second quarter, Amazon had profit of $857 million, as compared to the same period last year of $92 million.

Sales moved higher ending the quarter at $30.3 billion compared to $23.18 billion for the same period last year.

One reason the big boost was enjoyed by the company was its Amazon Web Services cloud computing, which provides its customers with access to the power of computing over the Web.

While during 2015, revenue at AWS was $1.82 billion, this year the company managed to pull in over $2.89 billion. That arm is essential for Amazon to maintain faith from investors in the business as it crafted itself into the best provider of services for big corporations, government agencies as well as startups.

Get Analysts' Upgrades and Downgrades Daily - Enter your email address below to receive a concise daily summary of analysts' upgrades, downgrades and new coverage with MarketBeat.com's FREE daily email newsletter.