Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any suggestions for significant performance boost under high load? #14646

Closed
m0onspell opened this issue Aug 14, 2017 · 5 comments
Closed

Any suggestions for significant performance boost under high load? #14646

m0onspell opened this issue Aug 14, 2017 · 5 comments
Labels

Comments

@m0onspell
Copy link

m0onspell commented Aug 14, 2017

What steps will reproduce the problem?

Writing a basic API ping action, like

class PingAction extends BaseApiAction
{
	public function run()
	{
		return null;
	}
}

with token-authentication filter behind it. MySQL and Redis involved in proccess, typical User model.
That doesn't really matter, everything is quite basic.

What is the expected result?

I want to be able to serve as much requests per second as possible. At least 10k rps.

What do you get instead?

I am getting closely to 5k rps.
If I'll try to increase the load, response times become slower and slower, giving me even less count of succesfully handled requests.

Additional info

It must be a REST API, so no assets factor. My machine is quite powerful with 16 CPU cores. I've spent a lot of time tunning configurations for nginx, PHP-FPM, MySQL and Redis. Also made some Linux kernel settings optimization. I've also read this tutorial: enableSchemaCache helped a LOT, really. Dumping composer autoload also helped. Opcache is enabled. I haven't had a chance to upgrade to php 7.1, I know that will give a slight performance boost, and I also know, that it won't help significantly. But I'll do it.

Otherwise, I am pretty sure that everything is well-configured and optimized.

I've then built a Node.js/Express application with similar action and authentication step on each request. And I have to say, that node app was much-much faster, serving a lot more times of requests, almost out of the box, without any optimizations.

MySQL (after schema caching enabled) and Redis are definitely not the source of the problem - from the monitoring, I can see that they use a very small amount of resources under high load. I think that problem is framework bootstraping on every request. So I found this concept of using bootstraped daemons listening for new requests, like in
https://github.com/php-pm/php-pm
https://github.com/PHPFastCGI/FastCGIDaemon
But I am not sure if those libraries could be integrated easily with Yii2. I think they could really help. What do you guys think?

P.S. Sorry for posting a question here.

Q A
Yii version 2.0.10
PHP version 7.0
Operating system Ubuntu Server
@yii-bot
Copy link

yii-bot commented Aug 15, 2017

Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.

We advise you to use our community driven resources:

If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.

This is an automated comment, triggered by adding the label question.

@yii-bot yii-bot closed this as completed Aug 15, 2017
@samdark
Copy link
Member

samdark commented Aug 15, 2017

PHP has to initialize everything on each request so 5000 rps sounds OK. phpdaemon and php-pm could be used with Yii but I can't say it's easy.

@samdark
Copy link
Member

samdark commented Aug 15, 2017

@m0onspell
Copy link
Author

@samdark I see. Well, then I'll just go with node/express for this project.
But it's quite interesting to make a research on integration with php-pm, just for fun, I'll investigate that.
I also will look at WebSockets approach instead of REST.
Thanks.

@samdark
Copy link
Member

samdark commented Aug 15, 2017

I've linked to websocket ext. not because it's about websockets but because it uses PhpDaemon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants