One of the little-known facts about social game giant Zynga is that it’s one of the biggest operators of cloud computing infrastructure, built to support its current customer base of more than 281 million monthly active users.

For much of its four-year history, Zynga has relied on a third-party hosting company, Amazon Web Services, for the hardware infrastructure for its server-based games such as FarmVille on Facebook. But to cut costs and diversify its risks, Zynga is now investing more money in building its own data centers, according to the company’s initial public offering filing with the Securities and Exchange Commission.

Zynga considers the investment in its own infrastructure to be important enough to warrant an investment of $100 – $150 million in the second half of 2011, according to the filing.

The company’s relationship with Amazon, which makes its own data centers available to host applications from third-party customers, allowed Zynga to grow quickly in its early days. Most Facebook game companies use Amazon as well, but the ability to design applications that can scale up in the number of users quickly is one of Zynga’s competitive advantages, according to an interview last September with Zynga’s chief technology officer, Cadir Lee.

For instance, Zynga wasn’t the first to produce a major farm simulation game. Farm Town came out before Zynga’s title, FarmVille. But Farm Town had trouble scaling as it grew well beyond 10 million users, while Zynga’s FarmVille, built on an engine acquired with the purchase of MyMiniLife, was able to pass Farm Town in part because it scaled well and didn’t have performance slowdowns as it added more and more users. That’s a credit not only to the quality of the application and the engine, but to Amazon as well.

“It’s not the amount of hardware that matters,” Lee said in September, 2010. “It’s the architecture of the application. You have to work at making your app architecture so that it takes advantage of Amazon. You have to have complete fluidity with the storage tier, the web tier. We are running our own data centers. We are looking more at doing our own data centers with more of a private cloud.”

Right now, Zynga can add as many as 1,000 new servers to accommodate a surge of users in a 24-hour period. The company’s servers can deliver a petabyte of data to users each day.

The question remains whether Zynga will migrate fully to its own private cloud, or its own infrastructure, and move away from Amazon Web Services. Zynga said that one of its risk factors is its dependence on Amazon Web Services, which had an outage for several hours in April that made it impossible for users to log into some of Zynga’s games. Zynga does not specifically say in its IPO document that it wants to get rid of Amazon.

Zynga also said that it’s hosting costs go up when the company’s user demand exceeds its planned capacity. If Zynga needs more computing power than it ordered in advance because a game is taking off quickly, it has to pay more to its hosting company to get that additional temporary data center capacity. If Zynga owned its own data centers outright, it wouldn’t have that problem.

If Zynga also made improvements to its data centers, the cost improvements would fall to Zynga’s bottom line. For instance, if Zynga figured out how to cut its electricity costs in its data centers, Amazon would get the benefit of that now. If Zynga owned the data centers entirely, Zynga itself would benefit from the cost savings.

But owning data centers also comes with risks. If the demand for Zynga’s games were to drop dramatically, as has happened on occasion, Zynga would get caught with too much infrastructure on its hands and losses could result. That’s probably why Zynga will likely own part of its data centers and will rely on external hosts for the rest.

In any event, the fact that Zynga is considering such an option of owning its own data centers puts it into rare company. Only the biggest companies such as Facebook, Google, and Apple have invested in owning their own data center operations, when their user counts run into the hundreds of millions of users.