390 likes | 601 Views
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 ?.
E N D
Asynchronous PHPMyth? Reality! Alexander Lisachenko, Head of Sowtware Architecture at Alpari (RU)
Simple example What if sharding? What if unavailable? Highload?
Asynchronous PHP • Soap one-way calls • CLI processes: exec, popen, proc_open • CLI signals: pcnt_signal_dispatch, ticks, register_tick_function • Message Queues • DB: reap_async_query, mysqli_poll, pg_send_query • Selecting: curl_multi_select, socket_select, stream_select, stream_set_blocking • Threads (pthreads extension)
One-way SOAP call No output is defined for the operation
One-way SOAP call Works only in WSDL-mode, so need an WSDL (Zend_AutoDiscover): Only “input” part is defined for one-way call
Processes. Intermediate Non-blocking stream, we can query it later asynchronously with stream_select()
Processes. Intermediate stream_select() goodness POSIX signals
Signal handling issue in the code PHP will hang until loop is finished and will ignore signals
Asynchronous signal handling Enable support for tick handler and async signal handling.
Asynchronous PHP. Enterprise way. Publishers Subscribers Message Queue PHP App1 PHP App4 PHP App2 PHP App5 PHP App3 PHP App6 STOMP, WebSocket, AMQP
Asynchronous data access in PHP Like typical stream_select() call
Asynchronous PHP. Cutting-edge. True threads in PHP! Just call a function in the separate thread Thread syncrhronization
Asynchronous PHP. Cutting-edge. yields a thread-coroutine
Threaded asynchronous socket server Non-blocking server Our threaded server Effective epoll() loop in libevent
Threaded asynchronous socket server Non-blocking connection
Threaded asynchronous socket server Each connection is handled in separate thread Separate loop for each connection
Thanks! Questions? Alexander Lisachenko Twitter: https://twitter.com/lisachenko Github: https://github.com/lisachenko