Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Request-level concurrency has always scaled well. As for lightweight concurrency, have you worked with PHP Fibers? https://medium.com/@binumathew1988/leveraging-php-fibers-for...


PHP Fibers does not do anything on its own. Its basically just syntax for generators, to be used with various external runtimes.

This means in a vanilla PHP setup when i do something like this:

    $a = new Fiber(function () {
        sleep(2); // block
        Fiber::suspend();
        return null;
    });
    
    $b = new Fiber(function () {
        sleep(2); // block
        Fiber::suspend();
        return null;
    });
    
    // Start execution
    $a->start();
    $b->start();
    
    // ... later in code wait for both executions to finish
    $a->resume();
    $b->resume();

    
    // Total execution time is not 2 seconds, but 4
I need an additional runtime to support real concurrency. I also need a separate async IO library to handle blocking. This is usually a showstopper for most PHP still out there. And just annoying on so many levels.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: