Max Mednik
  • Home
  • About
  • Interests
    • Angel investing
    • Magic
    • Scuba Diving
  • Blog
  • Contact

Readings and musings

Notes on The State of PHP in 2011

8/1/2011

2 Comments

 
Picture
I recently was lucky enough to attend a sold-out, uber-geek event featuring the creator of PHP, the programming language powering a couple small websites out there, including some you may have heard of, like Yahoo and Facebook.

The talk was put on by LAPHP, and the speaker was Rasmus Lerdorf. The topic was "PHP in 2011," and it discussed how PHP fits into the current technology stack, followed by an overview of what you should and shouldn't be doing, along with a summary of new and upcoming features in PHP 5.3 and PHP 5.4.

Rasmus Lerdorf is known for having gotten the PHP project off the ground in 1995 and has contributed to a number of other open source projects over the years. He spent 7 years at Yahoo and has since worked for and consulted with various startups. He was born in Greenland, grew up in Denmark and Canada, and has a Systems Design engineering degree from the University of Waterloo. 

The full "slides" for Rasmus's talk are here.

From the moment I found out that PHP is a recursive acronym (standing for "PHP: Hypertext Processor"), I found the language cute. While I personally feel the syntax leaves much to be desired in terms of prettiness, the language clearly gets the job done.


Below are my main observations and notes on the talk.

Rasmus Background
  • Rasmus seemed like a very approachable and down-to-earth guy. Definitely doesn't flaunt nerd celebrity status.
  • Not traditional hacker background
  • He doesn't even have CS degree.
  • Likes solving problems, not writing code
  • Hated repeating code
  • Wrote PHP to program less and enjoy his weekends
  • Wrote language to be functional and easy to grasp
  • Web programming was never sexy for good programmers
  • Thus, non-technical people had to build the web.
  • Made it very easy to just add PHP tags to existing web pages and make them dynamic.
  • Wrote documentation before wrote code
  • PHP written in C
  • Was always speed freak; hated slow calls to perl interpreter
  • Wanted to embrace architecture of web: store nothing/stateless approach

PHP Background
  • Mosaic first graphical web browser came out; start of real web
  • 1993: Started with basic templating system using HTML comment tags
  • Used yacc and lex to write PHP v2
  • 1995: Introduced <? tag (process instruction from SGML)
  • Others said should label his tag (forgot to read that part of SGML) so now <?php. He likes to read only as much to feel like he understands and then moves on (sometimes not the best practice).
  • 2003: added classes/OO
  • PHP has 1/3 of web market share
  • Only .NET close to PHP in market share
  • Yahoo switched all to PHP in 2002 across thousands of servers; stateless design allowed parallelization
  • FB using PHP
  • PHP did not allow you to modify web server like mod_perl so could be shared on ISPs (important for adoption)
  • Limiting CPU time, file system access were other strategic features for ISP growth
  • Added 5 second Atom parser to print XML content in 1 line
  • Geocoded Twitter search example
  • Worked at Yahoo for 7 years
  • Created YQL: Yahoo Query Language: like SQL selects from various web APIs
  • Geocoded Flickr photos example
  • New CSS: shadows, rotation of divs, rounded corners example

On his mind for 2011
  • PHP 5.4
  • Continuous integration
  • Node.JS and PHP
  • Libevent
  • ZeroQM: message queuing
  • Gearman worker management in PHP-FPM: offloading jobs to other processes to run in background
  • Getting a "real" job :)
  • Rewriting 10 year old presentation system
  • He also helps startups get going well on PHP
Technologies serving tech (what he sees in the field)
  • MongoDB, MySQL, Couchdb
  • Redis, Gearman, Memcache, ZeroMQ
  • Mod_PHP APC, PHP-FPM APC 
  • Apache, nginx
  • Linux
  • Recommends nginx and PHP-FPM
  • Sees a lot out there: nginx for load balancing frontend, Apache for web server
Performance
  • Doesn't matter which web server you choose
  • Latency and throughput both roughly stable
  • Other stuff you do in generating dynamic data much more important
  • Set error reporting to -1
  • Use strace, look for ENOENT (should never happen)
  • Look at stat cache to see if fills up
  • Use a profiler, callgrind, xdebug
  • Use "Inclued" tool to see a picture of include files
  • Use Hiphop-PHP to do static analysis (Facebook's compiler for PHP to compile to c++ through g++). Can tell Hiphop just to analyze through --analyze flag to find undeclared variables and dead code.

Recommendations
  • Put static assets on different domain/subdomain for CDN
  • Keep cookies short and remember MTU size (max transmission unit for 1420-1500 bytes on TCP) for mobile. Includes all headers, so after headers maybe 600 bytes left.
  • Don't overload web servers; don't set max serving to 200 (he never goes above 50-60 servers running no matter how beefy of machines; better to just add another machine)
  • Use out of band processing: Gearman or custom via ZeroMQ (he prefers Gearman)
  • Don't move relational data out of relational database
  • Do move huge non-relational tables out of relational DB
  • Be very careful about foreign keys. Avoid if possible. Can create deadlocks easily.
  • Think hard about ORM, caching strategy
  • Get on PHP 5.3
  • Tie cookies to www domain
  • Use other domain for all static content (helps w/ CDN)
PHP 5.3 features
  • Better stack
  • Constants in read-only memory
  • Better exception handling
  • Performance improvements
  • MD5 faster
  • 5-15% overall faster
  • Added closures, namespaces, late static binding, garbage collector, nowdoc, restricted goto, ternary shortcut, __dir__, __callstatic, dynamic static calls, improved date extension, date create from format, better date error reporting, spl, FPM, OpenSSL improvements
  • His secret: he likes to turn off the garbage collector because he's 1337 and still programs in vi
PHP 5.4 performance improvements
  • FastCGI request handling, better memory handling, startup/shutdown, repeated run-time function binding, string constants, access to global constants, access to static properties, empty hashes, @ operator, unserialize(), removed features, traits, short array syntax, function array dereferencing, binary notation, improved errors, json improvements
2 Comments
Danilo Stern-Sapad link
8/6/2011 07:21:03 am

With notes like this why did I even bother going? =P

Reply
Max
8/6/2011 08:30:13 am

Thx :)

I honestly went just to see what kind of dude Rasmus was. It was fun to see.

Reply

Your comment will be posted after it is approved.


Leave a Reply.

    Archives

    June 2021
    May 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    April 2020
    January 2020
    December 2019
    November 2019
    October 2019
    September 2019
    August 2019
    July 2019
    May 2019
    March 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    February 2018
    January 2018
    November 2017
    October 2017
    September 2017
    May 2017
    April 2017
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014
    May 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    February 2013
    January 2013
    December 2012
    November 2012
    October 2012
    September 2012
    August 2012
    July 2012
    June 2012
    May 2012
    April 2012
    March 2012
    February 2012
    January 2012
    December 2011
    November 2011
    October 2011
    September 2011
    August 2011
    July 2011
    June 2011
    May 2011
    April 2011
    March 2011
    February 2011
    January 2011
    December 2010
    November 2010
    October 2010
    September 2010
    August 2010
    July 2010
    June 2010
    May 2010
    April 2010
    March 2010
    February 2010

    Categories

    All
    Angel Investing
    Cacti
    Cars
    China
    Community Service
    Culture
    Design
    Djing
    Dogs
    Education
    Entertainment
    Entrepreneurship
    Family
    Finance
    Food
    Google
    Happiness
    Incentives
    Investment Banking
    Judaism
    Law
    Lighting
    Magic
    Marketing
    Medicine
    Networking
    Nolabound
    Philosophy
    Professionalism
    Psychology
    Reading
    Real Estate
    Religion
    Romance
    Sales
    Science
    Shangri-La
    Social Entrepreneurship
    Social Media
    Sports
    Teams
    Technology
    Travel
    Turtles
    Ucla
    Venture Capital
    Web Services
    Weddings
    Zen

    Subscribe

    RSS Feed

Picture
Picture
  • Home
  • About
  • Interests
    • Angel investing
    • Magic
    • Scuba Diving
  • Blog
  • Contact