SlideShare a Scribd company logo
SCALING
WITH SYMFONY

+

=

PHP UK CONFERENCE 2014
HELLO PHPUK!
•

Ricard Clau, born and grown up in Barcelona, Spain

•

Software engineer at Hailo London

•

Symfony2 lover and PHP believer

•

Open-source contributor, sometimes I give talks

•

Twitter @ricardclau / Gmail ricard.clau@gmail.com
WHY THIS TALK?
•

Lots of PHP haters these days. I just don´t get it.

•

Some misconceptions about full-stack PHP frameworks

•

PHP is absolutely fine for most of your applications

•

But at some point you may need to replace some bits

•

DragonCity - Social game - 7.5M DAU - Symfony
AGENDA
•

Performance and scalability

•

Profiling and optimization

•

Storage: SQL vs NoSQL

•

Symfony2 is fast enough! Seriously!

•

Some war stories!

•

Almost everything applies to all PHP projects
Millions of
Users
Worldwide
24x7x365

CONCEPTS
Scalability, Availability, Load Balancing, Sharding
SCALABILITY
Which model would you choose?
AVAILABLE 24X7X365
We need to recover fast from any failure
LOAD BALANCING
It allows you to make changes without stopping your app
SHARDING
Luckily, you will get to a point when you need to do it...
And it can hurt if you have never considered it!
DON´T IF NOT NEEDED
•

Avoid premature optimizations

•

Microoptimizations are completely useless

•

Focus on impacting things

•

Incremental improvements

•

If the business is not working, it will be useless
BUT ACTIVELY PREVENT RISKS
•

Monitor servers: Ram, CPUs, Disk, network, idle
processes...

•

Try to engage stakeholders

•

When something surpasses half capacity, start
creating a B plan

•

Death of success is terrible
HANDS ON!
Where do we start from?
LOVE YOUR FRONTEND
Reduce # of requests and their size
SOME QUICK ADVICES
•

Fastest request -> No actual request

•

Icons in base64 inside your CSS

•

Minify CSS and JS, image size (jpegoptim, pngcrush, ...)

•

Use HTTP headers to cache at several layers

•

Network latency matters a lot

•

User experience takes benefit from all of these
SCALING PHP
Facebook, Wikipedia, Yahoo, Wordpress, Etsy, Zynga, YouPorn, Hailo,
Softonic, Emagister, Privalia, SocialPoint, Tuenti, ...
IS SCALING ACTUALLY EASY?
•

PHP bootstraps on every Request, so scaling is as “easy” as adding machines
behind a Load Balancer

•

But it makes it much slower than many other languages

•

Some things are shared among requests (sessions, storage, ...) but frameworks like
Symfony make it easier

•

PHP has been proof-tested in several BIG projects

•

Most of the times, problems are caused by the DB
LOOK BEYOND LAMP
•

Light-weight HTTP servers / CDNs for assets

•

Introduce reverse proxy cache like Varnish to cache pages (or ESI blocks)

•

Cache all the things (APC, Memcached, Redis, ...). 10 seconds cache -> Only 6
hits per minute!

•

RDBMS can deal with A LOT of data. But some problems are much better
solved with NoSQL databases

•

Sometimes other languages are more suitable for our problem
PHP PERFORMANCE
Opcode caches, composer, HHVM, quick wins
Upgrading from PHP5.3 will boost ~20-40%
APC: OUR OLD BESTIE
•

If you have ever worried about performance... you know it!

•

apc.stat -> Off (Apache reload to see changes)

•

apc.serializer -> igbinary (compact_strings -> Off)

•

apc.shm_size -> Check if 32Mb is enough

•

apc.write_lock -> Avoids cold cache issues

•

Check http://www.php.net/manual/en/apc.configuration.php
APC STATUS
http://svn.php.net/viewvc/pecl/apc/trunk/apc.php?view=markup
ZEND OPCACHE
•

Included in PHP5.5 standard distribution (valid with 5.2) will avoid weird
random issues like PHP5.4+APC

•

Better performance than APC in all tests

•

README https://github.com/zendtech/ZendOptimizerPlus

•

APC Userland Cache + Upload Hooks now live in APCU
(https://github.com/krakjoe/apcu)

•

Lots of companies are already using it!
OPCACHE STATUS
1 full-stack file, Rasmus style :)
(https://github.com/rlerdorf/opcache-status)
COMPOSER AUTOLOAD
•

You all already use Composer, right?

•

Default PSR-0 implementation is slow because we access
the FileSystem a lot

•

composer.phar install --optimize-autoloader (-o)
generates ClassMap

•

Same performance apc.stat = Off than
ApcUniversalClassLoader and less keys stored in APC
APC VS ZEND OPCACHE

http://www.ricardclau.com/2013/03/apc-vs-zend-optimizer-benchmarks-withsymfony2/
APC VS ZEND OPCACHE

http://www.ricardclau.com/2013/03/apc-vs-zend-optimizer-benchmarks-withsymfony2/
HHVM: THE FUTURE ENGINE?
•

Impressive progress in HHVM these past months

•

Most frameworks and libraries ~100% compatibility

•

Fewer memory, interesting speed improvements

•

We might finally have a language specification for PHP!

•

Specific HHVM features? -> Dangerous!

•

It will still not be comparable to compiled languages
FINE TUNING SYMFONY2
•

Disable unused bundles

•

SwiftMailer is quite slow, delegate to queue processes

•

If you can, use SubRequests with ESI and Varnish

•

Also check Twig C extension

•

You can implement a Cache Warmer for special needs

•

If using Apache, try app/console router:dump-apache
PROFILING
Diagnosing bottlenecks
PROFILING TOOLS
•

How often do you profile your code?

•

xDebug (Derick Rethans) and XHProf (Facebook)

•

Very convenient to install them in live servers and
activate to grab real data

•

Many things can also be discovered locally

•

Some tragedies only happen with live traffic
XHPROF (DEV VS PROD)
https://github.com/jonaswouters/XhprofBundle
HELLO WORLD
PHP and its frameworks...
Benchmarks comparing completely different things...
¿FRAMEWORKS == SLOW?
•

Some people think that writing their own
framework from scratch is a good idea

•

Also, that big frameworks use a lot of memory. (ZF1
and Symfony2 work with memory_limit 32M)

•

If this is your problem, PHP is not the solution

•

Don´t trust Hello World Performance Tests!

•

Nobody is better than a big community
TECHEMPOWER BENCHMARK
•

Symfony2 appears at the bottom

•

Comparison with light-weight frameworks is unfair.
Some incoherences (frameworks PHP >> PHP)

•

PHP will never be faster than a compiled language

•

In real apps, caching and DB optimizations equal things

•

Symfony2 roadmap improving performance
STORAGE
Use the right tool for the job. Silver bullets do not exist
RELATIONAL DBS
•

Mature technologies, good performance

•

Transactions: Atomicity, Consistency, Isolation, Durability

•

Foreign Keys, Joins, complex reporting queries

•

Millions of records without issues

•

We can use a NOSQLs key-value approach using
BLOB fields with serialized objects
NOSQL SOLUTIONS
•

Solutions to some concrete problems

•

CAP theorem (Consistency, Availability, Partition tolerance).
You can only get 2 of them... theoretically

•

Inmaturity in some of them. Complex to scale.

•

¿Big Data? 100M of records is NOT BIG DATA.

•

Redis, Cassandra, Riak and Solr work really well
QUEUE SYSTEMS
Read the docs, they are all completely different!
REAL-TIME DATA?
•

Try to delegate as much as possible to batch processes

•

Sending mails, external API requests, image
resizing, non-critical stats, ...

•

99% of stats don´t need to be real-time

•

60 seconds delay is mostly real-time!

•

Batch processes can be coded in different languages!
PHP NEEDS FRIENDS
Sometimes it is just not the best tool for our needs
PHP BAD SCENARIOS
•

24x7 running CLI daemon apps

•

Heavy math calculations, massive data processing,
programming contests

•

High concurrency apps with non-cachable requests

•

Threading, Forking, concurrent programming...

•

Writing DSLs
LOOK BEYOND PHP
•

JavaScript will be the king in the client side

•

In the server, Erlang and Go are growing adopters. And time will say about
Node.JS

•

Compiled languages like Go, C, C++ or Java will always be used in our stack.

•

JVM languages like Scala and Clojure are sexy now!

•

Learning other languages makes you a better engineer!
SYMFONY2
It is fast enough for most of what you want to do
WHY SYMFONY2?
•

Symfony2 is NOT the fastest “Hello world” framework...
but it is fast enough for most APIs and web applications

•

Big-community frameworks allow you to test any
technology in less than 5 minutes

•

A custom framework has usually higher costs and risks

•

LTS releases roadmap, stability, big projects are using it

•

Mature community, # of bundles
SOCIAL VIDEOGAME
https://apps.facebook.com/dragoncity/
(~7.5M DAU Facebook, iOS & Android Game)
DRAGONCITY: NUMBERS
•

~7.5 million daily users

•

~300 millions of registered users

•

Hundreds of millions of records for analytics generated daily

•

MySQL (32x2 + Analytics), Redis (~30), Cassandra (3)

•

HTTP requests are your progress -> No cacheable

•

Yes, most of the code is Symfony2! :)
POWERED BY SYMFONY2
@adanlobato showing happiness and pride!
6 DIGITS IN ANALYTICS
Yeah, still Symfony2! o/
WRAP-UP
•

PHP and Symfony2 work for most projects

•

Clever caching strategy is helpful

•

Profiling can make performance improve

•

The storage is almost always the bottleneck

•

Proper architecture design is crucial

•

PHP is not the best solution to some problems
QUESTIONS?
•

Twitter: @ricardclau

•

E-mail: ricard.clau@gmail.com

•

Github: https://github.com/ricardclau

•

Blog about PHP and Symfony2: http://www.ricardclau.com

•

Please, rate this talk at https://joind.in/talk/view/10697
Ad

More Related Content

What's hot (19)

Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
kscaldef
 
Real-world Experiences in Scala
Real-world Experiences in ScalaReal-world Experiences in Scala
Real-world Experiences in Scala
Amir Karimi
 
What we talk about when we talk about DevOps
What we talk about when we talk about DevOpsWhat we talk about when we talk about DevOps
What we talk about when we talk about DevOps
Ricard Clau
 
Perl-Critic
Perl-CriticPerl-Critic
Perl-Critic
Jonas Brømsø
 
Beyond Apache: Faster Web Servers
Beyond Apache: Faster Web ServersBeyond Apache: Faster Web Servers
Beyond Apache: Faster Web Servers
webhostingguy
 
The Wix Microservice Stack
The Wix Microservice StackThe Wix Microservice Stack
The Wix Microservice Stack
Tomer Gabel
 
Streaming 101: Hello World
Streaming 101:  Hello WorldStreaming 101:  Hello World
Streaming 101: Hello World
Josh Fischer
 
MariaDB - The Future of MySQL?
MariaDB - The Future of MySQL?MariaDB - The Future of MySQL?
MariaDB - The Future of MySQL?
Bokowsky + Laymann GmbH
 
Apcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go languageApcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go language
Derek Collison
 
Travel with your mock server
Travel with your mock serverTravel with your mock server
Travel with your mock server
Jorge Ortiz
 
Compression talk
Compression talkCompression talk
Compression talk
Ilya Ganelin
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Tim Bunce
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
Ruby in office time reboot
Ruby in office time rebootRuby in office time reboot
Ruby in office time reboot
Kentaro Goto
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2
Antonio Peric-Mazar
 
Gophers Riding Elephants: Writing PostgreSQL tools in Go
Gophers Riding Elephants: Writing PostgreSQL tools in GoGophers Riding Elephants: Writing PostgreSQL tools in Go
Gophers Riding Elephants: Writing PostgreSQL tools in Go
AJ Bahnken
 
Mini-Training: Redis
Mini-Training: RedisMini-Training: Redis
Mini-Training: Redis
Betclic Everest Group Tech Team
 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
Tomer Gabel
 
Ansible Best Practices - July 30
Ansible Best Practices - July 30Ansible Best Practices - July 30
Ansible Best Practices - July 30
tylerturk
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
kscaldef
 
Real-world Experiences in Scala
Real-world Experiences in ScalaReal-world Experiences in Scala
Real-world Experiences in Scala
Amir Karimi
 
What we talk about when we talk about DevOps
What we talk about when we talk about DevOpsWhat we talk about when we talk about DevOps
What we talk about when we talk about DevOps
Ricard Clau
 
Beyond Apache: Faster Web Servers
Beyond Apache: Faster Web ServersBeyond Apache: Faster Web Servers
Beyond Apache: Faster Web Servers
webhostingguy
 
The Wix Microservice Stack
The Wix Microservice StackThe Wix Microservice Stack
The Wix Microservice Stack
Tomer Gabel
 
Streaming 101: Hello World
Streaming 101:  Hello WorldStreaming 101:  Hello World
Streaming 101: Hello World
Josh Fischer
 
Apcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go languageApcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go language
Derek Collison
 
Travel with your mock server
Travel with your mock serverTravel with your mock server
Travel with your mock server
Jorge Ortiz
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Tim Bunce
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
Ruby in office time reboot
Ruby in office time rebootRuby in office time reboot
Ruby in office time reboot
Kentaro Goto
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2
Antonio Peric-Mazar
 
Gophers Riding Elephants: Writing PostgreSQL tools in Go
Gophers Riding Elephants: Writing PostgreSQL tools in GoGophers Riding Elephants: Writing PostgreSQL tools in Go
Gophers Riding Elephants: Writing PostgreSQL tools in Go
AJ Bahnken
 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
Tomer Gabel
 
Ansible Best Practices - July 30
Ansible Best Practices - July 30Ansible Best Practices - July 30
Ansible Best Practices - July 30
tylerturk
 

Viewers also liked (17)

Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Ville Mattila
 
MidwestPHP Symfony2 Internals
MidwestPHP Symfony2 InternalsMidwestPHP Symfony2 Internals
MidwestPHP Symfony2 Internals
Raul Fraile
 
Starting with Symfony2
Starting with Symfony2Starting with Symfony2
Starting with Symfony2
Kevin Bond
 
Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)
Matthias Noback
 
A Practical Introduction to Symfony2
A Practical Introduction to Symfony2A Practical Introduction to Symfony2
A Practical Introduction to Symfony2
Kris Wallsmith
 
Interoperability and Portability for Cloud Computing: A Guide
Interoperability and Portability for Cloud Computing: A GuideInteroperability and Portability for Cloud Computing: A Guide
Interoperability and Portability for Cloud Computing: A Guide
Cloud Standards Customer Council
 
Rationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringRationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoring
Giulio De Donato
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
Karwin Software Solutions LLC
 
Symfony in microservice architecture
Symfony in microservice architectureSymfony in microservice architecture
Symfony in microservice architecture
Daniele D'Angeli
 
Effective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 DevelopersEffective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 Developers
Marcin Chwedziak
 
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Innomatic Platform
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Ryan Weaver
 
Symfony2 and AngularJS
Symfony2 and AngularJSSymfony2 and AngularJS
Symfony2 and AngularJS
Antonio Peric-Mazar
 
Code Review
Code ReviewCode Review
Code Review
Frank Sons
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
Jonas Bonér
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDB
Pablo Godel
 
Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2
Pablo Godel
 
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Ville Mattila
 
MidwestPHP Symfony2 Internals
MidwestPHP Symfony2 InternalsMidwestPHP Symfony2 Internals
MidwestPHP Symfony2 Internals
Raul Fraile
 
Starting with Symfony2
Starting with Symfony2Starting with Symfony2
Starting with Symfony2
Kevin Bond
 
Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)
Matthias Noback
 
A Practical Introduction to Symfony2
A Practical Introduction to Symfony2A Practical Introduction to Symfony2
A Practical Introduction to Symfony2
Kris Wallsmith
 
Interoperability and Portability for Cloud Computing: A Guide
Interoperability and Portability for Cloud Computing: A GuideInteroperability and Portability for Cloud Computing: A Guide
Interoperability and Portability for Cloud Computing: A Guide
Cloud Standards Customer Council
 
Rationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringRationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoring
Giulio De Donato
 
Symfony in microservice architecture
Symfony in microservice architectureSymfony in microservice architecture
Symfony in microservice architecture
Daniele D'Angeli
 
Effective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 DevelopersEffective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 Developers
Marcin Chwedziak
 
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Innomatic Platform
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Ryan Weaver
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
Jonas Bonér
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDB
Pablo Godel
 
Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2
Pablo Godel
 
Ad

Similar to Scaling with Symfony - PHP UK (20)

Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
isnull
 
Be faster then rabbits
Be faster then rabbitsBe faster then rabbits
Be faster then rabbits
Vladislav Bauer
 
The JavaScript Delusion
The JavaScript DelusionThe JavaScript Delusion
The JavaScript Delusion
JUGBD
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
netzwelt12345
 
Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019
graemerocher
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
Alex Tumanoff
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
Igor Anishchenko
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHP
John Coggeshall
 
Putting Compilers to Work
Putting Compilers to WorkPutting Compilers to Work
Putting Compilers to Work
SingleStore
 
Introduction To Web Development & The New Digital Workplace
Introduction To Web Development & The New Digital WorkplaceIntroduction To Web Development & The New Digital Workplace
Introduction To Web Development & The New Digital Workplace
Jen Wei Lee
 
What's the "right" PHP Framework?
What's the "right" PHP Framework?What's the "right" PHP Framework?
What's the "right" PHP Framework?
Barry Jones
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
Jonathan Klein
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matter
Mizno Kruge
 
Realtime web2012
Realtime web2012Realtime web2012
Realtime web2012
Timothy Fitz
 
Lessons learned from building Eclipse-based add-ons for commercial modeling t...
Lessons learned from building Eclipse-based add-ons for commercial modeling t...Lessons learned from building Eclipse-based add-ons for commercial modeling t...
Lessons learned from building Eclipse-based add-ons for commercial modeling t...
IncQuery Labs
 
Stackato
StackatoStackato
Stackato
Jonas Brømsø
 
From vagrant to production - Mark Eijsermans
From vagrant to production - Mark EijsermansFrom vagrant to production - Mark Eijsermans
From vagrant to production - Mark Eijsermans
Devopsdays
 
Content Management Systems and Refactoring - Drupal, WordPress and eZ Publish
Content Management Systems and Refactoring - Drupal, WordPress and eZ PublishContent Management Systems and Refactoring - Drupal, WordPress and eZ Publish
Content Management Systems and Refactoring - Drupal, WordPress and eZ Publish
Jani Tarvainen
 
Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL
Konstantin Gredeskoul
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
isnull
 
The JavaScript Delusion
The JavaScript DelusionThe JavaScript Delusion
The JavaScript Delusion
JUGBD
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
netzwelt12345
 
Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019
graemerocher
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
Alex Tumanoff
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
Igor Anishchenko
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHP
John Coggeshall
 
Putting Compilers to Work
Putting Compilers to WorkPutting Compilers to Work
Putting Compilers to Work
SingleStore
 
Introduction To Web Development & The New Digital Workplace
Introduction To Web Development & The New Digital WorkplaceIntroduction To Web Development & The New Digital Workplace
Introduction To Web Development & The New Digital Workplace
Jen Wei Lee
 
What's the "right" PHP Framework?
What's the "right" PHP Framework?What's the "right" PHP Framework?
What's the "right" PHP Framework?
Barry Jones
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
Jonathan Klein
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matter
Mizno Kruge
 
Lessons learned from building Eclipse-based add-ons for commercial modeling t...
Lessons learned from building Eclipse-based add-ons for commercial modeling t...Lessons learned from building Eclipse-based add-ons for commercial modeling t...
Lessons learned from building Eclipse-based add-ons for commercial modeling t...
IncQuery Labs
 
From vagrant to production - Mark Eijsermans
From vagrant to production - Mark EijsermansFrom vagrant to production - Mark Eijsermans
From vagrant to production - Mark Eijsermans
Devopsdays
 
Content Management Systems and Refactoring - Drupal, WordPress and eZ Publish
Content Management Systems and Refactoring - Drupal, WordPress and eZ PublishContent Management Systems and Refactoring - Drupal, WordPress and eZ Publish
Content Management Systems and Refactoring - Drupal, WordPress and eZ Publish
Jani Tarvainen
 
Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL
Konstantin Gredeskoul
 
Ad

More from Ricard Clau (10)

Essential Info for the Devops Barcelona 2024 Conference
Essential Info for the Devops Barcelona 2024 ConferenceEssential Info for the Devops Barcelona 2024 Conference
Essential Info for the Devops Barcelona 2024 Conference
Ricard Clau
 
devopsbcn23.pdf
devopsbcn23.pdfdevopsbcn23.pdf
devopsbcn23.pdf
Ricard Clau
 
devopsbcn22.pdf
devopsbcn22.pdfdevopsbcn22.pdf
devopsbcn22.pdf
Ricard Clau
 
NoEresTanEspecial-PulpoCon22.pdf
NoEresTanEspecial-PulpoCon22.pdfNoEresTanEspecial-PulpoCon22.pdf
NoEresTanEspecial-PulpoCon22.pdf
Ricard Clau
 
DevOps & Infraestructura como código: Promesas Rotas
DevOps & Infraestructura como código: Promesas RotasDevOps & Infraestructura como código: Promesas Rotas
DevOps & Infraestructura como código: Promesas Rotas
Ricard Clau
 
DevOps Barcelona Conference 2018 - Intro
DevOps Barcelona Conference 2018 - IntroDevOps Barcelona Conference 2018 - Intro
DevOps Barcelona Conference 2018 - Intro
Ricard Clau
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
Ricard Clau
 
Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2
Ricard Clau
 
Betabeers Barcelona - Buenas prácticas
Betabeers Barcelona - Buenas prácticasBetabeers Barcelona - Buenas prácticas
Betabeers Barcelona - Buenas prácticas
Ricard Clau
 
Desymfony - Servicios
Desymfony  - ServiciosDesymfony  - Servicios
Desymfony - Servicios
Ricard Clau
 
Essential Info for the Devops Barcelona 2024 Conference
Essential Info for the Devops Barcelona 2024 ConferenceEssential Info for the Devops Barcelona 2024 Conference
Essential Info for the Devops Barcelona 2024 Conference
Ricard Clau
 
NoEresTanEspecial-PulpoCon22.pdf
NoEresTanEspecial-PulpoCon22.pdfNoEresTanEspecial-PulpoCon22.pdf
NoEresTanEspecial-PulpoCon22.pdf
Ricard Clau
 
DevOps & Infraestructura como código: Promesas Rotas
DevOps & Infraestructura como código: Promesas RotasDevOps & Infraestructura como código: Promesas Rotas
DevOps & Infraestructura como código: Promesas Rotas
Ricard Clau
 
DevOps Barcelona Conference 2018 - Intro
DevOps Barcelona Conference 2018 - IntroDevOps Barcelona Conference 2018 - Intro
DevOps Barcelona Conference 2018 - Intro
Ricard Clau
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
Ricard Clau
 
Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2
Ricard Clau
 
Betabeers Barcelona - Buenas prácticas
Betabeers Barcelona - Buenas prácticasBetabeers Barcelona - Buenas prácticas
Betabeers Barcelona - Buenas prácticas
Ricard Clau
 
Desymfony - Servicios
Desymfony  - ServiciosDesymfony  - Servicios
Desymfony - Servicios
Ricard Clau
 

Recently uploaded (20)

2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 

Scaling with Symfony - PHP UK

  • 2. HELLO PHPUK! • Ricard Clau, born and grown up in Barcelona, Spain • Software engineer at Hailo London • Symfony2 lover and PHP believer • Open-source contributor, sometimes I give talks • Twitter @ricardclau / Gmail [email protected]
  • 3. WHY THIS TALK? • Lots of PHP haters these days. I just don´t get it. • Some misconceptions about full-stack PHP frameworks • PHP is absolutely fine for most of your applications • But at some point you may need to replace some bits • DragonCity - Social game - 7.5M DAU - Symfony
  • 4. AGENDA • Performance and scalability • Profiling and optimization • Storage: SQL vs NoSQL • Symfony2 is fast enough! Seriously! • Some war stories! • Almost everything applies to all PHP projects
  • 7. AVAILABLE 24X7X365 We need to recover fast from any failure
  • 8. LOAD BALANCING It allows you to make changes without stopping your app
  • 9. SHARDING Luckily, you will get to a point when you need to do it... And it can hurt if you have never considered it!
  • 10. DON´T IF NOT NEEDED • Avoid premature optimizations • Microoptimizations are completely useless • Focus on impacting things • Incremental improvements • If the business is not working, it will be useless
  • 11. BUT ACTIVELY PREVENT RISKS • Monitor servers: Ram, CPUs, Disk, network, idle processes... • Try to engage stakeholders • When something surpasses half capacity, start creating a B plan • Death of success is terrible
  • 12. HANDS ON! Where do we start from?
  • 13. LOVE YOUR FRONTEND Reduce # of requests and their size
  • 14. SOME QUICK ADVICES • Fastest request -> No actual request • Icons in base64 inside your CSS • Minify CSS and JS, image size (jpegoptim, pngcrush, ...) • Use HTTP headers to cache at several layers • Network latency matters a lot • User experience takes benefit from all of these
  • 15. SCALING PHP Facebook, Wikipedia, Yahoo, Wordpress, Etsy, Zynga, YouPorn, Hailo, Softonic, Emagister, Privalia, SocialPoint, Tuenti, ...
  • 16. IS SCALING ACTUALLY EASY? • PHP bootstraps on every Request, so scaling is as “easy” as adding machines behind a Load Balancer • But it makes it much slower than many other languages • Some things are shared among requests (sessions, storage, ...) but frameworks like Symfony make it easier • PHP has been proof-tested in several BIG projects • Most of the times, problems are caused by the DB
  • 17. LOOK BEYOND LAMP • Light-weight HTTP servers / CDNs for assets • Introduce reverse proxy cache like Varnish to cache pages (or ESI blocks) • Cache all the things (APC, Memcached, Redis, ...). 10 seconds cache -> Only 6 hits per minute! • RDBMS can deal with A LOT of data. But some problems are much better solved with NoSQL databases • Sometimes other languages are more suitable for our problem
  • 18. PHP PERFORMANCE Opcode caches, composer, HHVM, quick wins Upgrading from PHP5.3 will boost ~20-40%
  • 19. APC: OUR OLD BESTIE • If you have ever worried about performance... you know it! • apc.stat -> Off (Apache reload to see changes) • apc.serializer -> igbinary (compact_strings -> Off) • apc.shm_size -> Check if 32Mb is enough • apc.write_lock -> Avoids cold cache issues • Check http://www.php.net/manual/en/apc.configuration.php
  • 21. ZEND OPCACHE • Included in PHP5.5 standard distribution (valid with 5.2) will avoid weird random issues like PHP5.4+APC • Better performance than APC in all tests • README https://github.com/zendtech/ZendOptimizerPlus • APC Userland Cache + Upload Hooks now live in APCU (https://github.com/krakjoe/apcu) • Lots of companies are already using it!
  • 22. OPCACHE STATUS 1 full-stack file, Rasmus style :) (https://github.com/rlerdorf/opcache-status)
  • 23. COMPOSER AUTOLOAD • You all already use Composer, right? • Default PSR-0 implementation is slow because we access the FileSystem a lot • composer.phar install --optimize-autoloader (-o) generates ClassMap • Same performance apc.stat = Off than ApcUniversalClassLoader and less keys stored in APC
  • 24. APC VS ZEND OPCACHE http://www.ricardclau.com/2013/03/apc-vs-zend-optimizer-benchmarks-withsymfony2/
  • 25. APC VS ZEND OPCACHE http://www.ricardclau.com/2013/03/apc-vs-zend-optimizer-benchmarks-withsymfony2/
  • 26. HHVM: THE FUTURE ENGINE? • Impressive progress in HHVM these past months • Most frameworks and libraries ~100% compatibility • Fewer memory, interesting speed improvements • We might finally have a language specification for PHP! • Specific HHVM features? -> Dangerous! • It will still not be comparable to compiled languages
  • 27. FINE TUNING SYMFONY2 • Disable unused bundles • SwiftMailer is quite slow, delegate to queue processes • If you can, use SubRequests with ESI and Varnish • Also check Twig C extension • You can implement a Cache Warmer for special needs • If using Apache, try app/console router:dump-apache
  • 29. PROFILING TOOLS • How often do you profile your code? • xDebug (Derick Rethans) and XHProf (Facebook) • Very convenient to install them in live servers and activate to grab real data • Many things can also be discovered locally • Some tragedies only happen with live traffic
  • 30. XHPROF (DEV VS PROD) https://github.com/jonaswouters/XhprofBundle
  • 31. HELLO WORLD PHP and its frameworks... Benchmarks comparing completely different things...
  • 32. ¿FRAMEWORKS == SLOW? • Some people think that writing their own framework from scratch is a good idea • Also, that big frameworks use a lot of memory. (ZF1 and Symfony2 work with memory_limit 32M) • If this is your problem, PHP is not the solution • Don´t trust Hello World Performance Tests! • Nobody is better than a big community
  • 33. TECHEMPOWER BENCHMARK • Symfony2 appears at the bottom • Comparison with light-weight frameworks is unfair. Some incoherences (frameworks PHP >> PHP) • PHP will never be faster than a compiled language • In real apps, caching and DB optimizations equal things • Symfony2 roadmap improving performance
  • 34. STORAGE Use the right tool for the job. Silver bullets do not exist
  • 35. RELATIONAL DBS • Mature technologies, good performance • Transactions: Atomicity, Consistency, Isolation, Durability • Foreign Keys, Joins, complex reporting queries • Millions of records without issues • We can use a NOSQLs key-value approach using BLOB fields with serialized objects
  • 36. NOSQL SOLUTIONS • Solutions to some concrete problems • CAP theorem (Consistency, Availability, Partition tolerance). You can only get 2 of them... theoretically • Inmaturity in some of them. Complex to scale. • ¿Big Data? 100M of records is NOT BIG DATA. • Redis, Cassandra, Riak and Solr work really well
  • 37. QUEUE SYSTEMS Read the docs, they are all completely different!
  • 38. REAL-TIME DATA? • Try to delegate as much as possible to batch processes • Sending mails, external API requests, image resizing, non-critical stats, ... • 99% of stats don´t need to be real-time • 60 seconds delay is mostly real-time! • Batch processes can be coded in different languages!
  • 39. PHP NEEDS FRIENDS Sometimes it is just not the best tool for our needs
  • 40. PHP BAD SCENARIOS • 24x7 running CLI daemon apps • Heavy math calculations, massive data processing, programming contests • High concurrency apps with non-cachable requests • Threading, Forking, concurrent programming... • Writing DSLs
  • 41. LOOK BEYOND PHP • JavaScript will be the king in the client side • In the server, Erlang and Go are growing adopters. And time will say about Node.JS • Compiled languages like Go, C, C++ or Java will always be used in our stack. • JVM languages like Scala and Clojure are sexy now! • Learning other languages makes you a better engineer!
  • 42. SYMFONY2 It is fast enough for most of what you want to do
  • 43. WHY SYMFONY2? • Symfony2 is NOT the fastest “Hello world” framework... but it is fast enough for most APIs and web applications • Big-community frameworks allow you to test any technology in less than 5 minutes • A custom framework has usually higher costs and risks • LTS releases roadmap, stability, big projects are using it • Mature community, # of bundles
  • 45. DRAGONCITY: NUMBERS • ~7.5 million daily users • ~300 millions of registered users • Hundreds of millions of records for analytics generated daily • MySQL (32x2 + Analytics), Redis (~30), Cassandra (3) • HTTP requests are your progress -> No cacheable • Yes, most of the code is Symfony2! :)
  • 46. POWERED BY SYMFONY2 @adanlobato showing happiness and pride!
  • 47. 6 DIGITS IN ANALYTICS Yeah, still Symfony2! o/
  • 48. WRAP-UP • PHP and Symfony2 work for most projects • Clever caching strategy is helpful • Profiling can make performance improve • The storage is almost always the bottleneck • Proper architecture design is crucial • PHP is not the best solution to some problems
  • 49. QUESTIONS? • Twitter: @ricardclau • E-mail: [email protected] • Github: https://github.com/ricardclau • Blog about PHP and Symfony2: http://www.ricardclau.com • Please, rate this talk at https://joind.in/talk/view/10697