Asynchronous PHP Myth? Reality!

39
Asynchronous PHP Myth? Reality! Alexander Lisachenko, Head of Sowtware Architecture at Alpari (RU)

description

Asynchronous PHP Myth? Reality!. Alexander Lisachenko, Head of Sowtware Architecture at Alpari (RU). About me. About me. Technology Evolution. Technology Evolution. What should we expect in the nearest future?. Technology trends. PHP World. Simple example. What if sharding ?. - PowerPoint PPT Presentation

Transcript of Asynchronous PHP Myth? Reality!

Page 1: Asynchronous PHP Myth? Reality!

Asynchronous PHPMyth? Reality!

Alexander Lisachenko, Head of Sowtware Architecture at Alpari (RU)

Page 2: Asynchronous PHP Myth? Reality!

About me

Page 3: Asynchronous PHP Myth? Reality!

About me

Page 4: Asynchronous PHP Myth? Reality!

Technology Evolution

Page 5: Asynchronous PHP Myth? Reality!

Technology Evolution

Page 6: Asynchronous PHP Myth? Reality!

What should we expectin the nearest future?

Page 7: Asynchronous PHP Myth? Reality!

Technology trends

Page 8: Asynchronous PHP Myth? Reality!

PHP World

Page 9: Asynchronous PHP Myth? Reality!

Simple example

What if sharding?

What if unavailable?

Highload?

Page 10: Asynchronous PHP Myth? Reality!

Blocking IO

Page 11: Asynchronous PHP Myth? Reality!

What is the solution?

Page 12: Asynchronous PHP Myth? Reality!

Asynchronous PHP

Page 13: Asynchronous PHP Myth? Reality!

One-way SOAP call

Page 14: Asynchronous PHP Myth? Reality!

One-way SOAP call

No output is defined for the operation

Page 15: Asynchronous PHP Myth? Reality!

One-way SOAP call

Works only in WSDL-mode, so need an WSDL (Zend_AutoDiscover):

Only “input” part is defined for one-way call

Page 16: Asynchronous PHP Myth? Reality!

One-way SOAP call – client side

Page 17: Asynchronous PHP Myth? Reality!

CLI tools

Page 18: Asynchronous PHP Myth? Reality!

Processes

Page 19: Asynchronous PHP Myth? Reality!

Processes. Elementary

Page 20: Asynchronous PHP Myth? Reality!

Processes. Intermediate

Non-blocking stream, we can query it later asynchronously

with stream_select()

Page 21: Asynchronous PHP Myth? Reality!

Processes. Intermediate

stream_select() goodness

POSIX signals

Page 22: Asynchronous PHP Myth? Reality!

Processes. POSIX signals

Page 23: Asynchronous PHP Myth? Reality!

Processes. POSIX signals

Page 24: Asynchronous PHP Myth? Reality!

Signal handling issue in the code

PHP will hang until loop is finished and will ignore signals

Page 25: Asynchronous PHP Myth? Reality!

Asynchronous signal handling

Enable support for tick handler and async signal

handling.

Page 26: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Enterprise way.

Page 27: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Enterprise way.

PHP App1PHP App1

PHP App2PHP App2

PHP App3PHP App3

PHP App4PHP App4

PHP App5PHP App5

PHP App6PHP App6

STOMP, WebSocket,

AMQP

Publishers Subscribers

Page 28: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Enterprise way.

Page 29: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Enterprise way.

Page 30: Asynchronous PHP Myth? Reality!

Asynchronous data access in PHP

Page 31: Asynchronous PHP Myth? Reality!

Asynchronous data access in PHP

Like typical stream_select() call

Page 32: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Cutting-edge.

Page 33: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Cutting-edge.

True threads in PHP!

Just call a function in the separate thread

Thread syncrhronization

Page 34: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Cutting-edge.

yields a thread-coroutine

Page 35: Asynchronous PHP Myth? Reality!

Asynchronous PHP. Cutting-edge.

Page 36: Asynchronous PHP Myth? Reality!

Threaded asynchronous socket server

Non-blocking server

Effective epoll() loop in libevent

Our threaded server

Page 37: Asynchronous PHP Myth? Reality!

Threaded asynchronous socket server

Non-blocking connection

Page 38: Asynchronous PHP Myth? Reality!

Threaded asynchronous socket server

Separate loop for each connection

Each connection is handled in separate

thread

Page 39: Asynchronous PHP Myth? Reality!

Thanks! Questions?

Alexander Lisachenko

Twitter: https://twitter.com/lisachenkoGithub: https://github.com/lisachenko