With the shift to the cloud in full swing, along with the impact of the Internet of Things (IoT) and the reams of information its "gadgets" collect, the need for security solutions seems obvious. So, why did FireEye Inc (MNDT) have such a dismal 2016 and Fortinet (FTNT 0.72%) merely a so-so year?

Fortinet CEO Ken Xie  said the tough 2016 security market was because of "extended sales cycles" and "a moderated spending environment." Xie could have added that competition from big hitters including Cisco, among others, likely played a role in the two upstarts' struggles. Looking ahead, both FireEye and Fortinet offer compelling growth stories, but which is the better buy?

Image source: FireEye.

The case for FireEye

In the past year, FireEye stock nosedived about 40%. Like others in its peer group, FireEye has been living on strong sales growth to overshadow its money-losing quarters. But its revenue growth slowed to "just" 13% after reporting $186.4 million last quarter. To put that into perspective, in 2015's third quarter, FireEye had reported a whopping 45% year-over-year jump in sales to $165.6 million

Unfortunately, the mid-range revenue outlook for the current quarter of $190 million doesn't bode well. A year ago, FireEye reported $184.8 million in sales, meaning at the mid-range of its forecast investors can expect year-over-year growth of 2.7%. But not all is lost, as FireEye implements a restructuring plan that is already paying dividends.

Last quarter, FireEye boasted its best operating margin ever, climbing to 74% after accounting for one-time items. The margin boost was the result of reducing its "total expense base" by over $10 million compared to the previous quarter. The expense management effort is a much-needed step in the right direction, particularly in light of slowing sales in the near future.

Building recurring subscription and services revenue, another focus of CEO Kevin Mandia and his team, will impact top-line growth in the near term as well, but creating a more reliable foundation in the years ahead is a sound move. Toward that end, last quarter was an unmitigated success. FireEye's $142.55 million in subscription and services sales was a whopping 35% jump compared to a year ago.

Image source: Fortinet.

The case for Fortinet

After a year of reporting 30% or higher sales growth, Fortinet's $316.6 million in the third quarter was good for a 22% improvement. Like FireEye, Fortinet has not been shy about opening its checkbook, but it's a bit further along in getting a handle on spending -- at least enough of a handle to generate profits as it did again last quarter.

That said, despite its 22% jump in sales, Fortinet's $0.04 earnings per share in the third quarter was down from $0.05 a year ago. The culprit was a $49.25 million increase in combined cost of revenue and total operating expenses over 2015's third quarter. But that should change in the coming quarters.

Fortinet's focus on service sales should help it better manage expenses, particularly as it relates to sales and marketing costs. Providing ongoing services to existing customers doesn't require the same sales and marketing effort that one-time hardware products do. For some perspective, last quarter Fortinet spent $154.1 million in sales-related overhead, equal to an eye-popping 49% of total revenue.

As measured by deferred revenue, Fortinet's future looks awfully bright. Last quarter's $934.8 million in deferred sales was an impressive 32% jump over a year ago. And free cash flow soared 36% to $70.2 million in the third quarter, helping to boost Fortinet's cash and equivalents position to $1.27 billion, despite the spending hike.

Which is the better buy?

If you have the time and the risk tolerance to handle occasional wild swings in share price, FireEye offers a compelling growth investment alternative, particularly considering its focus on decreasing overhead and increasing recurring revenue. A time-consuming initiative but worth the wait.

For investors with an appreciation for profitability but less tolerance for roller-coaster-like stock price rides, Fortinet is the better buy due to its relative stability and stronger top-line growth, even as it pursues its own service-related sales.