Top Banner
Threads in PHP „will changes the world“
83
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Threads in PHP - Presentation

Threads in PHP „will changes the world“

Page 2: Threads in PHP - Presentation

Stefan WillkommerCo-Founder and CTO

wag

ner_t

im78

@

Tim WagnerCo-Founder and Lead Architect

@

swillkommer

Page 3: Threads in PHP - Presentation

TigerSissi

me ;)Annette

Uschi

me ah Tim

Barbecue

Page 4: Threads in PHP - Presentation
Page 5: Threads in PHP - Presentation

Let’s

DIFFERENTIATE

Page 6: Threads in PHP - Presentation
Page 7: Threads in PHP - Presentation

EVENTLOOPS

Page 8: Threads in PHP - Presentation

FORKS

Page 9: Threads in PHP - Presentation

THREADS

Page 10: Threads in PHP - Presentation
Page 11: Threads in PHP - Presentation

What is a

THREAD

Page 12: Threads in PHP - Presentation

Process-Model without

THREADS

Page 13: Threads in PHP - Presentation

Process-Model with

THREADS

Page 14: Threads in PHP - Presentation

What do we

NEED

Page 15: Threads in PHP - Presentation
Page 16: Threads in PHP - Presentation

PHP 5.3+

Page 17: Threads in PHP - Presentation

compiled thread-safe--enable-maintainer-zts

Page 18: Threads in PHP - Presentation

PECL extensionpthreads

Page 19: Threads in PHP - Presentation
Page 20: Threads in PHP - Presentation
Page 21: Threads in PHP - Presentation
Page 22: Threads in PHP - Presentation

my first

THREAD

Page 23: Threads in PHP - Presentation

my first

THREAD

Page 24: Threads in PHP - Presentation

What is a

STACKABLE

Page 25: Threads in PHP - Presentation
Page 26: Threads in PHP - Presentation

enabling sharing and synchronizingData over THREADS

Page 27: Threads in PHP - Presentation
Page 28: Threads in PHP - Presentation

tasks which can be processedby a WORKER

Page 29: Threads in PHP - Presentation
Page 30: Threads in PHP - Presentation

What can be

SHARED

Page 31: Threads in PHP - Presentation
Page 32: Threads in PHP - Presentation

everything which is

SERIALIZABLE

Page 33: Threads in PHP - Presentation
Page 34: Threads in PHP - Presentation

sharing Data with a

Stackable

Page 35: Threads in PHP - Presentation

sharing Data with a

Stackable

Page 36: Threads in PHP - Presentation

sharing Data with a

Stackable

Page 37: Threads in PHP - Presentation

What is a

WORKER

Page 38: Threads in PHP - Presentation
Page 39: Threads in PHP - Presentation

allows stacking ofDATA

Page 40: Threads in PHP - Presentation

like aQUEUE

Page 41: Threads in PHP - Presentation
Page 42: Threads in PHP - Presentation

using a

Worker

Page 43: Threads in PHP - Presentation

using a

Worker

Page 44: Threads in PHP - Presentation

SYNCHRONISATION and

CONCURRENCY HANDLING

Page 45: Threads in PHP - Presentation

waiting for Threads with

join()

Page 46: Threads in PHP - Presentation
Page 47: Threads in PHP - Presentation

enables waiting for one or moreTHREADS

Page 48: Threads in PHP - Presentation

makes sure that result is available inTHREAD

Page 49: Threads in PHP - Presentation
Page 50: Threads in PHP - Presentation

waiting by using

Join

Page 51: Threads in PHP - Presentation

waiting by using

Join

Page 52: Threads in PHP - Presentation

waiting by using

Join

Page 53: Threads in PHP - Presentation

synchronizing Threads with

synchronized()

Page 54: Threads in PHP - Presentation

synchronize with synchronized()

Page 55: Threads in PHP - Presentation

synchronize with synchronized()

Page 56: Threads in PHP - Presentation

synchronize with

synchronized()

Page 57: Threads in PHP - Presentation

concurrency handling by using

MUTEX

Page 58: Threads in PHP - Presentation

synchronize with

Mutex

Page 59: Threads in PHP - Presentation

synchronize with

Mutex

Page 60: Threads in PHP - Presentation

synchronize with

Mutex

Page 61: Threads in PHP - Presentation

sharing

Resources

Page 62: Threads in PHP - Presentation

sharing Sockets

Page 63: Threads in PHP - Presentation

sharing Sockets

Page 64: Threads in PHP - Presentation

sharing Sockets

Page 65: Threads in PHP - Presentation

What to do with all these

POSSIBILITIES

Page 66: Threads in PHP - Presentation
Page 67: Threads in PHP - Presentation
Page 68: Threads in PHP - Presentation
Page 69: Threads in PHP - Presentation

GOODeverything

is

BAD

Page 70: Threads in PHP - Presentation
Page 71: Threads in PHP - Presentation
Page 72: Threads in PHP - Presentation

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

Page 73: Threads in PHP - Presentation
Page 74: Threads in PHP - Presentation

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

Page 75: Threads in PHP - Presentation

The power of

MEMORY

Page 76: Threads in PHP - Presentation

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

Page 77: Threads in PHP - Presentation

60%in average about

faster

Page 78: Threads in PHP - Presentation
Page 79: Threads in PHP - Presentation
Page 80: Threads in PHP - Presentation

280%in average about

faster

Page 81: Threads in PHP - Presentation

What’s

NEXT?

Page 82: Threads in PHP - Presentation

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

Page 83: Threads in PHP - Presentation

Thank you!

Questions?