Ray.init and Ray.shutdown a lightweight operation or a time-consuming operation?
There is an http service, each http request will trigger ray’s task execution.
Should Ray.init and Ray.shutdown be initialized once when the http service starts and killed, or initialized every time an http request is made, and shut down when the request ends?
We recommend you initialize it once.
ray.shutdown are cheap if you already ran
ray start on your host machine. But running
ray.init will create a new “job” to the Ray system, and this is heavyweight to be created every time you process a request.
Thank you for your answer. If I forget to execute ray.shutdown, Instead kill the http service directly, will it cause memory or connection leaks?
You don’t have to call ray.shutdown normally. Unless you sigkill the process, ray.shutdown is called upon regular termination automatically.