The real story is something different than you would expect. Zuckerberg is not a genius coder but has skills in other areas. Adam D'Angelo - the former CTO of Facebook was pivotal in the creation of the big data website.
Cameron and Tyler Winklevoss and Divya Narendra were the people from whom Zuckerberg stole the idea of thefacebook. They had approached Zuckerberg asking for his assistance in creating a social network for Harvard students called "HarvardConnection" because their programmer got a high-paid job. He entered the project and continued the work of his predecessor but he never finished. Instead, he created based on the code of Harvard connection another project called “TheFacebook”. Following a lawsuit filed against Zuckerberg, eventually, all three received a settlement in 2008 that included 1.2 million shares in the company each. Facebook proved extremely popular with Harvard students when it was first launched, so much so that the site was soon also made available to students at Stanford, Yale and Columbia before expanding to numerous other colleges and then to the entire world.
Initially, it was built upon LAMP - Linux as an Operating system, Apache-server, Database-MySql, and PHP- server-side scripting language. But as the days passed, it has become huge. It uses HipHop Compiler (HHVM) that converts PHP to C++. For its chat service, Facebook initially used Erlang (The language which is used in the majority of messenger apps, such as WhatsApp). It has since switched over to C++. To cater and to store its enormous volume of photos and videos uses HayStack and Scribe for logging. Cassandra is a distributed storage system with no single point of failure used for its index search. And to analyze its data from its users, it uses technologies such as Hadoop and Hive. (non SQL) To make sure all these components, written in a diverse variety of languages and frameworks, work together seamlessly, it uses Thrift (developed internally) BigPipe their custom technology to accelerate page rendering using a pipelining logic. (each web page in sections -called “pagelets” for optimal performance.) Varnish Cache (HTTP accelerator) is used for HTTP proxying. They've preferred it for its high performance and efficiency. For Facebook Messages, they use their own architecture which is notably based on infrastructure dynamic cluster management. Business logic and persistence are encapsulated in the so-called 'Cell'. Each Cell handles a part of the users; new Cells can be added as popularity grows. Persistence is achieved using HBase.
Facebook is estimated to own more than 60,000 servers and a recent data center in Prineville, Oregon is based on entirely self-designed hardware. Their Hadoop and Hive cluster is made of 3000 servers with 8 cores, 32 GB RAM, and 12 TB disks which is a total of 24k cores, 96 TB RAM, and 36 PB disks. 300 TB of data is stored in Memcached processes. ( It’s a distributed memory caching system which use as a caching layer between the web servers and MySQL servers - since database access is relatively slow)
Additionally, here’s a list of other software products that Facebook is using internally:
Marketing: eMarketer, Factual, Mailgun, Owler
Sales and Support: BuiltWith, Congra, GetFeedback, Salesforce Sales Cloud
Product and Design: Blososm, Cage, Google Fonts, Sketch
Analytics: DialogTech, Google Analytics, MicroStrategy, StatCounter
HR: AngelList Jobs, Connectifier, CrowdFlower, Hired
Finance and Accounting: Bango, Fortumo, SpringCM
Productivity: Boardvantage, Do, Google Drive, Throttle
According to: Quora