Image source: Getty Images.

Facebook (META -4.13%) and Amazon.com (AMZN -2.56%) are two of the greatest companies on earth. What both have accomplished -- through the revolutionary and long-term thinking of their founder/CEOs -- puts them in rarefied company.

Facebook and Amazon make up 11% and 21%, respectively, of my real-life holdings. Some might argue that such heavy allocations aren't a good idea. And for many investors, that may be true. But I am comfortable with both for reasons that I'll explain below.

Since my Amazon ownership is almost double my Facebook holdings, you might think that I prefer the former to the latter. But that doesn't tell the whole story. I've actually put more capital behind purchasing Facebook stock, but Amazon's has done so well -- over such a long time period -- that it's simply grown into that valuation.

So which is the better stock to buy today? Here's how they look when viewed through three key lenses.

1. Financial fortitude

While cash in the bank isn't sexy, it's hugely important. When a business -- or the economy as a whole -- runs into tough times, cash gives a company options. It allows a company to outspend rivals, buy back shares, increase its dividend, or even make a splashy acquisition.

Debt has the exact opposite effect. Being caught with debt during a downturn means that you'll have to shrink your industry presence, cut back on future-focused research and development, and assume a single-minded survival approach.

When it comes to financial fortitude, both Amazon and Facebook are in good shape, but one is the clear leader.

 

Cash

Debt

Net Income

Free Cash Flow

Amazon

$15.9 B

$17.6 B

$1.16 B

$6.37 B

Facebook

$20.6 B

$0

$4.67 B

$6.73 B

Data source: Yahoo! Finance. Net Income and free cash flow represent trailing 12 months.

Amazon CEO Jeff Bezos is (in)famous for playing the uber-long game: sacrificing short-term profits for long-term dominance in the decades to come. Using the company's stock as a proxy, he's been very successful in that endeavor.

But the flip side to that is the fact that net income is far below that of Facebook. While Amazon is by no means in a perilous position -- it creates more than enough free cash flow to cover its obligations -- it isn't as strong, financially, as Facebook. With over $20 billion in the bank and no debt, Facebook would undeniably be able to weather any broad economic downturn.

Winner = Facebook

2. Sustainable competitive advantages

Since I began investing eight years ago, no variable has had more influence on the success of an investment than the underlying company's sustainable competitive advantage.

Facebook has one of the strongest advantages possible: the network effect. With each additional Facebook (or WhatsApp, or Instagram) user, other non-users have more incentive to join, which incentivizes even more. It's a virtuous cycle that lets Facebook collect gobs of data and use that data to sell advertising impressions to businesses.

Amazon benefits from the network effect as well, albeit in a weaker format. Because the website is so popular with shoppers, it makes more sense for small and medium-sized businesses to use Amazon's fulfillment services to build up an e-commerce presence, than to try and build one on their own.

Additionally, because Amazon has an unmatched network of fulfillment centers to guarantee two-day shipping, it would be prohibitively expensive for any competitor to match that scale.

Both of these companies have impressively wide moats surrounding them.

Winner = Tie

3. Valuation

There are many ways to value a business, and no one metric is perfect. That being said, here are four that I typically reference when measuring a stock's value.

 

P/E

P/FCF

P/S

PEG Ratio

Amazon

307

55

3.1

2.8

Facebook

44

50

16.9

0.95

Data sources: Yahoo! Finance, E*Trade. P/E = price to earnings. P/FCF = price to free cash flow. P/S = price to sales. PEG = price/earnings to growth. P/E is based on non-GAAP earnings.

Here, again, we go back to Bezos' successful approach in playing the long game. Because he is so willing to pour money into Amazon's investments, the company's net income is deflated. That leads to the stock trading for a much higher valuation than Facebook.

While Facebook might have a higher price-to-sales ratio, that's largely because its margins are much more impressive. Given that Facebook's PEG ratio -- which takes growth into consideration -- is below one, it's clear that Facebook is actually trading for a somewhat fair price today.

Winner = Facebook

So there you have it: Even though Amazon is clearly my dominant position, I think Facebook is a better buy at today's prices. That's no guarantee, however, that one will outperform the other over the next five years. In the end, both deserve serious consideration for inclusion in just about every Foolish portfolio.