Thre „will
ads
in PH P
chan ges the worl d“
m
om
Co-Founder and CTO
illk sw
Stefan Willkommer
er
@
r_ tim
78
Tim Wagner
w
@
ag ne
Co-Founder and Lead Architect
me ah Tim Uschi me ;)
Barbecue
i s s i S
Annette
Tiger
Let’s
DIFFERENTIATE
EVENTLOOPS
FORKS
THREADS
What is a
THREAD
Process-Model without
THREADS
Process-Model with
THREADS
What do we
NEED
PHP 5.3+
compiled thread-safe --enable-maintainer-zts
PECL extension
pthreads
my first
THREAD
my first
THREAD
What is a
STACKABLE
enabling sharing and synchronizing
Data over THREADS
tasks which can be processed
by a WORKER
What can be
SHARED
everything which is
SERIALIZABLE
sharing Data with a
Stackable
sharing Data with a
Stackable
sharing Data with a
Stackable
What is a
WORKER
allows stacking of
DATA
like a
QUEUE
using a
Worker
using a
Worker
SYNCHRONISATION and
CONCURRENCY HANDLING
waiting for Threads with
join()
enables waiting for one or more
THREADS
makes sure that result is available in
THREAD
waiting by using
Join
waiting by using
Join
waiting by using
Join
synchronizing Threads with
synchronized()
synchronize with
synchronized()
synchronize with
synchronized()
synchronize with
synchronized()
concurrency handling by using
MUTEX
synchronize with
Mutex
synchronize with
Mutex
synchronize with
Mutex
sharing
Resources
sharing
Sockets
sharing
Sockets
sharing
Sockets
What to do with all these
POSSIBILITIES
everything
GOOD BAD is
Runtime ApplicationServer PersistenceContainer MQ
Worker
Timer
Web Objects
WebServer
MBeans! SBeans!
Threads
!
Worker Socket! 0.0.0.0:8587
Message
Socket! 0.0.0.0:8585
Socket! 0.0.0.0:8586
RemoteMethod
HTTP
Performance comparison
260
Test Profile Setup: 1 Webserver + 1 DB Server Virtualisation: KVM / Intel Xeon / 4 Cores OS: Debian wheezy
milliseconds
195
130
65
Magento: 1.13.1.0 EE Amount of Products: 10,000
0
Homepage
AS, mod PHP
Category Page
Detailpage
nginx, PHP FPM
The power of
MEMORY
Performance comparison
260
Test Profile Setup: 1 Webserver + 1 DB Server Virtualisation: KVM / Intel Xeon / 4 Cores OS: Debian wheezy
milliseconds
195
130
65
Magento: 1.13.1.0 EE Amount of Products: 10,000
0
Homepage
Category Page
AS, Mage Servlet
Detailpage
nginx, PHP FPM
in average about
60% faster
in average about
280% faster
What’s
NEXT?
Ressources https://github.com/techdivision/phptek_2014 https://github.com/krakjoe/pthreads https://computing.llnl.gov/tutorials/pthreads/ http://appserver.io https://github.com/techdivision/TechDivision_ApplicationServer
Thank you!
Questions?