Friendster Architecture
Wednesday, July 11, 2007 at 3:18PM
Todd Hoff in Example, Linux, MySQL, PHP, Perl

Friendster is one of the largest social network sites on the web. it emphasizes genuine friendships and the discovery of new people through friends.


Information Sources

  • Friendster - Scaling for 1 Billion Queries per day


  • MySQL
  • Perl
  • PHP
  • Linux
  • Apache

    What's Inside?

  • Dual x86-64 AMD Opterons with 8 GB of RAM
  • Faster disk (SAN)
  • Optimized indexes
  • Traditional 3-tier architecture with hardware load balancer in front of the databases
  • Clusters based on types: ad, app, photo, monitoring, DNS, gallery search DB, profile DB, user infor DB, IM status cache, message DB, testimonial DB, friend DB, graph servers, gallery search, object cache.

    Lessons Learned

  • No persistent database connections.
  • Removed all sorts.
  • Optimized indexes
  • Don’t go after the biggest problems first
  • Optimize without downtime
  • Split load
  • Moved sorting query types into the application and added LIMITS.
  • Reduced ranges
  • Range on primary key
  • Benchmark -> Make Change -> Benchmark -> Make Change (Cycle of Improvement)
  • Stabilize: always have a plan to rollback
  • Work with a team
  • Assess: Define the issues
  • A key design goal for the new system was to move away from maintaining session state toward a stateless architecture that would clean up after each request
  • Rather than buy big, centralized boxes, [our philosophy] was about buying a lot of thin, cheap boxes. If one fails, you roll over to another box.
  • Article originally appeared on (
    See website for complete article licensing information.