[Serve] Reconfigure backend class at runtime (#11709)

This commit is contained in:
architkulkarni
2020-11-09 14:04:51 -06:00
committed by GitHub
parent 287aba6dc3
commit adcaabcd64
8 changed files with 127 additions and 4 deletions
+20 -1
View File
@@ -1,5 +1,5 @@
======================================
Advanced Topics, Configurations, & FAQ
Advanced Topics and Configurations
======================================
Ray Serve has a number of knobs and tools for you to tune for your particular workload.
@@ -269,6 +269,25 @@ errored requests through the Ray metrics monitoring infrastructure. By default,
the metrics are exposed in Prometheus format on each node. See the
`Ray Monitoring documentation <../ray-metrics.html>`__ for more information.
Reconfiguring Backends (Experimental)
=====================================
Suppose you want to update a parameter in your model without creating a whole
new backend. You can do this by writing a `reconfigure` method for the class
underlying your backend. At runtime, you can then pass in your new parameters
by setting the `user_config` field of :mod:`BackendConfig <ray.serve.BackendConfig>`.
The following simple example will make the usage clear:
.. literalinclude:: ../../../python/ray/serve/examples/doc/snippet_reconfigure.py
The `reconfigure` method is called when the class is created if `user_config`
is set. In particular, it's also called when new replicas are created in the
future, in case you decide to scale up your backend later. The
`reconfigure` method is also called each time `user_config` is updated via
:mod:`client.update_backend_config <ray.serve.api.Client.update_backend_config>`.
Dependency Management
=====================