Optimization Of Scilab Instances On Server

The project is about optimizing http://cloud.scilab.in/ to reduce total response time experienced by users after hitting execute button. In existing implementation, a scilab instance is created for each user request which loads all scilab libraries in the background while executing the script from the website. All Users experience delay to get output due to the load time required for these libraries. Scilab instances are terminated after the execution is completed.

The major idea of this project was to avoid the creation of scilab instance and hence load scilab libraries for each user request. The proposed solution was to have running scilab instances available to cater to user’s requests. The implementation of proposed solution was achieved via the two stages given below.

Stage1: We kept the scilab instances alive and running in the server using pexpect. Pexpect is a pure python module. Loading of scilab instances for each request is being avoided by using pexpect.

Stage2: Creation of additional Scilab instances are done dynamic based on the load on the server. If the load on the server is low, the only minimum number of scilab instances are made available to run scripts. Here is an example to explain the scenario, suppose 4 scilab instances are available and all these 4 are busy then a new request comes from a user. In this case, proposed implementation spawn (create) new scilab instance and assign it to the new request. The server can now handle 5 requests at a time. This process goes on until a fixed scilab instances indicating maximum allowed number of instances are being spawned. This number is set based on hardware availability of the server. What happens in the case when there are no users accessing the website?

Well, in cases like this, many of the active scilab instances are residing in the server without any work. We implemented an infinite thread (method) running in the back end to check the number of scilab instances working in the server and the number that are idle. This method then kills the scilab instances which are not working and does the same for the next interval as well. This process goes on until there is only one scilab instance in the server because we are assuming that anytime any user can access our website. This way the memory efficiency and speed are achieved in our project.


Mentor’s View

It was a great pleasure to know and work with my interns Divakar, Meghana and Sumanth. They achieved the project objective of optimizing code execution on http://cloud.scilab.in/ with an overall decrease in execution time and improve execution efficiency on the server. I would also like to thank the Python team at FOSSEE, especially Ankit J and Mahesh Gudi for their timely feedback and ideas on the project.

-Arun KP (Project Research Engineer, FOSSEE, IIT Bombay)


FOSSEE intern:

“IIT Bombay changed my life. This ekalavya camp for interns should continue and putting more open source projects is helpful.”

-Sumanth Pole (Rajiv Gandhi University of Knowledge Technologies)