Why does MATLAB Production Server (MPS) take more time to process the first request compared to the subsequent requests?

When I send my first request to the MATLAB Production Server in MATLAB R2019a, it takes ~30 seconds to process it. However, the subsequent requests take less than a second to process. Why is this behavior encountered?

 Réponse acceptée

The MATLAB Production Server (MPS) instance uses MATLAB Runtime to evaluate incoming requests. The runtime is initialized when a worker first receives a request, and can take ~30 seconds to load. The same running instance of the runtime can then be used by any subsequent requests to the same worker. 
A few things to note:
  • If your MATLAB Production Server instance uses multiple workers, each worker maintains a separate instances of the runtime. For example, if your first request goes to Worker 1 and triggers the runtime initialization for this worker, subsequent requests that are routed to Worker 1 will process quickly. However, if a subsequent request is routed to Worker 2, the request will experience some delay while the runtime is initialized on Worker 2. 
  • The runtime required by an incoming request is specific to the MATLAB release used to compile the CTF. For example, a request for a CTF compiled using MATLAB R2024b will trigger the MATLAB Production Server worker to initialize an instance of the R2024b runtime. Subsequent requests that use the R2024b runtime will then process more quickly on this worker, as the R2024b runtime has already been initialized. However, if your next request is to a CTF compiled using MATLAB R2024a, this will experience some delay as the R2024a runtime must be initialized as well. 
  • Worker restarts (e.g. based on worker-restart-interval) will terminate any running runtime processes for a worker. 
Another factor that can impact the time taken to process the first request sent to an MPS instance is the time taken to load the requested CTF into memory. This can vary depending on your code, but can potentially introduce some minor delays to initial requests. Note that this also occurs on a per-worker basis and is cleared upon worker restarts.

Plus de réponses (0)

Catégories

Produits

Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by