This topic explains distributed processing on multiple machines using RaSC. As the distributed processing is performed using a virtual machine in this tutorial, install the followings in advance:
In addition, install the following to set up RaSC services on virtual machines:
This section explains configuration for distributed processing shown in the figure below. The node called worker corresponds to a RaSC service that performs a process to be executed in parallel. Each aggregation server executes multiple workers in parallel, and aggregates the results. And, the load balancing server distributes requests to multiple aggregation servers by a round robin method, etc.
In this example, we use a RaSC service SampleSearchWorker as a worker, which obtains environment variables of deployed computers. We also use SampleSearchServer as aggregation server, which aggregates and returns the results from multiple SampleSearchWorkers. These services have the common interface SampleSearchService. [1]
Prepare virtual machines, using VirtualBox and Vagrant. By the following commands, you can download the image of a virtual machine and start the virtual machines:
$ mkdir rasc_parallel && cd rasc_parallel
$ wget https://alaginrc.nict.go.jp/rasc/resources/Vagrantfile
$ vagrant box add RaSC_Ready https://alaginrc.nict.go.jp/rasc/resources/rasc_ready.box
$ vagrant up
These commands start virtual machines of 192.168.33.11 to 192.168.33.17.
First, clone the repository at GitHub.
$ git clone https://github.com/nict-wisdom/rasc.git
The deployment script for distributed processing is found in rasc_deployer/ in the repository. This example uses the setting file tutorial_parallel.properties. You can find important settings in sections services, workers, servers, and proxyserver. The following introduces each section briefly.
In the services section, the services to be deployed should be described. The following example assumes that the implementation of the aggregation server is SampleSearchServer (jp.go.nict.isp.webapps.samplesearch.server in the repository), the implementation of the worker is SampleSearchWorker (jp.go.nict.isp.webapps.samplesearch.worker in the repository), and the interface for each service is jp.go.nict.isp.wisdom2013.api.samplesearch.SampleSearchService.
[services]
servicesdef={
"samplesearch" : { "server" : {"path" : 'jp.go.nict.isp.webapps.samplesearch.server' , "name" : "SampleSearchServer" } ,
"worker" : {"path":'jp.go.nict.isp.webapps.samplesearch.worker' , "name" : "SampleSearchWorker" } , "timeout" : 60000 , "rewriteEndpoint" : True ,
"interface" : "jp.go.nict.isp.wisdom2013.api.samplesearch.SampleSearchService" , "msgpackPort" : 9011 } }
The workers section describes the nodes to which each worker will be deployed, and the port, start script, and communication protocol for the worker.
[workers]
workers={ "workers1" : { "host" : [("192.168.33.", 11, 12)] , "port" : 8080 , "services" : "all" } ,
"workers2" : { "host" : [("192.168.33.", 13, 14)] , "port" : 8080 , "services" : "all" } }
scripts.start=jp.go.nict.langrid.webapps.jetty.embedded/scripts/RunAllWorker/start_runallworkers.sh
scripts.stop=jp.go.nict.langrid.webapps.jetty.embedded/scripts/RunAllWorker/stop_runallworkers.sh
worker.servicetype=msgpackRPC
Similarly, the servers section describes the nodes to which each aggregation server will be deployed, and the port, start script, and communication protocol for the server.
[servers]
servers={ "server1" : { "host" : [("192.168.33.", 15, 15)] , "port" : 8080 , "workers" : ["workers1","workers2"] , "services" : "all" } ,
"server2" : { "host" : [("192.168.33.", 16, 16)] , "port" : 9090 , "workers" : ["workers2","workers1"] , "services" : "all" }}
scripts.start=jp.go.nict.langrid.webapps.jetty.embedded/scripts/RunAllServers/start_runallserver.sh
scripts.stop=jp.go.nict.langrid.webapps.jetty.embedded/scripts/RunAllServers/stop_runallserver.sh
server.servicetype=jsonRPC
The proxyserver section describes the node to which the load load balancing service will be deployed, and the port, start script, and communication protocol for the server.
[proxyserver]
proxy={ "host": [("192.168.33.", 17, 17)] ,"port" : 8080 }
scripts.start=jp.go.nict.langrid.webapps.jetty.embedded/scripts/start_proxy.sh
scripts.stop=jp.go.nict.langrid.webapps.jetty.embedded/scripts/stop_proxy.sh
target.project=jp.go.nict.ial.webapps.wisdom.proxy
proxy.servicetype=msgpackRPC
As these settings are consistent with configuration of the virtual machines which are already started, run the deployment script with Fabric as shown below. The deployAllservers, deployAllworkers, and deployproxy tasks build the workers, aggregation servers, and load balancing server, and deploy them to their corresponding virtual machines. After that, startAllservers, startAllworkers, and startproxy tasks start them on the virtual machines.
$ cd rasc/rasc_deployer
$ eval `ssh-agent` && ssh-add ~/.vagrant.d/insecure_private_key # for authentication
$ fab config:'tutorial_parallel.properties' deployAllservers -u vagrant # specify user name on virtual machine
$ fab config:'tutorial_parallel.properties' deployAllworkers -u vagrant
$ fab config:'tutorial_parallel.properties' deployproxy -u vagrant
$ fab config:'tutorial_parallel.properties' startAllservers -u vagrant
$ fab config:'tutorial_parallel.properties' startAllworkers -u vagrant
$ fab config:'tutorial_parallel.properties' startproxy -u vagrant
Access the following addresses from your Web browser:
At any of the above addresses, you can open a page to call a relevant RaSC service from the Web browser. Click + on the right end of the method getValues. Enter the request in the input area for a parameter as follows:
[{"envName":"HOSTNAME"}]
You can get the environment variable HOSTNAME from each virtual machine by this request. Each aggregation server returns the hostname of the node for the worker it is connected to. As the load balancing server uses two different aggregation servers, the result changes every time you send the request.
[1] | The implementations for the aggregation servers and workers used in this example are found in the projects jp.go.nict.isp.wrapper.samplesearch.server, jp.go.nict.isp.wrapper.samplesearch.worker, jp.go.nict.isp.webapps.samplesearch.server, and jp.go.nict.isp.webapps.samplesearch.worker registered in GitHub. |