The market has experienced some wild swings over the past few months. But there's been one bright spot among the turmoil: tech stocks. Many investors have seen the shift made by companies to remote work and have looked for stocks that are benefiting from this monumental change. 

But not all tech companies are benefiting in the same way, and not all tech stocks are great long-term investments. That's why a few Motley Fool contributors put together this list of the top tech stocks to buy right now. MongoDB (MDB -2.41%), Microsoft (MSFT -1.27%), and Okta (OKTA -1.79%) are all experiencing growth during this difficult economic time, and are perfectly poised to keep growing over the long haul. Here's why these companies are worth adding to your buy list. 

Woman pointing to computer screen with graphs on it.

Image source: Getty Images.

This cloud database provider is just getting started 

Brian Withers (MongoDB): A lot has happened in the last 50 years, especially in tech. Mobile phones came on the scene in the 1980s, the internet and smartphones in the 1990s, and cloud computing in the 2000s. But interestingly enough, most of the world's applications are powered by databases that are based on an SQL (or relational, think rows and columns) architecture that was developed in the 1970s. MongoDB was founded to change that.

In 2007, MongoDB set about creating a modern database from the ground up that was cloud-scalable, flexible, and reliable to meet the increasing performance demands of today's applications. In 2009, it released the first version of its document database for the world. Since then, it has become the most popular NoSQL (non-relational) database for developers, according to the DB-Engines Ranking, and is used by over 18,400 customers in 100-plus countries.

The company's database comes in two flavors, a cloud-based product called Atlas and an on-premise version called MongoDB Enterprise Advanced. The cloud version is growing faster (75% year-over-year growth last quarter) and represents 42% of the top line. The on-premise model, which a company installs on its servers behind its own firewall, is popular for larger companies that want more control over access and how the database is used. Between these two products, the company has an annual revenue run rate of $462 million and an impressive revenue retention rate of 120%.

But the reason why this database specialist is one of the top tech stocks to buy in August is that it's just barely tapped its market opportunity. IDC estimates the database market to be $71 billion in 2020, growing to $97 billion in 2023. That puts its current market share at less than 1% of this year's number. With much of the $26 billion in new market demand going toward modern cloud-based applications, MongoDB is in a perfect position to capitalize. Additionally, as companies go through upgrade cycles for its legacy enterprise applications every 8 to 10 years, there's even more opportunity to grow.

It's not surprising that this growth company isn't profitable yet, but with $978 million in cash and marketable securities it has plenty of a cushion to continue investing in its growth for years to come. Even though its stock seems pricey at a 25 price-to-sales ratio, the quality of this business and the huge opportunity make it worth paying up for this database specialist.

The entrance to a Microsoft building, with a sign that says Microsoft

Image source: Microsoft.

Diversity is its strength

Danny Vena (Microsoft): Even in the face of the pandemic, Microsoft has shown why it's one of the few stocks worthy of a $1.5 trillion valuation, able to capitalize on the ongoing stay-at-home and remote work trends. It's the diversity of Microsoft's business that gives the company an edge against a number of its competitors. This was evident when Microsoft reported the results of its fiscal fourth quarter (ended June 30), as each of the company's major business segments outperformed expectations, and there were even a few surprises.

Remote work has accelerated the use of cloud computing for distributed workforces, playing to several of Microsoft's many strengths. The company has a solid foundation of business productivity customers who already use Office, Microsoft 365, and Dynamics 365, and those subscriptions continued to bring in boatloads of cash for the company as employers scrambled to outfit employees working from home. This led the productivity and business processes segment to grow 6% year over year. The segment also got a boost from demand for Microsoft's Teams workplace collaboration tool.

Azure, the company's cloud computing operation, has consistently grown faster than Alphabet's (NASDAQ: GOOGL) (NASDAQ: GOOG) Google Cloud and Amazon (NASDAQ: AMZN) Web Services -- its two biggest competitors. Azure grew 47% year over year during the quarter, leading the intelligent cloud segment to 17% growth. Microsoft noted that cloud computing generated $50 billion in revenue for the first time during the trailing-12-month period.

The resilience of the more personal computing segment was on full display, as consumers equipped their home offices with computers outfitted with Windows. Revenue from the segment grew 14%, which also got a boost from a couple of unlikely contributors. Xbox content and services revenue climbed above $1 billion for the quarter, soaring 65% year over year, while sales of the Surface family of laptops and notebooks grew 28%.

Yet even as several businesses -- including LinkedIn and search advertising -- took a hit from the pandemic, the bigger takeaway is that the diversity of Microsoft's offerings has helped insulate it from the damage many companies have suffered as a result of the economic downturn. This will help Microsoft thrive for years to come.

A person sitting on the floor using a laptop.

Image source: Getty Images.

Okta's services couldn't be in a better position right now

Chris Neiger (Okta): Okta may not be a household name, but the company's services are some of the best in the niche identity and access management market. Okta's cloud-based services allow people to easily and safely log in to software and apps, allowing companies to manage all the online permissions for their employees. 

The identity and access management market was already well on its way to becoming a $24 billion industry by 2025, and the coronavirus pandemic has accelerated the need for Okta's services. The company reported a 46% increase in first-quarter sales at the end of May, fueled in part by a 48% increase in Okta's subscription revenue.

While the pandemic has harmed many companies' top and bottom lines, Okta's management forecasts sales growth of 32% at the midpoint for fiscal 2021, and the company continues to add high-dollar customers, including 113 new customers with annual contracts worth more than $100,000 in the first quarter. 

And Okta's customers are very happy with their services, which has led to the company having a dollar retention rate in fiscal 2020 of 119%, meaning that customers are not only keeping the services they initially signed up for, but are adding new ones as well.

Okta's co-founder and CEO, Todd McKinnon, doesn't expect the company's growth to slow down post-pandemic. He said in a first-quarter press release: "When this crisis is over, we don't expect organizations to revert to their prior ways of working. Our commitment to our customers and continued focus on operational agility will help us navigate this environment, lead the new way of work, and seize the opportunity to emerge in an even stronger position."

Okta's share price has soared 86% since the beginning of this year, but there's likely still more room for this stock to grow. As more and more companies look to long-term remote work solutions for their employees, Okta's services will be in demand more than ever before.