In the early days of Amazon, Jeff Bezos instituted a rule: every internal team should be small enough that it can be fed with two pizzas. The goal wasn’t to cut down on the catering bill. It was, like almost everything Amazon does, focused on two aims: efficiency and scalability. The former is obvious. A smaller team spends less time managing timetables and keeping people up to date, and more time doing what needs to be done. But it’s the latter that really matters for Amazon.

The thing about having lots of small teams is that they all need to be able to work together, and to be able to access the common resources of the company, in order to achieve their larger goals.

That’s what turns the company into, in the words of Benedict Evans, of venture capital firm Andreessen Horowitz, “a machine that makes the machine”.

“You can add new product lines without adding new internal structure or direct reports, and you can add them without meetings and projects and process in the logistics and e-commerce platforms,” Evans notes. “You don’t need to fly to Seattle and schedule a bunch of meetings to get people to implement support for launching makeup in Italy, or persuade anyone to add things to their roadmap.”

Amazon is good at being an e-commerce company that sells things, but what it’s great at is making new e-commerce companies that sell new things.

The company calls this approach its “flywheel”: it takes the scale that can smother a typical multinational, and uses it to provide an ever-increasing momentum backing up its entire business. The faster the flywheel spins, and the heavier it is, the harder it is for anyone else to stop it.

Amazon’s distribution centre in Phoenix, Arizona. Photograph: Ralph Freso / Reuters/Reuters

Perhaps the best example of that approach in action is the birth and growth of AWS (previously called Amazon Web Services). That’s the division of Amazon that provides cloud computing services, both internally and for other companies – including those that are competitors to Amazon in other areas (both Netflix and Tesco use the platform, for instance, despite Amazon also selling streaming video and groceries).

It started, like so many things at Amazon, with an edict from the top. Every team, Bezos ordered, should begin to work with each other only in a structured, systematic way. If an advertising team needed some data on shoe sales to decide how best to spend their resources, they could not email analytics and ask for it; they needed to go to the analytics dashboard themselves and get it. If that dashboard didn’t exist, it needed to be created. And that approach needed to cover everything.

From there, it was almost an afterthought to take the obvious next step, and let others use the same technology that Amazon made available internally.

Those humble beginnings spawned a beast. The business is now 10% of Amazon’s overall revenue, making so much money that financial regulations forced the company to report it as a top-level division in its own right: Amazon divides its company into “US and Canada”, “International”, and “AWS”.

AWS is large enough that it is dealt with on the same tier as the entire rest of the world. AWS is large enough that Netflix, a company that accounts for around a third of all internet traffic in North America, is just another customer.

AWS is large enough that in 2016 the company released the “Snowmobile”, a literal truck for moving data. The companies that work with AWS move so much information around that sometimes the internet simply cannot cope. So now, if you want to upload a lot of data to Amazon’s cloud, the company will drive a truck to your office, fill it with data, then drive it back. If you need to upload 100 petabytes – that’s roughly 5m movies in 4k with surround sound – it turns out there’s no quicker way to do it than driving it down the freeway at 75mph.

While AWS saw Amazon open up its internal technology to external customers, another part of the company does the same trick with Amazon’s actual website.

Amazon Marketplace launched in 2000, allowing third-party sellers to put up their own wares on the site. The feature has expanded over the years to become a major plank in the company’s quest to be the “everything store” – the one destination on the internet you need to go to to buy anything in existence.

Marketplace goes one better than the pizza rule, allowing Amazon to expand into new sectors without needing to employ a single extra employee.

The variety of things sold on Amazon is now so huge that its internal computer scientists faced a problem. “E-commerce companies such as Amazon … process billions of orders every year,” a team of Amazon researchers wrote. “However, these orders represent only a small fraction of all plausible orders.” The solution? Train an artificial intelligence purely to generate plausible fake orders, to better guess how to market brand-new products.

Amazon reports the revenue it makes from Marketplace as around 20% of the company’s total income. But that metric, which only counts the fees paid to the company by third-party sellers, understates the colossal scale of the business. “Marketplace is now around half of the total volume of goods sold through Amazon,” estimates Andreessen Horowitz’s Evans. “In other words, Marketplace means that Amazon handles (but does not, incidentally, itself set prices for) double the share of e-commerce that it reports as revenue.”

Increasingly, then, Amazon resembles less a big-box retailer such as Tesco or Walmart, hovering at the edge of town sucking up commerce and killing the local high street, and more a shopping mall: independent retailers can exist, and even make a tidy living, but only if they get a slot in the mall itself – and if they always remember that the real moneymaker is the landlord.

Since 2014, Amazon has added a third flywheel to its business: artificial intelligence. The company has always been near the leading edge of the industry, most obviously in its neural-network-powered recommendation algorithms. But, until recently, that approach was scattershot, segmented, and hardly world-class (think of the last time you bought something on Amazon only to have it recommended to you for weeks afterwards. “You like duvets? Why not buy 10 more?”).

An Amazon Echo Dot. Photograph: Elaine Thompson/AP

That changed when the company decided to build the hardware that would become the Echo. In classic Amazon fashion, it started at the end and worked backwards from there, writing a “press release” for the notional future product and then trying to figure out what expertise needed to be developed – or bought – to make it. Need a personal assistant? Buy Cambridge-based True Knowledge, once working on a Siri competitor, and you get Alexa. Require far-field voice recognition, letting you hear people on the other side of the room? Start working on that now, because no one’s really cracked the problem.

Institutionally, the bulk of the Alexa AI team still sits under AWS, using its infrastructure and offering another tranche of digital services to third parties who want to build speech control into their devices. But the economies of scale that come to AI are unique. There’s the value to the data, of course: the more people use an Echo, the more speech samples it has to train with, and so the better the Echo becomes. And beyond that, machine learning technologies are so fundamental, and so general purpose, that every advancement Amazon makes ricochets throughout its business, increasing efficiency, opening up new fields, and suggesting further avenues of research.

But nothing lasts forever, and even Amazon has its weak points. The two-pizza rule, for instance, may be a good strategy for building an infinitely expandable company, but it doesn’t lend itself to a pleasant, stress-free working environment.

Amazon has long faced criticism over its treatment of warehouse workers: as with many companies in its sector, huge valuations and high-tech aspirations sit uneasily alongside the low-paid, low-skilled work that makes the company tick over.

Where Amazon differs from companies such as Deliveroo, Apple and Facebook is that the highly skilled employees sitting in the headquarters have almost as many complaints.

A New York Times exposé from 2015 described employees crying at their desks and suffering near-breakdowns from the pressure they were put under. Amazon denied a number of allegations made in the article.

The company’s rapid employee turnover is legendary, with insiders describing a sort of Forth Bridge of technical debt: someone leaves, and someone else has to rewrite all their code to make it understandable to the people still there – but by the time the rewrite is finished, the person doing the rewriting has also left, requiring someone else to start the whole process again.

But the one thing that’s been true from day one is that Jeff Bezos sits at the top of the food chain, with direct control of a $740bn (£530bn) business matched by few other bosses. It would take a bold gambler to bet against the company right now.

• This article was amended on 26 April 2018 to make clear that Amazon denied allegations made about it in a New York Times piece.