Until last year, Amazon was known as much for its ubiquity in online retail as it was for the bold and expensive visions of CEO Jeff Bezos. The company would spend mightily, only to assuage investor fears with promises of a bright future. Many of those investments, like cloud computing, have become huge and profitable businesses. Some — like the failed Fire Phone —have fallen flat on their face. Now, however, Amazon appears to have hit its stride as Bezos' long-term visions for the future begin paying off big time. For the fifth straight quarter, Amazon has earned a profit. This time around, that profit is bigger than it's ever been before, and by a large margin.

For the second fiscal quarter of 2016, Amazon posted a profit of $857 million, or $1.78 a share, on revenue of $30.1 billion, making these past three months its most profitable quarter in its history. Those earnings handily beat Wall Street expectations, with investors putting Amazon at EPS of $1.11 a share on revenue of $29.56 billion. Year over year, Amazon's profit is up 832 percent while sales have jumped 31 percent from the second quarter of 2015, when Amazon made a profit of only $92 million. After a brief and perplexing dive, Amazon's stock is now up 3 percent, and its share price has jumped more than 40 percent in the last 12 months.

Amazon posted its biggest quarterly profit in the company's history

So where is this money coming from? Multiple places, in fact. Amazon has begun turning the corner on its more costly sectors like international retail. It's also ramped up investment in cloud computing with the highly profitable Amazon Web Services. Lastly, the company is figuring out ways to cut its logistics costs as it adds more delivery flexibility for its Prime subscription service, which continues to grow and now sits at 60 million members in the US alone. This past week, Prime launched in India. Despite its obvious free shipping perk, Amazon continues to use the service as a way to bring new products, like video streaming and food delivery, to new markets.

"It’s been a busy few months for Amazon around the world, and particularly in India — where we launched a new AWS Region, introduced Prime with unlimited free shipping, and announced that Prime Video is coming soon, offering Prime members in India exclusive access to Amazon Original Series and Movies — including original content featuring top Indian creators and talent," Bezos said in a statement. "The team in India is inventing at a torrid pace, and we’re very grateful to our Indian customers for their welcoming response."

AWS, Amazon's cloud computing platform used by companies as big as Netflix and Spotify, continues to grow. The division more recently added Salesforce as a primary customer, Amazon says, and it posted profit of $718 million on $2.9 billion in sales. That's a 135 percent jump in profit and 58 percent jump in sales compared with the year-ago quarter. For the second straight quarter, AWS earns Amazon more profit than its entire North American retail division.

Amazon's international retail division still loses it money, but it's closing the gap. This past quarter, the division posted an operating loss of $135 million, down 29 percent from $189 million in the second quarter of 2015.

It's an open question whether Amazon can continue to sustain this profit growth, but the answer may not arrive for some time. Due to the huge success of the company's second annual Prime Day, which occurred on July 12th and broke sales records, the fiscal third quarter ending September 30th may result in yet another big beat. Worldwide Amazon orders rose 60 percent from last year's Prime Day, which amounts to a potential bump of $600 million in additional sales. For the current quarter, Amazon forecasts sales of $31 billion to $33.5 billion.