How to Run MATLAB Production Server in the Cloud with Microsoft Azure
Learn how to get MATLAB® Production Server™ up and running in Azure with the help of a reference architecture. This reference architecture provides templates that use preconfigured AMIs to create the necessary MATLAB Production Server and license server virtual machines, helping you get running in less time. Incorporate MATLAB analytics into enterprise, web, and mobile applications with MATLAB Production Server. The elasticity of the Azure infrastructure combined with MATLAB Production Server enables your application to support many users simultaneously.
In this video I will show you how to run MATLAB® Production Server™ on Microsoft® Azure using the MATLAB Production Server reference architecture.
This is one of several reference architectures to help you get up and running with MATLAB on the cloud.
This reference architecture contains all the components necessary to run MATLAB Production Server on Azure:
The ARM (or Azure Resource Manager) template deploys:
- A virtual network
- A virtual machine that acts as the license server and cloud console server
- By default 2 x virtual machines that run MATLAB Production Server in a scale set (although this can be changed during configuration)
- An application gateway that acts as a load balancer
- A storage account for log files
We’ll get started by navigating to the Github repository for the MATLAB Production Server reference architecture. This page has the detailed instructions that are used for this video. Before getting started, make sure you have the following:
- Microsoft Azure account
- A MathWorks account
- MATLAB Production Server License
Once you have these, we can get started. Click the “Deploy to Azure” button to begin the process. Note that you have the choice to deploy either to Windows or Linux VMs.
Sign in to your Azure account if prompted.
You will be taken to a page in the Azure Portal where you can customize your deployment parameters:
- First, select your subscription.
- Next, select an existing resource group or create a new one. I will create a new resource group so that my resources are kept separate from other projects I may be working in. Using a separate resource group also makes it easier to delete your deployment later.
- Then select a location for your deployment.
- You will then be asked to choose a VM instance size. This is the size of the machine that is running Production Server. We have provided a reasonable default choice of a 4 vCPU machine. You want to make sure your instance size is sufficient to run your workload. We recommend 1 vCPU and 2GB RAM per worker process. Refer to the MATLAB Production Server documentation for more details on system requirements.
- Instance Count indicates how many of the VMs you wish to run in your deployment. The default is 2 to provide some degree of high availability, but you can change the count to any number you wish, as long as you keep your worker count below the number you have licensed.
- Next, specify the admin username and password for the cloud administration console. Write these down so you don’t forget.
- Finally, enter a CIDR or IP address range for clients that can connect to your Production Server deployment. This helps to secure your servers by restricting access to only those clients from these address ranges. 188.8.131.52/32
- Then check the box to agree to the terms and conditions, and click the Purchase button. You will be billed by Azure for the resources consumed.
Azure will begin deploying your resources. This will take about 30 minutes, so be patient.
Once the deployment has successfully completed, obtain the cloud console IP address from the servermachine-public-ip resource and enter that IP address into your browser. You may receive a warning message from your browser about visiting an unsecure site. This is due to the use of a self-signed certificate. You can change the self-signed certificate to a CA-signed certificate to eliminate this error. Details on how to do so are found in the GitHub repository.
Log in using the username and password credentials you specified earlier.
The cloud console shows you the current status of your Production Server deployment. We specified two VM instances earlier; each one of those instances is running four MATLAB workers, giving us a total of eight workers. A typical Production Server license contains 24 workers, so you can scale up to six VM instances.
The URL endpoint to call the functions from your client application is displayed prominently on the cloud console.
The first thing we need to do is get the Host ID or MAC address of the license server. We will need this to generate our license. At the cloud console, go to the Administration tab and choose ”Manage Licenses.” Provide the License Server Host ID to your sales rep if you are obtaining a trial license. Otherwise, provide the HostID to your license administrator, who has access to the MathWorks License Center to generate a license file.
Once you receive the license file (usually with a .lic extension), select the file from the File Open dialog and then upload the file.
The license log file should show that two instances of MATLAB Production Server are checked out, each with four worker licenses like we specified.
You are now ready to upload a Production Server application. We will go to the Applications tab and click on “Upload Application.” Production Server applications are packaged using MATLAB Compiler SDK in a .ctf file. Let’s upload a BondTools .ctf from the \for_redistribution folder of the project.
Once the application has been uploaded, you can call its functions from your front-end client. In this example we have a web-based front-end client app that is calling the Bond tools function we just uploaded to get the price of the bond. The web front-end client app captures the input data in the fields, packages it into JSON payload, and makes a REST call to the Production Server endpoint. The endpoint is found on the Home page of the cloud console. Append your ctf name and function name to form the URL to call.
You can manage Production Server configuration from the cloud console by going to Administration -> Manage Server configurations and modifying the configuration flags.
If you need to support additional users, you can scale up the number of virtual machines by either manually increasing the scale set size or enabling autoscaling.
If you no longer need to run MATLAB Production Server in Azure, delete the entire resource group, which will remove your all the components in your deployment.
Be sure to check out the Github repository for more detailed instructions.
To learn more about using MathWorks on the cloud, go to mathworks.com/cloud.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.