Selling your Facebook (NASDAQ:FB) shares over concerns about increased spending would be a short-sighted move. More than that, it would be one that ignores a key ingredient in Facebook's tremendous success over the past few years.

Facebook delivered strong top-line growth in the just-reported second quarter, notching a 39% bump in revenue over the prior-year quarter, including a 43% increase in advertising sales. It also boasted a 29% increase in daily mobile users, and 17% growth in its monthly active users overall -- not an easy feat when a company already counts nearly one in every five people on the planet as an active monthly user.

Still, the social network's earnings failed to impress, with EPS coming in 17% below the second quarter of 2014, and the stock dropped from $96.99 prior to the July 29 release to a next-day low of $91.80. Although shares are up from that low, they are still down from the pre-earnings closing price,and there remains a concern over just how much Facebook is spending to achieve its impressive growth in users and ad sales. Total costs and expenses for the quarter were up a whopping 82%.

These spending concerns are overblown at least, and misguided at worst. Investors should be embracing this spending push, and they need only look at the company's own recent history to see why.

Over the past six months, Facebook increased its research-and-development spending by 136% -- or a staggering $1.3 billion. That R&D accounts for nearly two-thirds of the total spending increase over that time.

A look at Facebook's R&D spending over time shows us that it's headed upward -- and rather sharply.

FB Research and Development Expense (TTM) Chart

FB Research and Development Expense (TTM) data by YCharts

A spike like that is enough to raise eyebrows, but let's put this into historical context.

Remember those mobile worries?
In late 2012, just months after Facebook went public, one of the biggest concerns among investors was whether the company could meaningfully monetize mobile Internet use. We'd already seen from Google that mobile ads generated less revenue than standard Web ads, and it was starting to look like mobile-heavy companies might be forced to trade dollars for dimes.

Adding to those concerns was the reported early mobile success of Facebook rival Twitter. Twitter's then-CEO, Dick Costolo, boasted that unlike its rivals (read: Facebook), the company was making more on mobile ads than on desktop ads many days.

That drew headlines like this one from Mobile Marketer: "Twitter monetizes mobile where others fail."

Facebook CEO Mark Zuckerberg at the time forecast good things to come on the mobile front over the longer term.  What followed was a steep increase in R&D spending for Facebook.  

Facebook has since carved out a dominant position in mobile, where its sites and apps now reportedly account for one out of every five minutes spent on a smartphone. It's also capitalized on that position, growing mobile advertising from nothing in 2012 to a nearly $3 billion-per-quarter business. 

Infographic: Where Facebook's Revenue Growth Comes From | Statista
You will find more statistics at Statista

Today, mobile advertising is what's driving Facebook, but Facebook's work is far from over in mobile. Ad products need continual improvement, and advertisers are demanding more from Web and social platforms in terms of the return they're getting for their investment.

Facebook has also recognized that as mobile Web consumption habits change, video is becoming a larger part of use. Add to that the fact that Facebook is building out its family of apps and ad platforms, and what works in the mobile News Feed may not work in Messenger, or Instagram, or WhatsApp, when the company decides to start monetizing that platform.

Some areas of investment
That's why it's important for Facebook to spend smartly now. In the most recent earnings call, company executives highlighted several areas where it will be making investments.

It plans to continue improving the News Feed, which it sees as the core driver of use in the near term. It will be investing in WhatsApp and Messenger, which figure into the picture more prominently in the long term. It won't be focusing on ads first, but on continuing to improve the user experience while it figures what types of ads would work best on each platform, Zuckerberg said.

It also will spend on monetizing Instagram, where it has been ramping up advertising slowly, and as COO Cheryl Sandberg said, "very, very cautiously." It will be introducing new ad formats on the platform and offering advertising in new markets.

Facebook is also continuing to develop ways for businesses to measure the effectiveness of their ads, which should be key moving forward, as businesses face an ever-widening array of advertising outlets.

We've seen this before, and it turned out well
And as it turns out, it's spending at just about the same rate of its revenue as it was when it was ramping up for the mobile revolution.

FB R&D to Revenue (TTM) Chart

FB R&D to Revenue (TTM) data by YCharts

Capitalizing on its strong position
Facebook had 10,955 employees at the end of June, up 52% compared with the previous year. It added nearly 900 employees in the second quarter alone, and CFO David Wehner said most of those workers will be conducting R&D.

Facebook has built an incredibly strong position in mobile right now, and it needs to find ways to capitalize on that. Increased R&D is integral here. And when viewed in terms of a percentage of revenue, the levels of R&D expenses it's incurring right now are on a par with its expenses in the mobile ramp-up.

Investors shouldn't be chased off by the spending. They should welcome it.

John-Erik Koslosky owns shares of Facebook, Google (A shares), and Twitter. The Motley Fool recommends Facebook, Google (A shares), Google (C shares), and Twitter. The Motley Fool owns shares of Facebook, Google (A shares), Google (C shares), and Twitter. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.