Closed AlpeshValvi123 closed 5 years ago
A trained model (ITransformer) is thread safe, so it can even be singleton or static and you can re-use it. However, the PredictionEngine is NOT thread safe, so it shouldn't be re-used across different threads. That's why we created the PredictionEnginePool you must use in multi-thread apps when using .NET Core like ASP.NET Core apps.
For further details on how to deploy a model with the PredictionEnginePool, read the following resources: Tutorials:
For further background information on why the PredictionEnginePool is recommended, read this blog post which was the origin of our PredictionEnginePool: https://devblogs.microsoft.com/cesardelatorre/how-to-optimize-and-run-ml-net-models-on-scalable-asp-net-core-webapis-or-web-apps/
Closing the issue for now. Re-open if needed. Thanks,
How to reused train model and PredictionFunction in multiple method? Please look at below eg.