Coder Social home page Coder Social logo

sokil / php-concurrency-labs Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 1.0 86 KB

PHP Concurency research

Home Page: https://sokil.github.io/php-concurrency-labs/

PHP 100.00%
php php-async php-threads reactphp php-concurrency concurrency async threads multitasking coroutines

php-concurrency-labs's Introduction

PHP Concurrency

Definitions

Concurrency: ability of different parts of a program to be executed out-of-order.

Parallelism: Form of parallel computing in which execution of processes are carried out concurrently across multiple processors in parallel computing environments.

Multitasking: is the concurrent execution of multiple tasks over a certain period of time. There are two types of multitasking:

  • Co-operative, non-preemptive: is a style of computer multitasking when process voluntarily yield control and all programs must cooperate for the entire scheduling scheme to work.
    • Asynchronous code execution
    • Coroutines
  • Preemptive: involves the use of an interrupt mechanism which suspends the currently executing process and invokes a scheduler to determine which process should execute next. Therefore, all processes will get some amount of CPU time at any given time.
    • Threads
    • Forks

Asynchronous code execution

Event loop extensions

Name Extension Source Version PHP version
ext-libevent PHP Manual PECL, git.php.net 0.1.0 >= 5.3.0, < 7.0.0
ext-event PHP Manual PECL, Bitbucket 2.3.0 >= 5.4, >= 7.0
ext-libev GitHub manual GitHub < 7.0.0
ext-ev PHP Manual PECL, BitBucket >= 5.4, > 7.0
eio PHP Manual PECL, GitHub
swoole GitHub manual GitHub
libuv GitHub PECL, GitHub
concurent-php/ext-async GitHub manual GitHub - nightly
ext-fiber https://wiki.php.net/rfc/fibers, https://github.com/amphp/ext-fiber

Links:

ext-libevent

Has build-in OpenSSL library, non-blocking IO, http, dns.

pecl install libevent-0.1.0

ext-event

Event is a PECL extension providing interface to libevent C library.

The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals or regular timeouts.

Dockerfile: https://github.com/sokil/php-concurrency-labs/blob/master/docker/Dockerfile.ext-event

ext-libev

Library tries to improve libevent. But this is only event library, instead of libevent giving non-blocking IO, http, etc.

Install libev library:

sudo apt-get install libev-dev

Install php extension ext-libev. Clone https://github.com/m4rw3r/php-libev and build extension:

phpize
./configure --with-libev
make
make install

libuv

Event loop frameworks

ReactPHP

Source: https://reactphp.org

Examples: https://github.com/sokil/php-concurrency-labs/tree/master/src/ReactPHP

cd src/ReactPHP
Docker build -t php-event .
docker run --rm -v `pwd`:/src php-event php /src/TimerExample.php
Articles

AMP

Site: https://amphp.org

Source: https://github.com/amphp

icicleio

Icicle is now deprecated in favor of Amp v2.0

Source: https://github.com/icicleio

Kraken

Source: http://kraken-php.com

Workerman

Source: https://github.com/walkor/Workerman

Multithread code execution

Thread extensions

Name Source Manual
Pthreads GitHub,PECL PHP Manual
Pht GitHub PHP Manual

Pthreads

Dockerfile: https://github.com/sokil/php-concurrency-labs/blob/master/docker/Dockerfile.ext-phtreads

Examples: https://github.com/sokil/php-concurrency-labs/tree/master/src/Pthreads

Coroutines

Coroutines are computer-program components that generalize subroutines for non-preemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes.

Articles

Distributed locking

Process management

Articles

Tools

Tools

Stream

PHP Manual: http://php.net/manual/ru/book.stream.php

Examples: https://github.com/sokil/php-concurrency-labs/tree/master/src/Stream

Articles

php-concurrency-labs's People

Contributors

sokil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rtiweb

php-concurrency-labs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.