threads in php will change the world - appserver.io
DESCRIPTION
Using threads in PHP will change the world. appserver.io is the worlds first real application server for PHP written in PHP supporting multi-threading "out-of-the-box". appserver.io is a next-generation PHP infrastructure consisting of a lightning fast webserver completely written in PHP including additional frequently needed services in one powerful bundle. You can use all of the services or only specifically selected services in your existing application with no additional tweaks. This is just what you need since we have eliminated the need for additional tools or additional services, appserver.io and PHP and you´re done!TRANSCRIPT
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
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 extensionpthreads
my first
THREAD
my first
THREAD
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
What is a
WORKER
allows stacking ofDATA
like aQUEUE
using a
Worker
using a
Worker
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
sharing Sockets
sharing Sockets
sharing Sockets
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
What’s
NEXT?
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?