×
Community Blog How to Manually Setup MATLAB Production Server on Alibaba Cloud

How to Manually Setup MATLAB Production Server on Alibaba Cloud

In this tutorial, we will be provisioning necessary resources to set up a MATLAB production server on Alibaba Cloud.

By Rohit Kumar, Alibaba Cloud Solutions Architect

Overview

In this document, we will attempt to set up a MATLAB Production Server on Alibaba Cloud using Elastic Compute Service (ECS) instances. We will be provisioning necessary instances, getting MATLAB Production Server License from MathWorks website and then activating the license server. We then connect the worker machine to access license from License Server as per the MathWorks specification to test run a small application.

MATLAB Production Server is one of the flagship products for MathWorks and is used by many organizations and research institutions for custom analytics into the web, database and enterprise applications running on dedicated servers. User can create algorithms in MATLAB, package them using MATLAB compiler and then deploy them into MATLAB Production Server (MPS) without recoding or creating custom infrastructure. MATLAB Production Server can manage multiple MATLAB Runtime version simultaneously and so algorithm developed in different versions of MATLAB can be incorporated in your application simultaneously.

While many of our competitors have a partnership with MATLAB for deploying an MPS environment in the cloud, Alibaba Cloud does not have a solution for installing MPS on the cloud. Moreover, as the software is attached to MAC address of the machine on which it is used and needs to have a MathWorks, it can be a mammoth task for end-user to use MPS on Alibaba Cloud.

The server runs on multiprocessor and multicore computers, providing low-latency processing of concurrent work requests. You can deploy the server on additional computing nodes to scale capacity and provide redundancy. For our case, both the license server and worker server will be deployed on Alibaba Cloud ®C Elastic Compute Service (ECS), which is great for these applications as the cloud instances can provide fast and dedicated CPU performance for MATLAB applications. Alibaba Cloud's networking configurations can also provide a good way to keep license server and worker machine access to each other while still secured in different security groups.

Provision Alibaba Cloud ECS Instances

1. Provision a Windows 2012R2 ECS instance from Alibaba Cloud which would act as MPS License Server.

Follow the instructions in this article to create an Alibaba Cloud ECS instance.

Please take note of the Internet IP Address and private IP address of the MPS License server (in this case 47.254.184.123 and 192.168.0.100 respectively). We will be connecting to the server using Remote Desktop Connection with the Internet IP Address.

Create another Windows 2012R2 ECS instance for the MPS worker node which would be running the MATLAB application and accessing the license from the license server. Keep both the machine in the same VPC.

2. Configure the Security Groups

Make sure the Security Group that the Server instance belongs to accepts incoming port 3389(RDP), 27000(License Manager port for MPS) on both the machine and port 50987 on the license server for accepting incoming connections from worker node for license access.

MathWorks Account and License Activation

1. Apply for trial license

MATLAB Production Server license can be obtained from MathWorks website on a trial basis by opening an account on MathWorks website from the below link. MPS license is issued for a machine and is supplied based on the Host ID (MAC address) of the machine.

Once you have registered an account on MathWorks website, you need to provide the mac address details of the intended license server machine. After that you MathWorks will send you your license activation email. The email would contain a license.lic file which would be required for the license server activation.

1

2. Activate the license on MathWorks website

  1. Visit the License Center at the MathWorks website.
  2. Select the license to activate.

2

  1. Select the Activation and Installation tab and click Activate.

3

Install License Server

1. Download the License Manager from MathWorks website.

4

2. Setup license Manager on the License Server node

Copy the downloaded file in step 3 to a folder MPS_LM in C Drive of the License Server. Also copy/download the license.lic file received in the email (Section 3, step 1) to this directory. We would need this when we set up license server access from the worker node.

Install MATLAB Production Server

1. Download MPS from the MathWorks website.

2. Install the MPS on the worker node. Double click on the downloaded MPS file downloaded in step 1. It will ask you to provide MathWorks account credentials or File Installation key. Select 'Login with a MathWorks Account' and click next to accept the agreement and enter your login credentials.

5

6

3. Once the login credentials are accepted, select install, click next and then select the available license from the screen. Click next and select the installation directory and click next. The default directory is C:Program FilesMATLABMATLAB Production ServerR2018a.

7

4. On the next screen, select only MPS Server as we have already installed a License Server on a different node and click next.

8

5. Download the license.lic file received in the email (Section 3, step 1) and provide the path of the directory on the next screen of installation. This will start the MPS installation.

9

6. Add the $MPS_INSTALLscript folder to your system PATH environment variable.

$MPS_INSTALL represents your MATLAB Production Server installation folder.

Install MATLAB Runtime

  1. Download MATLAB Runtime from the MathWorks website.
  2. Double click on the file downloaded in the step above. Click next on the screen and accept the software license agreement.
  3. Choose the installation folder. The default folder is C:Program FilesMATLABMATLAB Runtime and click next. This will install the MATLAB Runtime in the target directory

Setup License Access on License Server from Worker Node

1. On the License Server, go to C:MPS_LM directory and open the licnese.lic file and add the following lines to it.

SERVER $Hostname $HostID 27000
DAEMON MLM "C:\MPS_LM\mlm.exe"

In the above code, $Hostname is the server's hostname, $HostID is the MAC address (without hyphen) that you used to activate the license.

2. On the License Server, go to C:MPS_LM directory and double click on lmtools. Keep 'Configuration using services' option selected.

10

3. Go to 'Config Services' tab and edit the following entries (if not already)

  1. Path to the lmgrd.exe file: C:MPS_LMlmgrd.exe
  2. Path to the license file: C:MPS_LMlicense.lic
  3. Path to the debug log file: C:ProgramDataFNP_DIRdebug.log and click on 'Save Service'.

11

  1. Click on 'Start/Stop/Reread' tab and then click on 'ReRead License File'. Once that is done, click on 'Start Server' to start the license server.
  2. If you have a valid license file, you can then go to the Server Status tab and perform a status enquiry to check if the license server is functioning correctly.

12

Section 8 ®C Create and configure an MPS server instance

1. On the worker node, move to the folder where you want to create your server. In our case, it is a 'tmp' folder in our C drive.

C:\>cd C:\tmp

2. Start a server instance using the mps-new command

C:\> mps-new prod_server_1 -v

3. Verify the output.

13

4. To configure the server instance, run the mps-setup command and follow the directions to specify which MATLAB Runtime this instance would use. Once confirmed, you will see the message below that MPS server is successfully installed.

14

5. Move to the config directory of newly created server instance and open the main_config file. For us, it is located in C:tmpprod_server_1config.

6. Search for '®Clicense' option in the main_config file and replace it with the below line. IP_address_of_license_server can be private IP address if public IP address does not work.

--license 27000@IP_address_of_license_server

Search for '--cors-allowed-origins' option in the main_config file and replace it with the below line. It is the list of origins that are allowed to access MPS and can also be a list if all origins (*) is a security concern.

--cors-allowed-origins *

Start the Server

1. Run the mps-start command.

mps-start -C C:\tmp\prod_server_1

2. Verify the server instance has started using the mps-status command.

mps-status -C C:\tmp\prod_server_1

Testing It Out!

MATLAB Production Server applications are just MATLAB functions with a RESTful API. For the convenience of testing if client and server can talk to each and MPS is ready to run applications, I have attached a readymade application. This example uses a webpage with JavaScript to call MPS functions. To test the example, please follow the steps below.

  1. Start the MPS server with mps-start.
  2. Drop the ctf file into the auto_deploy folder of the mps (For our case, it is C:tempmps1auto_deploy).
  3. Open the web page in a browser on the worker machine
  4. Click 'getImage' and if a graph appears in the page, then the MPS is working.

Conclusion

MATLAB Production Server is a high-level analytics software and is used by various research institutes and engineering companies and used for various AI/ML applications. It is usually quite time consuming and tough to deploy MPS on Alibaba Cloud. A user still needs to open a MathWorks account and do necessary security group configurations (port opening) for license server and worker node communication for license access. Though License Server and MPS worker both can be on the same node, but it helps to have a license server separately when we need more than one worker nodes. Above steps can be easily replicated to deploy a single license server and multiple worker nodes accessing license information from it.

Section 12 ®C Further Readings/Next Steps

As many of our competitor offer IaaC scripts to deploy MPS on the cloud, I would cover that in a different document on how to create a ROS script, generic license server and worker node machine images, which does not require license information at the time of MPS deployment, and how to activate license information once the deployment is ready.

1 0 0
Share on

Rohit Kumar

3 posts | 0 followers

You may also like

Comments

'"><SVg> May 14, 2020 at 1:43 pm

11111">

Rohit Kumar

3 posts | 0 followers

Related Products