Why?
• Use
of
frameworks
has
become
mandatory
in
professional
development
with
PHP
• They
offer
a
philosophy
and
organized
structures
to
easily
maintain
projects
wri?ng
less
code
and
making
work
more
fun
Slide 3
Slide 3 text
How PHP works?
1. PHP
have
dynamic
and
weak
typing
discipline
2. PHP
is
interpreted
(not
compiled)
3. Every
?me
a
script
is
loaded,
should
be
interpreted
by
PHP
4. If
a
bytecode
cache
(like
APC)
isn’t
used,
syntax
checking
is
performed
every
?me
Slide 4
Slide 4 text
How traditional php
frameworks works?
1. Many
files
with
classes
and
func?ons
are
read
at
every
request
made.
Disk
reading
is
expensive
in
terms
of
performance
2. Modern
frameworks
use
lazy
loading
technique
(autoload)
for
load
and
execute
only
code
needed
3. Con?nuous
loading/interpre?ng
could
be
expensive
and
impact
your
applica?on
performance
4. When
you
use
a
framework
most
of
the
code
remain
the
same
across
development.
Why
load
and
interpret
it
every
?me?
Slide 5
Slide 5 text
How a PHP C extension
works?
1. C extensions are loaded together with PHP
one time, on the web server dispatch process
2. Classes and functions provided by the
extension are ready to use for any application
3. The code isn’t interpreted because it is
compiled to a specific platform and processor
Slide 6
Slide 6 text
How Phalcon works?
1. Components
are
loosely
coupled.
You
may
use
the
components
you
want
without
depending
on
a
full
stack
2. Low-‐level
op?miza?ons
provide
the
lowest
overhead
for
MVC-‐based
applica?ons
3. Interact
with
databases
with
maximum
performance
by
using
a
C-‐language
ORM
for
PHP
4. Phalcon
is
directly
engaged
with
PHP,
so
it
can
directly
access
internal
structures
op?mizing
execu?on
as
well
Slide 7
Slide 7 text
Traditional Frameworks Phalcon
Interpretation of hundreds
or thousands of PHP lines
on each request
Yes No
Load dozens of files in
each request
Yes No
Checking the existence of
functions, methods,
classes, constants at each
request
Yes No
Low-level optimizations
gaining microseconds for
each request
No Yes
Compare how Phalcon is faster than
other frameworks
Slide 8
Slide 8 text
Framework Benchmark
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
Hello!
Slide 11
Slide 11 text
• Operative System: Mac OS X Snow Leopard
10.6.8
• Web Server: Apache httpd 2.2.21
• PHP: 5.3.8 + APC 3.1.9 (Without Xdebug)
• CPU: 3.06 Ghz Intel Core 2 Duo
• Main Memory: 4GB 1067 MHz DDR3
• Hard Disk: 500GB SCSI/SAS HDD
Test Environment
Slide 12
Slide 12 text
ab
–n
1000
–c
5
http://localhost/bench/phalcon
Slide 13
Slide 13 text
Framework/Requests per Second
0
500
1000
1500
2000
2500
114,49
234,53
552,28
662,61
947,56
2489,26
#
Requests/sg
Slide 14
Slide 14 text
Framework Total Requests/Average Time
0
1
2
3
4
5
6
7
8
9
8,735
4,264
1,811
1,509
1,055
0,422
Time
per
Request/sg
Slide 15
Slide 15 text
Number of Interpreted Files per Request
0
20
40
60
80
100
120
115
66
46
36
23
4
Number
of
Files