Cphalcon: run phalcon in php-cli and use coroutine to do io

Created on 24 Sep 2017  路  6Comments  路  Source: phalcon/cphalcon

hey, i am a big fan of phalcon and zephir.
I have explained my idea that the bottle neck of phalcon in:https://github.com/phalcon/zephir/issues/694#issuecomment-331716887

I think use coroutine(which is only possible in php-cli) is the key to improve performance.
Swoole has already do it and get great improvement: https://github.com/swoole/swoole-src

I think run phalcon in php-cli and use coroutine deserves a try. As you can see swoole does not have a strong community as phalcon. so if you are interested in the idea, why not try to run phalcon in swoole or implement coroutine in phalcon itself?

stale

Most helpful comment

No, coroutine is different from asynchronous method.
ReactPHP, swoole1.x are asynchronous framework. They run in php-cli and act like nodejs early days. But call-back hell problem make it difficult to develop application(Althoug many framework use Generators to implement semi-coroutine to overcome this just like nodejs's koa).
swoole2.x implemented full coroutine and it's possible to run laravel/yii in swoole http server(which is run as php-cli coroutine). Of course you should change the core of laravel/yii and disallow blocking method completely. Also this will bring us tcp/mysql/redis connection pool. No need to initiate framework in every request anymore, one request one coroutine, a php-cli application can handle many requests at the same time.
Now php can handle io at a low cost just like go.

All 6 comments

Close in favor of #13068

No, coroutine is different from asynchronous method.
ReactPHP, swoole1.x are asynchronous framework. They run in php-cli and act like nodejs early days. But call-back hell problem make it difficult to develop application(Althoug many framework use Generators to implement semi-coroutine to overcome this just like nodejs's koa).
swoole2.x implemented full coroutine and it's possible to run laravel/yii in swoole http server(which is run as php-cli coroutine). Of course you should change the core of laravel/yii and disallow blocking method completely. Also this will bring us tcp/mysql/redis connection pool. No need to initiate framework in every request anymore, one request one coroutine, a php-cli application can handle many requests at the same time.
Now php can handle io at a low cost just like go.

phalcon is a web framework.

I support any idea which will improve core stuff. Even some ideas might sound too unrealistic for real world apps to take into account... but at least it's got to see a community full of nice ideas!

Thumbs up @gouchaoer

not unrealistic.
some framework has already use coroutine like:https://github.com/swoft-cloud/swoft (it's in chinese and in developing at present)

Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues

Was this page helpful?
0 / 5 - 0 ratings