As open source software grows more popular, and important, developers face an existential question: How to make money from something you give away for free?

The Open Source Initiative standards body says an open source license must allow users to view the underlying source code, modify it, and share it as they see fit. Independent developers and large companies alike now routinely release software under these licenses. Many coders believe open collaboration results in better software. Some companies open their code for marketing purposes. Open source software now underpins much technology, from smartphone operating systems to government websites.

"The entire world runs on open source software and we have no idea how to sustain that without destroying people" by essentially asking them to work for free, says John Anderson, vice president of technology at consulting firm Infinity Interactive.

Companies that release software under open source licenses generate revenue in different ways. Some sell support, including Red Hat, which IBM acquired for $34 billion earlier this month. Others, like cloud automation company HashiCorp, sell proprietary software based on the open source components. But with the rise of cloud computing, developers see their open source code being bundled into services and sold by other companies. Amazon, for example, sells a cloud-hosted service based on the popular open source database Redis, which competes with a similar cloud-hosted service offered by Redis Labs, the sponsor of the open source project.

To protect against such scenarios, companies behind popular open source projects are restricting how others can use their software. Redis Labs started the trend last year when it relicensed several add-ons for its core product under terms that essentially prohibit offering those add-ons as part of a commercial cloud computing service. That way, Amazon and other cloud providers can’t use those add-ons in their competing Redis services. Companies that want the functionality provided by those add-ons need to develop those features themselves, or get permission from Redis Labs.

“We felt that if we continue to license all this innovation under liberal open source licenses, then the cloud providers could start hosting it as a service, without contributing anything back to the community, and extract a lot of economic value out of the ecosystem," Redis Labs chief marketing officer Howard Ting says. "Then we wouldn't be able to fund this investment and give back to the community."

Analytics company Confluent and database maker CockroachDB added similar terms to their licenses, preventing cloud computing companies from using some or all of their code to build competing services. Taking a slightly different tack, MongoDB relicensed its flagship database product last year under a new "Server Side Public License" (SSPL) that requires companies that sell the database system as a cloud service also release the source code of any additional software they include. Alternatively, customers can buy a commercial license from MongoDB.

Offering the same software under two different licenses, known as “dual licensing,” is controversial in the open source community. The Open Source Initiative doesn't consider the SSPL, or any of these other newly adopted licenses, to be open source licenses.

Ting, of Redis Labs, says the new approaches are working. For example, earlier this year Google announced revenue sharing partnerships with several open source companies, including Redis Labs, Confluent, and MongoDB. But the new licenses haven’t stopped Amazon from selling its own services based on open source projects commercialized by the three companies. For example, Amazon in January launched DocumentDB, a database service compatible with an earlier version of MongoDB that included more permissive license terms.

Amazon says it is a friend, not a foe, of open source software. In a talk at the Oscon open source conference in Portland, Oregon, earlier this month, Amazon Web Services technologist Arun Gupta touted the company's contributions to open source, such as the virtual-machine management system Firecracker Amazon released last November. Gupta also pointed out that Amazon has contributed code to outside projects, including some encryption software for Redis that it released last year.