The future is not rosy for Russia and Venezuela.

The Kremlin faces a big budget deficit, which it's trying to close with cuts to health and education spending, and a massive 27 percent reduction in its military. Meanwhile, Russia's economy is in recession, and projected to slightly shrink for the third year in a row.

If that sounds bad, check out Venezuela, which is in utter economic pandemonium: Its GDP is projected to shrink 10 percent this year, and it's grappling with triple-digit inflation rates. Mass strikes and protests are breaking out, and its authoritarian government is threatening to crack down.

On the surface, these may seem like two very different countries with two very different sets of problems. But underneath, their woes actually share a common source: oil.

Sixty-eight percent of Russia's exports are in oil, oil products, and natural gas. For Venezuela, oil is a staggering 95 percent of its exports, and the oil industry makes up a quarter of its economy. Even more importantly, though, is the degree to which both governments rely on oil exports to finance themselves. Oil-related revenues supply roughly half the budget for both Russia and Venezuela.

The reason these governments rely on oil isn't hard to understand: If your government pulls in most of its money by exporting oil or other natural resources to the rest of the globe, it can keep taxes on its own people low while showering them with benefits bought with those exports. Sounds like a great deal!

Except relying on one single major export like this tends to screw with a country's economy. The global desire for that export will drive up demand for the country's currency — in Russia's case, the ruble, and in Venezuela's case, the bolívar. That demand drives up the value of the currency, which makes all exports from that country more expensive. So the overreliance on a single export — oil in these instances, but it could be anything — depresses all the other industries in the country.

Now, even as their overreliance on oil wreaked havoc on other industries in their economies, Russia and Venezuela were still pulling in a lot of money from that one export. So they could just import everything else they needed from abroad.

The problem is, this solution only worked as long as oil prices stayed high. And in 2014, the price of oil on the global market collapsed by two-thirds.

The immediate effect in Russia wasn't hard to predict: The government's deficit ballooned.

Normally, Russia's central bank would have responded by buying up the country's debt to prevent a bigger deficit from driving up interest rates or necessitating spending cuts. The trouble was, this would have put upward pressure on inflation and Russia was already dealing with an inflation problem due to its overreliance on oil.

This was a very foreseeable problem. When the rest of the world is driving up demand for your currency by buying just one of your exports, and then the price of that export plummets, the value of your currency will plummet along with it. And that also puts upward pressure on inflation. Sure enough, Russia's inflation rate spiked to over 16 percent following the collapse of oil prices. That left its central bank no room to monetize its debt. The only remaining option was spending cuts and austerity, which will likely drag down its economy further.

Venezuela's predicament is much worse, because the Venezuelan government compounded the damage caused by the fall in oil prices with two policies.

First, the government started instituting price controls way back in 2003 to keep its poorer citizens from facing unaffordable goods and services. But price controls also make domestic businesses and industries less profitable, so they begin closing up shop. Think of the way Venezuela's reliance on oil — which made up far more of its exports than Russia's — depresses all other parts of its economy; price controls basically injected that effect with a massive dose of steroids.

Much of the country's own capacity to produce, sell, and buy basic things like medicine, equipment, and even food within its own borders collapsed. Venezuela began importing all that stuff instead, relying on oil money to fund the purchases from abroad. So when the price of oil plummeted, its economy went into crisis.

Now, the natural reaction to the fall in oil prices would be for the value of the bolívar to collapse too, which brings us to Venezuela's second error: Trying to control the exchange rate. When the government set it at 10 bolívares for every U.S. dollar, it accidentally created a massive black market, where one dollar could be sold for hundreds of bolívares. And since Venezuelan businesses were in crisis, and everyone still needed imports, simply figuring out scams to get dollars and then sell them for bolívares became hugely lucrative. That set off a feedback loop that drove the inflation rate for Venezuela's currency into the stratosphere. Just like how its price controls depressed industries, Venezuela fiddling with its exchange rate supercharged the inflationary pressure from the downturn in oil prices.

As of now, Russia's inflation rate is back down to a merely unpleasant 6 or 7 percent. So its situation is still pretty painful, but it will probably be able to muddle through. Venezuela is another matter entirely.

But in both cases, the lessons should be clear: One, maintain a diverse economy that doesn't rely on just one overwhelming export. And two, finance your government with taxes that draw from the full sweep of that economy. Whatever else your government does — whether its a small free market enterprise or a big socialist-leaning state that provides all sorts of benefits — following those two rules of thumb will serve it well.