Facebook – Farmville – Architecture


Gaming made easy

Zynga Inc. CEO and founder Marc Pincus 

Zynga is the largest developer of social games on the Web, with such hugely popular titles as FarmVille, FrontierVille, Mafia Wars, Zynga Poker, Café World, Treasure Isle, YoVille, FishVille, and PetVille. Zynga’s “freemium” business model is simple and effective: Although many of its online games can be enjoyed for free, the company sells virtual goods for real money to its massive user base of gamers.

Image1
FarmVille

Staging of Infra

1. Zynga started their journey of in-house infrastructure 
Zynga Architecture

2. The requirement grew ( zero to six million), and they migrated to cloud.

3.And once the platform stabilizes, they know exact requirement, later they move particular application (Ville) to their own private cloud (Z-cloud)  from Amazon EC2 server.

FrontierVille

Architecture

Zynga uses Apache PHP on the front end, MemBase 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.

Zynga uses LAMMP configuration ( Linux,  Apache HTTP server, MemBase Memcache,mySql , PHP).

The basic architecture differences arise between social network sites and gaming sites are reads and writes.  Games uses lot of writes compared to websites like Facebook.

In 2009, Farmville is using the MemCache+ MySQL, now MemBase (from 2011 onwards)  is used in new architcture. This will able to provide optimized read and writes.

Server side :

Webstack(social network):
  • LAMP based webstack
  • Game logic in PHP
  • HTTP communication
CityVille

Mixed stack:(FishVille)

This will have additional “Game Logic” compared to the webstack
  • Game logic in MMO
    • Socket connections
    • Live Game support data
  • Webstack

Client side :

Flash(social network):
This is FarmVille Architecture
  • High production quality games
  • Game logic in client
  • Can open socket
HTML+ AJAX
This is MafiaWars architecture
  • Game is just a webpage
  • Limited graphics and animations
  • Minimal system requirements

Karthik Ayyar’s Zynga engineer on “Quora.com”

A. Client requests content over HTTP.

B. Flash Media Server proxies the request to port 8134. 

C. Apache web server delivers content for progressive download.

D. Client requests content over RTMPT. 

E. Flash Media Server streams content to client.

  • LAMP stack on the backend
  • The server aspects of game simulation are in PHP
  • MemBase/CouchBase
  • MySQL backend, sharded by userid used in an almost purely NoSQL style
  • Memcache layer, again sharded by userid 
  • A CDN used to serve game assets

Additional info: Based on comments from Quora user:

Zynga is moving towards SOA and many of services being exposed to 3rd party developers


References:

Advertisements

2 thoughts on “Facebook – Farmville – Architecture

  1. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what youre talking about, why waste your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s