roadrunner-server / roadrunner

🤯 High-performance PHP application server, process manager written in Go and powered with plugins
https://docs.roadrunner.dev
MIT License
7.92k stars 411 forks source link

A way to define max execution time #122

Closed speller closed 5 years ago

speller commented 5 years ago

Hi, Is there a way to define request max execution time? If a script will enter an infinite loop (for example) it seems it will never be killed.

Alex-Bond commented 5 years ago

Thats actually really good question. @wolfy-j lets add TTK config maybe?

wolfy-j commented 5 years ago

If you acknowledge that I can only KILL worker process (i.e. cause data corruption on looooong queries) - I'm fine doing that.

Alex-Bond commented 5 years ago

We can do TTK for request processing. If worker spend more than 60 seconds (for example) we will kill the worker and send 504 error to the client

wolfy-j commented 5 years ago

That is correct, I'm pointing that I will have to physically KILL workers. Meaning you would have to be careful setting TTK.

Alex-Bond commented 5 years ago

It is kind of the same as max_execution_time but for RR.

wolfy-j commented 5 years ago

Correct. I can work on it and on TTL as well.

speller commented 5 years ago

Yes, killing a worker will be good approach. Thanks! Let's set 60 sec timeout by default.

OO00O0O commented 5 years ago

Maybe RR could use some of php.ini settings as default value for RR. Drop in experience could get better.

wolfy-j commented 5 years ago

We do not read php.ini in RR service at the moment. I'm currently planning to implement functionality to provide much more flexible control on worker livecycle in rr server, it will open the gate to functionality like max lifetime, proactive memory monitoring and adaptive scalers.

speller commented 5 years ago

RR can read phpinfo() or php -i

wolfy-j commented 5 years ago

Available in 1.4.0, see sample config for configuration example https://github.com/spiral/roadrunner/blob/master/.rr.yaml

camohob commented 4 years ago

Available in 1.4.0, see sample config for configuration example https://github.com/spiral/roadrunner/blob/master/.rr.yaml

execTTL is solution for http service, but if i using roadrunner.Server directly, how can i use exec TTL?

wolfy-j commented 4 years ago

Hi,

you can attach the controller to any Server:

https://github.com/spiral/roadrunner/blob/master/server.go#L67 https://github.com/spiral/roadrunner/blob/master/controller.go#L4

You can implement any control logic inside it... or use the controller from Limit service:

https://github.com/spiral/roadrunner/tree/master/service/limit (you'll have to grab it from the config).

Or you can make your service expose Service() method and then you can point limit to it.