How Zynga Survived FarmVille

When Zynga launched FarmVille last June, the company thought 200,000 daily active users in the first two months would be a success. Within eight weeks, the game had surpassed Zynga’s hits of the previous two years. For the first 26 weeks FarmVille added 1 million net new users per week; it currently has 70 million active users a month.

The story of Mark William’s last two years has been one of trying to support such unpredictable growth. “Zynga has been horrible in terms of its ability to predict its success,” said Williams, the company’s VP of network operations. Not that it’s a bad problem to have. Under his watch, Zynga has grown from a few dozen servers to “several thousand” — Williams said maybe he’ll give us a more specific number when he speaks at the GigaOM Structure conference later this month.

At the time of FarmVille’s launch, Zynga had just run out of data center space, so the company had to use Amazon’s (s amzn) EC2. That circumstance-based decision was extremely lucky, Williams said; given the game’s huge growth, without Amazon FarmVille would have failed.

Amazon allowed Williams to “acquire instances at will” using RightScale, which he called “absolutely key.” Zynga uses Apache PHP on the front end, memcached for active user play and MySQL on the back end. It uses memcached to store key value pairs to deal with active user play during sessions and then later writes it to disk.

Was it cost effective to lean on Amazon this hard? “We did spend a lot of money to make that possible,” Williams said, “but we also made up for that in terms of the success of the game and what it did to Zynga as a brand and our success later on.” Post-FarmVille, Zynga has a new model for rolling out game launches.

Now, within less than a day, Zynga can allocate a new game enough EC2 computing capacity to support 10 million daily active users. That pre-built environment should last even the wildest growing game at least five to eight weeks. Each game starts on EC2 and is watched for the next three to six months. If at any time growth goes flat or predictable, the game is transitioned off Amazon and into Zynga’s data centers where it can be optimized to work with those resources.

Williams tries to maintain a 50-50 split between using EC2 and data centers. At any one time, the split could be 30-70 or 70-30, depending on the ratio of new games to predictably growing ones. Williams said he doesn’t want to test Amazon’s capacity and he’d rather not have all his eggs in any one basket, but he values the ability to get big fast.

One of Williams’ next big projects is to help Zynga unify its infrastructure as it diversifies across new platforms including mobile. Right now, Zynga dedicates infrastructure separately for each social network’s instance of any one game. Now, with launches like Monday’s FarmVille for iPhone, there’s an increased emphasis on syncing one user’s experience between everywhere they play a game.

Want to hear more from Williams? Come to Structure in San Francisco, June 23 & 24.