Top Banner
PHP at Yahoo! Federico Feroldi Senior Architect Engineer Yahoo! Europe
40

Federico Feroldi: PHP in Yahoo!

Jan 14, 2015

Download

Technology

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Federico Feroldi: PHP in Yahoo!

PHP at Yahoo!

Federico Feroldi

Senior Architect Engineer

Yahoo! Europe

Page 2: Federico Feroldi: PHP in Yahoo!

This presentation

Yahoo! numbers and values

Yahoo! and PHP: a brief history

PHP at Yahoo! today

Final notes, QA

Page 3: Federico Feroldi: PHP in Yahoo!

Yahoo! Some numbers

Page 4: Federico Feroldi: PHP in Yahoo!

Some numbers about Yahoo!

20Countries & Languages

Page 5: Federico Feroldi: PHP in Yahoo!

Some numbers about Yahoo!

500MUnique visitors per month

238MActive registered users

source comScore March 2007

Page 6: Federico Feroldi: PHP in Yahoo!

Some numbers about Yahoo!

3,5BAverage daily pageviews

source comScore March 2007

Page 7: Federico Feroldi: PHP in Yahoo!

Our Mission

Page 8: Federico Feroldi: PHP in Yahoo!

Our Mission

To connect people to their passions, their communities, and the world’s knowledge

Page 9: Federico Feroldi: PHP in Yahoo!

Our values as a Engineers

Security and Privacy

High Availability

Performance

Flexibility and Innovation

Page 10: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP

A brief history…

Page 11: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP: a brief history

We started in 1994 withcustom C/C++ software

Because at the time, free technologieswere considered too “immature” torun large, complex destinations.

Page 12: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP: a brief history

Then we moved to theOpen Source software

The growth of the Open Sourcemovement has spurred a change inthinking because languages like PHPaid performance and integration.

Page 13: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP: a brief history

Circa 1996

The Filo* Web Server was replaced bythe Apache web server

* David Filo, one of the Yahoo! founders, coded this simple, programmable, high performance web server that powered the first Yahoo! web site.

Page 14: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP: a brief history

Circa 1999

We replaced custom flat binary files with the Open Source MySQL database

Page 15: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP: a brief history

Circa 2001

We needed to replace our custom scripting languages with a modern language designed for the Web.

Custom scripting languages became a “pain in the neck tomaintain and use” and was difficult to integrate them withthird-party software.

Page 16: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP: a brief history

What we needed

High PerformanceRobust, sand boxed environmentModern language featuresC/C++ extensionsRuns on FreeBSDInternationalization supportLow training costs

Page 17: Federico Feroldi: PHP in Yahoo!

Yahoo! and PHP: a brief history

Why we picked PHP

Designed for Web scriptingHigh PerformanceLarge Open Source CommunityCode-in-HTML paradigmIntegration, libraries, extensibilityTools: IDE, debugger, profiler

Page 18: Federico Feroldi: PHP in Yahoo!

PHP at Yahoo! today

Page 19: Federico Feroldi: PHP in Yahoo!

PHP at Yahoo! today

Development Methodology

Server ArchitectureApplication LayoutDependency ManagementSecurityPerformanceGlobalizationOpen Source Frameworks

Page 20: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Server Architecture

Users

Load Balancers

Apache

PHPAPC, PEAR, PECL, Custom Extensions

Custom ApacheExtensions

FreeBSD 4.x/6.x, Linux 2.6.x

MySQL Web Services Ad API User API

Page 21: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Application Layout

HTML Templates/usr/local/share/htdocs/*.php

Template Helpers/usr/local/share/htdocs/*.inc

Business Logic/usr/local/share/pear/*.inc

Data Access, Networking, CryptoC/C++ core code

HTML PHP

Page 22: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Dependency Management

Light base PHP package

Basic PHP install includes only XML parser.All extensions disabled by default:

./configure --disable-all

+ Avoids unnecessary dependencies+ Smaller Apache memory footprint

Page 23: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Dependency Management

Self contained extension packages

Extensions can be installed separately with the package management tool.

Required dependencies are included in the installation process.

Page 24: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Security

php.ini settings

Always set open_basedirInsurance against /etc/passwd exploits.

Set allow_url_fopen = OffUse libcurl instead, avoid open proxy exploits.

Set display_errors = OffHowever, set log_errors = On

Page 25: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Security

Input Filtering

XSS and SQL Inj. most common attacksNever trust the data coming from the browser.

Use input_filter hookSanitize all user-submitted data on each request.

Use PECL filter packageDerived from our filtering library.

Page 26: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Performance

Opcode Caches

Easiest performance boostCache parsed PHP scripts in shared memory.Runtime optimizations without code modifications.

Several products availableAPC*Zend Performance SuiteTurck MMCache

* that’s what we use

Page 27: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Performance

Custom PHP Extensions in C/C++

Yahoo! Develops its own extensionsFast and optimized execution speed.Access to custom client libraries.

but

Longer development (edit, compile, link, debug)Manual memory management (and related issues)

Page 28: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Performance

Applications architecture

Avoid PHP sessions (they’re slow)Use cookies to store the user data thatyou most often need (like userid, profiletimestamp, etc…) in an encrypted andsigned format.

Page 29: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Globalization

Unicode

Yahoo! contributed to PHP Unicode ext.Andrei Zmievski (Yahoo!), Andi Gutmans (Zend)and many members of PHP community.

Page 30: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: Globalization

I18N support

Generate per intl PHP templates (r3 TMT)Yahoo! has donated to the Open Source hishomegrown Template Management Tool (r3 TMT).r3 allows developers of web applications tocustomize and translate their UI for differentlanguages, markets and uses.

http://sourceforge.net/projects/rthree

Page 31: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: PHP Frameworks

Smarty

Not widely used at Yahoo!.

Written in user-space PHP.

Caching lowers but does not eliminate the run-time overhead on each request.

With Yahoo!'s level of traffic, this overhead can be considerable.

Page 32: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: PHP Frameworks

Symfony

We began to use Symfony! (recently)

Good for integrated development, testing.

Factors out common patterns.

Encourages good design.

Page 33: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: PHP Frameworks

Symfony (what we kept)

Core MVC Architecture

Configuration system

The View Layer

User Security

Page 34: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: PHP Frameworks

Symfony (what we replaced)

Model Layer and ORMDoesn’t scale to our needs

Configuration system (extended)More flexible, I18N support

InternationalizationIntegrated with r3 TMT

Page 35: Federico Feroldi: PHP in Yahoo!

Yahoo! PHP: PHP Frameworks

Drupal

Usage investigations going on.

Excellent application framework.

Not tested yet on Yahoo! production.

Page 36: Federico Feroldi: PHP in Yahoo!

Final notes

Page 37: Federico Feroldi: PHP in Yahoo!

Yahoo! Developer Network

PHP Developer Center

Using PHP with Yahoo! Web Services API

HowTo Articles and Code Samples.

Active community.

http://developer.yahoo.com/php/

Page 38: Federico Feroldi: PHP in Yahoo!

Yahoo! Developer Network

Yahoo! Web Services

Yahoo! Mail APIIntegrate your application with Yahoo! Mail.

Yahoo! Maps APIEasily build advanced map based mashups.

Flickr APIGet access to milion of pictures.

del.icio.us APIThe number one tagging and bookmarking tool.

Page 39: Federico Feroldi: PHP in Yahoo!

Thank you! - Questions?

Yahoo! Developer Network

http://developer.yahoo.com/

Federico [email protected]

Page 40: Federico Feroldi: PHP in Yahoo!