php performance-talk

46
Sherif Ramadan PHP Performance At Scale

Upload: sherif-ramadan

Post on 16-Jul-2015

175 views

Category:

Engineering


6 download

TRANSCRIPT

Sherif Ramadan

PHP Performance At

Scale

What is performance?A factor of efficiently producing output.

Finite resources must serve infinite needs.

What is scale?A quantitative measure of need.

Dealing with sheer numbers of inputs and outputs.

First, let’s clear up some preconceived notions

about PHP…

Why does PHP have a bad wrap?

“PHP can run really bad code really well” - Rasmus Lerdorf

“1” + 1 == 2

function argument order…!!

array_map(<callback>, <array>) array_filter(<array>, <callback>)

type juggling behavior!!

md5('240610708') == md5('QNKCDZO')

“0e462097431906509019562988736854" "0e830400451993494058024219903391"

Bueller? Bueller? Anyone?Popularity has its price…

We’re going back to 1995!

The First PHPAnnouncing the Personal Home Page Tools (PHP Tools) version 1.0. These tools are a set of small tight cgi binaries written in C. They perform a number of functions including: . Logging accesses to your pages in your own private log files. Real-time viewing of log information. Providing a nice interface to this log information. Displaying last access information right on your pages. Full daily and total access counters. Banning access to users based on their domain. Password protecting pages based on users' domains. Tracking accesses ** based on users' e-mail addresses **. Tracking referring URL's - HTTP_REFERER support. Performing server-side includes without needing server support for it . Ability to not log accesses from certain domains (ie. your own) . Easily create and display forms. Ability to use form information in following documentsHere is what you don't need to use these tools:

. You do not need root access - install in your ~/public_html dir

. You do not need server-side includes enabled in your server

. You do not need access to Perl or Tcl or any other script interpreter

. You do not need access to the httpd log files The only requirement for these tools to work is that you have the ability to execute your own cgi programs. Ask your system administrator if you are not sure what this means. The tools also allow you to implement a guestbook or any otherform that needs to write information and display it to userslater in about 2 minutes.The tools are in the public domain distributed under the GNUPublic License. Yes, that means they are free!

For a complete demonstration of these tools, point your browserat: http://www.io.org/~rasmus --

Rasmus [email protected]://www.io.org/~ras

Why do we care about performance?

We Live In An Information Age

More people; more data;

more time online!

Lots of Data!!!Cisco predicts annual data transfer of a zettabyte by 2016!

Impactful change is fundamentally disruptive…

SELECT * FROM table LIMIT 10; !

Thank PHP!

How do I improve performance?

It depends…

What matters to you?

Factors of Performance

• Economics

• Luxury

• Speed

Economy?

• Goes 0 - 60 (MPH) > 10 Seconds

• Does ~50 MPG

• Costs ~$24K

Luxury?• Goes 0 - 60 (MPH) < 4 Seconds

• Does ~14 MPG

• Costs ~$200K

Speed?

• Goes 0 - 60 (MPH) < 2 Seconds

• Does 3.1 MPG

• Costs ~$2.6 Million

All of The Above?• Goes 0 - 60 (MPH) < 6 Seconds

• Uses ~85KwH (320 Servers)

• Costs ~$79K

Architecture

–Rasmus Lerdorf

“Scaling something up is hard. Scaling something down is even harder. Both are rocket

science.”

PHP ScalePHP scales up as well as it scales down!

Load Balancing

PHP-FPM > mod_php?

Distributing Load Properly

Offloading - Gearman

Offloading - Gearman

Offloading - ZeroMQ

Service Discovery with Zookeeper

APC Cache vs Memcached

Atomic Operations++

Vectors

PHP Arrays

Implementation

Present Day PHP Implementations

• C PHP (Defacto Standard)

• HHVM

• HipHop PHP

• Phalanger

• PHPPHP

PHP 7Zend Engine 3.0

The Future of PHP

PHP-NG

PHP-NG

PHP-NG

Sherif Ramadan@sr_googleguy

sheriframadan.com

Thank You! !

Q&A