Threads in PHP „will changes the world“
Stefan WillkommerCo-Founder and CTO
wag
ner_t
im78
@
Tim WagnerCo-Founder and Lead Architect
@
swillkommer
TigerSissi
me ;)Annette
Uschi
me ah Tim
Barbecue
Let’s
DIFFERENTIATE
Process-Model without
THREADS
Process-Model with
THREADS
compiled thread-safe--enable-maintainer-zts
PECL extensionpthreads
What is a
STACKABLE
enabling sharing and synchronizingData over THREADS
tasks which can be processedby 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
allows stacking ofDATA
SYNCHRONISATION and
CONCURRENCY HANDLING
waiting for Threads with
join()
enables waiting for one or moreTHREADS
makes sure that result is available inTHREAD
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
What to do with all these
POSSIBILITIES
GOODeverything
is
BAD
RuntimeApplicationServerPersistenceContainer Web
MQ Objects WebServer
Worker Threads
Socket 0.0.0.0:8587
Socket 0.0.0.0:8585
Socket 0.0.0.0:8586
HTTPRemoteMethodMessage
Timer
MBeans SBeans
!
Worker
Performance comparison
Test Profile
Setup: 1 Webserver + 1 DB Server Virtualisation: KVM / Intel Xeon / 4 Cores OS: Debian wheezy Magento: 1.13.1.0 EE Amount of Products: 10,000
mill
isec
onds
0
65
130
195
260
Homepage Category Page Detailpage
AS, mod PHP nginx, PHP FPM
The power of
MEMORY
Performance comparison
Test Profile
Setup: 1 Webserver + 1 DB Server Virtualisation: KVM / Intel Xeon / 4 Cores OS: Debian wheezy Magento: 1.13.1.0 EE Amount of Products: 10,000
mill
isec
onds
0
65
130
195
260
Homepage Category Page Detailpage
AS, Mage Servlet nginx, PHP FPM
60%in average about
faster
280%in average about
faster
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
Ressources
Thank you!
Questions?