Some industries simply fare better than others during a recession. Some struggle because they rely on discretionary spending -- that is, products or services that will have to wait when times are tight. Other industries are more recession-proof because they provide things we can't live without, like food, essential technology, and healthcare, among others.

Here are three stocks from companies in those less affected industries that are built to not only ride out the recession, but grow.

A woman shopping in a big box store looking at the label of a product she may buy.

Image source: Getty Images.

Walmart

As an essential business throughout the COVID-19 shutdowns, Walmart (WMT 0.57%) has continued to perform throughout the recession. While its stock dropped in March when the market crashed, it almost immediately bounced back, and it's up about 11% on the year through midday Monday -- outperforming the S&P 500 and the food and staples retailing industry, both of which are flat.

This big-box store is a classic recession-proof stock -- it sells low-priced merchandise, including food and daily essentials, and its massive market share makes it the world's biggest brick-and-mortar retailer, with $524 billion in revenue last year. Walmart is on pace to beat that this year, as the company generated $134 billion in the first quarter, an 8.6% increase year over year.

Walmart's earnings have been buoyed by strong gains in e-commerce sales, which were up 74% over the first quarter of last year. Walmart has been gaining market share in this space, and is now the second-largest e-commerce retailer behind Amazon -- another reason to like Walmart in this recession.

Mastercard

Mastercard (MA -0.08%) has been one of the most reliable performers over the past decade. Since 2009, the world's second-largest payments company (behind Visa) has had only one year with a negative return: 2010, when the stock was down 12%. Every other year, it has been in positive territory -- including this year, up about 3.5% through midday Monday. It has generated revenue growth every quarter dating back to the first quarter of 2009, and over the last 10 years it has posted an annualized return of 27% per year.

Mastercard and Visa are payment processors. They don't issue the credit cards -- third-party banks do -- but they process the payments and earn fees every time the card is swiped and a purchase is made. So, in a recession, spending is down, which would suggest that revenue would be down. But in the first quarter, Mastercard's net revenue was up 5% and operating income was up 2% year over year. This is on the strength of an 8% increase in gross dollar volume, which is the amount charged, and purchasing volume, which is the number of purchases.

With the world moving rapidly toward electronic payments, accelerated by the COVID-19 social distancing protocols, purchasing volumes should continue to increase as people make more purchases using cards than cash. As the second-largest credit card company in a small pool of competitors, Mastercard should continue to thrive through the recession and beyond.

Dollar Tree

Money doesn't grow on trees, but it does grow during recessions for Dollar Tree (DLTR -0.57%). During the Great Recession and its aftermath, this discount retailer was one of the best-performing stocks on the market, returning 60.8% in 2008, 15.8% in 2009, 74.6% in 2010, and 48.2% in 2011. During hard times, when people have less income to spend, Dollar Tree and Family Dollar -- which Dollar Tree owns -- see a spike in business. In the first quarter, the company posted a net sales increase of 8.2% and a same-store sales jump of 7%. Net income was down about 8% due to an increase in COVID-19-related expenses, including higher payroll costs for wage premiums and bonuses during the pandemic and additional safety and sanitation costs.

Dollar Tree, which appointed a new CEO in July, Michael Witynski, who was promoted from enterprise president, saw even stronger growth from Family Dollar. Overall, the stock is up about 2% this year and analysts expect the company to generate annual earnings growth of about 6.5% over the next five years, which should carry it through the recession in good shape.