MOJA - Mobile Offloading for JavaScript Applications

0 downloads 0 Views 384KB Size Report
the web applications to cloud servers running Node.JS. The computation ... best energy savings possible under the mobile devices ... with selective offloading” [8], authors propose a ... and encoding, and also a natural way to deal with data.
ISSC 2014 / CIICT 2014, Limerick, June 26-27

MOJA - Mobile Offloading for JavaScript Applications Chaoran Xu, Yuansong Qiao, Brian Lee, Niall Murray Software Research Institute, Athlone Institute of Technology, Athlone, Ireland Email: {cxu, ysqiao, nmurray} @research.ait.ie, [email protected]

Abstract—There is an increasing growth of usage on mobile devices in this decade. However, the limited computation ability and energy weaken the performance as the web applications of mobile devices are more and more rich and energy-consumed. The development of cloud computing and mobile computation offloading technologies provides an opportunity for removing the limitations of mobile devices. This paper presents MOJA – a JavaScript offloading solution for web centric mobile applications based on WebSocket and Node.JS. The computing ability of mobile device is augmented by offloading the computational functions of the web applications to cloud servers running Node.JS. The computation results are sent back to mobile devices using the WebSocket technologies. Various experiments have been executed to validate the solution. The test results show that the proposed solution can significantly enhance the performance of mobile devices and provide a better Quality of Experience to end users. Keywords –Mobile Cloud Offloading, JavaScript Offloading, WebSocket, Node.JS, Mobile Apps

______________________________________________________________________________________

I INTRODUCTION With significant increase of mobile devices, e.g. smart phones and tablets, and the development of web application technologies, such as Rich Internet Application and Single Page Application, the functions of web pages are more and more complicated that leads to an embarrassing situation where the most mobile devices would consume more and more resources and energy for opening and running them while the battery lives of mobile devices hold back the performance and even user experience. As a consequence of the great needs for making mobile devices live longer and for providing high computation capabilities, the Mobile Cloud Computing has emerged. Mobile Cloud Computing combines mobile devices, mobile networks and Cloud Computing to dynamically outsourcing computation tasks from mobile devices to clouds. Mobile cloud computing can potentially benefit mobile users, network providers, and cloud computing providers by enhancing user experience and providing more business opportunities to providers [1]. Basically, mobile cloud computing aims at compensating the battery shortage and resource constraint of mobile devices by offloading computational functions inside mobile applications to computing servers in the cloud. The server side usually needs powerful machines with high computing abilities so that the results can be calculated and returned to the mobile device in a

shorter time. The network conditions, e.g. network latency, loss and bandwidth, would also be critical factors that affect the performance of the whole offloading process. Many solutions have been proposed to enhance web application performance on mobile devices. In the aspect of web browsers, the Opera Mini requests web pages through Opera Software’s servers, which process and compress them before sending them to the mobile phone, speeding up transfer by two to three times and dramatically reducing the amount of data transferred, also increasing compatibility with web pages not designed for mobile phones [2]. The Amazon Silk also routes user requests through remote proxy servers powered by Amazon Elastic Compute Cloud. These cloud servers provide high-performance connection speeds and computing powers that are not normally available to a mobile device [3]. In mobile cloud computing area, various solutions has been proposed, e.g. CloneCloud [4], ThinkAir [5], and MAUI [6]. Most of the solutions are designed for specific platforms. The paper focuses on web based technologies so that the solution can be applied to different mobile platforms. PIOS [7] proposes an offloading scheme for JavaScript. Normal JavaScript files are pre-processed by a proxy. Offloading functions are added into the files so that functions can be offloaded from mobile devices to servers. However, the detailed offloading mechanism

between the mobile device and the offloading server is not defined. This paper proposes a Mobile Offloading scheme for mobile JavaScript web applications (named MOJA). The JavaScript functions are serialized and transmitted to an offloading server via WebSocket. The offloading server runs the functions from the mobile devices by Node.JS and returns the results to the requesting mobile devices. The rest of the paper is organized as follows. Section II introduces Related Work. The MOJA design is described in Section III. Section IV shows the test results. The conclusions and future work is given in Section V. II RELATED WORK MAUI proposes a system that enables finegrained energy-aware offload of mobile code to the infrastructure [6]. It is a system that decides at runtime which methods should be remotely executed, driven by an optimization engine that achieves the best energy savings possible under the mobile devices current connectivity constraints. The MAUI system uses its code portability to create two versions of a web application for mobile devices, one for running locally on the mobile devices while another running remotely in the cloud server. Then the reflection and type safety parts identify those methods for offloading. After that, the profiling and serialization component would check the energy and CPU cost of those offloading before offloading to server. For this solution, the dynamic profiler is one of the important roles as the main decision for offloading according to the profiling consumption of energy and CPU on the mobile devices. However, the MAUI system uses Microsoft .Net Common Language Runtime as the code environments, which means it might lack of compatibility for the most web application. PIOS proposes a platform-independent offloading system, which is a delegated system for a mobile web environment [7]. This platform uses a proxy as Contents Adaptor for intermediate request from mobile clients. The Contents Adaptor recognises the offloading annotation in the web page and notifies generator to create a skeleton process for this offloading functions on the server while sends a lightweight modified web page to client. After this process, the performance of mobile client is increased as no more heavy computation. The process of proxy might be increased the time of performance and data transfer for mobile client. In this paper -- “Accelerating the mobile web with selective offloading” [8], authors propose a measurement-based framework that allows to offload portions of mobile page load process to the cloud. And this framework would be integrated in a mobile browser. To make this selective offloading working for acceleration, the framework focus on: reducing round trips, reducing time in computation, and consistency with other mobile constraints. But this

framework considers the offloading process from the browsers’ point of view as it is offloading the portion of page.

III THE OFFLOADING SCHEME DESIGN This offloading scheme is a web framework designed to offload the computational functions of web applications. It is targeted on the web applications of mobile devices. With the Websocket [8] technology, the client can offload chosen functions to the server and take the results from the server efficiently and reliably. The server side uses Node.JS [10] as the platform which executes the JavaScript code on the Google V8 engine. The MOJA architecture and high-level communication sequence is shown in Figure 1. The mobile device first sends HTTP requests to the web server to retrieve web pages and JavaScript files. Afterwards, it chooses the JavaScript functions which are able to be offloaded and sends these functions to the offloading server and receives the calculation results.

Figure 1: MOJA Offloading Scheme.

a) Offloading Server Design

Figure 2: Offloading Server Design

The offloading server in Node.JS uses the WebSocket-Node [11], which is the WebSocket implementation for Node.JS. The detailed design of the offloading server is shown in Figure 2. The WebSocket server is opened by the server.on() method which listening the request at the same time. Then the request is accepted by the server using the request.accept() method.After the acceptation, the message is sent by client side in the JSON format and the server parse the message as an object. The function part of the message object will be deserialized back to the normal function, which would be run in the server with the argument part of message. Then the result is also sent in JSON format to the client side. The message sent from client to offloading server uses the following format: For the first time offloading: { hassent //false, function // f1.toString() arguments // arg1, arg2, etc. } For the not first time offloading: { hassent // true function_name // f1.name arguments // arg1, arg2, etc. } The server stores these functions received from the client, so that the client only sends the functions at first time to the server and after that only sends the arguments. This design reduces the data exchange volumes between the mobile client and the offloading server.

b) Offloading Client Design The client side also implements with the WebSocket-Node client. It uses the JavaScript code to set up a connection with the offloading server. The detailed design of the offloading client is shown in Figure 3. Inside the client framework, it firstly checks whether this browser supports WebSocket before sending a request to the server. After getting the positive checking results, the request for connection will be sent by defining a new WebSocket() object within the argument of server’s host and its listening port. Then, the client converts the message object to JSON which includes the functions and parameters need to be offloaded. The reason for using JSON format is that it is leaner than XML or other format, fast for transaction and encoding, and also a natural way to deal with data in this environment due to its closed relationship with JavaScript.

Figure 3: Offloading Client Design

The client sends messages to the offloading server through the websocket.send() method. Once the computational functions are sent to the server, a flag is used to help the client remember that the functions have been offloaded so that next time only needs to send function parameters. After the server finishes computing and sends results back, the client receives the result messages by websocket.onmessage() method and encoding the message body before make use of it.

IV EXPERIMENT In order to show the performance and efficiency of this offloading scheme, various of experiments have been performed for different situations.

a) Test Setup Table 1 shows the specifications of the devices used in these experiments. The web application for test is the Bubble-Sort [12] application. The user input an integer number to define the size of the array need to be sorted. Afterwards, the application fills this array with random numbers ranging between 0 and the user input integer without duplicated. After sorting, the array will be displayed in the ascend order. The computation part of this application is the sorting function which consumes lots of resources in the RAM for comparison and swap of each number inside the array. In this case, the larger size of the array is, the more time and resource it will spend. Two test groups are executed. First test group is on the Android device. The size of the array which is input by user are 10, 100, 1000, 10000, and 100000. For each array size, the JavaScript functions are executed twice, i.e. running locally in the mobile device and running through MOJA. The second group

repeat the above tests for the IOS device. The test results are shown in the next section.

Table 1: Experiment Hardware Specification Platform

Server

PC

Samsung S2

Client

OS Ubu ntu 12.0 4 64B it And roid 4.1. 2

CPU Intel Core 2 Quad Q6600 2.40GH z

IOS 7.1

iPad 2

RAM

Software

4.00G B

Node.JS

DualCore 1.2GHz

1.00G B

Opera Mini

DalCore 1.0GHz

1.00G B

Safari

Figure 5 shows the server execution time and network transmission time while using MOJA. The blue line is the offloading server computing time and the orange one is the network transmission time. The figure shows that network transmission time for the first time (Array Size: 10) is higher than that of the second time (Array Size: 100). This is because the client needs to send the function body to the offloading server and afterwards the client only sends function name and its parameters. The results also show that the network transmission time is relatively high compared with the server computation time when the computation task is light.

1000000

b) Test Results Figure 4 shows the test results for the Android device. The blue line is local execution time while the orange line is the execution time using MOJA. All the time increases as the array size increases. The chart indicates the MOJA execution time is always less than the local execution time. The MOJA is roughly faster than the local execution about 1.5 times. Note: the result figures in this section are all using logarithmic scale.

Time (ms)

100000 10000 1000

100 10 1 1

10

100

1000

10000

100000

Array Size Local Execution

MOJA

Figure 6: IOS Device Test Execution Time

1000000

100000

100000

10000

Time(ms)

Time (ms)

1000000

10000 1000

1000 100

100

10

10

1 1

10

1 1

10

100

1000

10000

Localy Execution

Server Computing Time JSOM

Figure 4: Android Device Test Execution Time

1000000

Time(ms)

100000 10000 1000 100

10 1 1

10

100

1000

10000

100000

Array Size Server Computing Time

Network Transmission Time

Figure 5: MOJA Server Computation/Network Transmission Time for Android Device Test

1000

10000

100000

Array Size

100000

Array Size

100

Network Transmission Time

Figure 7: MOJA Server Computation/Network Transmission Time for IOS Device Test

The test results for the IOS device is shown in Figure 6 and 7. Figure 6 shows that the local execution time is higher than the execution time of MOJA except when the Array Size is small (10). This is caused by network fluctuations. The above test results show that the MOJA performance is affected by both network condition and the complexity of the computation task. For light computation tasks, local execution is preferred, whereas for heavy computation tasks, MOJA can improve performance significantly. Furthermore, a more powerful offloading server performs better. Another interesting phenomenon observed during the tests is that MOJA can provide a much better user experience than local execution. The mobile device does not response to user inputs during

the local execution phase because the device is busy calculating the function. Whereas in the MOJA computation mode, the mobile devices are very responsive to user inputs. This is because the event driven feature of JavaScript. After the functions have been offloaded to the server, the mobile device is ready to execute other functions. V CONCLUSION & FUTURE WORK This paper presents a platform independent mobile cloud offloading scheme for mobile web applications (MOJA). A detailed design for offloading JavaScript functions is proposed. WebSocket is employed to implement communications between the offloading client and server. Node.JS is used to run the offloaded JavaScript functions in the server. The design is validated through various experiments. The results show that MOJA can reduce mobile device load from different aspects: The calculation time of JavaScript functions are reduced significantly (apparently, more powerful servers provide better performance); The use experience is improved as the mobile device is more responsive to user inputs. Future work is to explore the effects of offloading on mobile energy and resource consumptions. Another research focus is to design an intelligent offloading decision algorithm to adaptively offload tasks based on the conditions of the mobile device, e.g. the battery and network status.

REFERENCES [1] Saeid Abolfazli, Zohreh Sanaei, Ejaz Ahmed, Abdullah Gani, Rajkumar Buyya, "Cloud-Based Augmentation for Mobile Devices: Motivation, Taxonomies, and Open Challenges", IEEE COMMUNICATIONS SURVEYS & TUTORIALS, Page 337 - 368, Volume:16, Issue: 1, July 2013. [2] Opera Mini, http://www.opera.com/mobile. [3] Amazon, “Amazon Silk”, http://docs.aws.amazon.com/silk/latest/develope rguide/introduction.html. [4] Byung-Gon Chun, Sunghwan Ihm, Petros Maniatis, Mayur Naik, Ashwin Patti, "CloneCloud: Elastic Execution between Mobile Device and Cloud", Eurosys 2011. [5] Sokol Kosta, Andrius Aucinas, Pan Hui, Richard Mortier, Xinwen Zhang, "ThinkAir: Dynamic resource allocation and parallel execution in cloud for mobile code offloading", Inforcom 2012. [6] E. Cuervo and A. Balasubramanian, “MAUI: making smartphones last longer with code offload,” Proc. 8th …, vol. 17, pp. 49–62, 2010. [7] H. Y. Yeom, “PIOS: A platform-independent offloading system for a mobile web environment,” 2013 IEEE 10th Consum. Commun. Netw. Conf., pp. 633–636, 2013.

[8] X. S. Wang, H. Shen, and D. Wetherall, “Accelerating the mobile web with selective offloading,” Proc. Second ACM SIGCOMM Work. Mob. cloud Comput. - MCC ’13, p. 45, 2013. [9] WebSocket.org, http://www.websocket.org. [10] Node.JS, http://nodejs.org/. [11] WebSocket-Node, http://github.com/Worlize/WebSocket-Node. [12] Wikipedia, “Bubble sort”, http://en.wikipedia.org/wiki/Bubble_sort.

Suggest Documents