Gabriel Ha, MathWorks
The REDIS high-speed cache shipped with MATLAB Production Server™ allows you to store data. This function is particularly useful to:
See how REDIS works with an example that calculates the remaining useful life (RUL) of a machine.
This video highlights a feature of MATLAB Production Server introduced in R2018b: the ability to store persistent data in a high-speed in-memory cache.
MATLAB Production Server requests are stateless, meaning that each call is independent of the previous one. There are times when you will want to store data or a state between calls, and MATLAB Production Server implements this feature by utilizing a high-speed in-memory database called REDIS. REDIS is shipped with MATLAB Production Server for on-premise installations, and MATLAB Production Server on the cloud lets you call the cloud service provider’s implementation, for example, Azure REDIS cache.
There are 2 primary scenarios where you’ll want to use the REDIS persistent cache:
The following example demonstrates both these scenarios. It uses incremental machine learning to predict the RUL—the remaining useful life of a motor.
The machine learning RUL algorithm has been deployed to MATLAB Production Server, and the predictive machine learning model required for the algorithm has been stored on REDIS.
The client application sends current samples of the motor to MATLAB Production Server, along with a request for the RUL given those samples. The RUL algorithm runs on a worker process which loads the predictive machine learning model from REDIS. This happens very quickly since REDIS is an in-memory database.
The predicted RUL is returned to the client application.
The model is also incrementally updated with the sample data and written back to REDIS to await the next invocation.
The results collected over time can be plotted on a chart in the client application.
Let’s see how this plays out.
We have data from a motor collected in sequence all the way to the end of its “Remaining Useful Life.” The 'monitorRUL' test script will perform an expedited simulation of the RUL for this motor by sending all those samples in sequence to MATLAB Production Server. It will also plot the RUL results as results are retrieved.
Line 6 of this code shows the syntax for connecting to a running REDIS cache. Lines 18 and 20 show how to use MATLAB 'put' and 'get' functions to write and read data to and from the cache.
Let’s now run the monitorRUL script, which will be sending the data to a MATLAB Production Server instance containing the deployed RUL algorithm and the corresponding predictive model stored in a REDIS cache.
We see that after about 2500 minutes of data, the model indicates a steep decline in the motor’s remaining useful life. A predictive maintenance application would use this information to alert someone to schedule maintenance for this particular motor.
To learn more about how to use persistence in MATLAB Production Server, visit the following website: https://www.mathworks.com/help/mps/ml_code/use-a-data-cache-to-persist-data.html
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .Select web site
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.