the performance effects of memcached and json ...

5 downloads 98586 Views 3MB Size Report
Php (Personel Home Page) is a script programming language that can be embedded on html and working on apache web server. It has widely usage area in ...
Gediz University

3rd International Symposium on Computing in Science & Engineering

THE PERFORMANCE EFFECTS OF MEMCACHED AND JSON TECHNOLOGIES ON WEB PROJECTS Murat Tanrıöver, Mahmut Çetin, Ali Buldu, and Kazım Yıldız Marmara University, Turkey {[email protected], [email protected], [email protected], [email protected]}

ABSTRACT

languages. Its usage is very simple and it can form dynamic web projects rapidly. Mysql is relationally data base server system working on Linux. It works adaptable and fast with Php. It has Phpmyadmin interface and data base processes can be easily performed via that interface (Mysql, 2013). Even though php with mysql work very fast and adaptable, there can be some slowness in project depending on the busyness on the server. This slowness is stemming from the high instant data flow, weakness of server properties, and useless encodings on the software. In order to prevent these situations, cache mechanisms can be used depending on the project structure. Cache mechanisms are used to reduce the data density on project data base. The main purpose is to take data base traffic by getting some part of data intensity from the data base to the cache mechanism. Apc cache, memcache, file cache are the examples for these mechanisms (Bilgisayarkavramları, 2013). In this Project memcache mechanism that keeps the data on main memory was used. Mysql data base keeps data on hard disk whilst memcache mechanism keeps them on main memory. Due to the computer architecture, data from main memory are faster that from hard disk, thus a performance increment will be provided. The structure in this project was constructed considering these properties.

The main limitation of web projects with intense data flow is the inadequacy of resources. The project owners in that positions increase the resources by making big investments. With this project, it was aimed to reduce the resource expenditures of the project owners by making minimum the resource consumption. Additionally, removing the loss of prestige which is stemming from the slowness of the project was aimed. In the project, a technique was formed based on data taking from data base with memcache to the cache memory in json format, and allowing to the next interrogations making in cache memory instead of data base usage. Thus the intensity on data base will be reduced to the minimum level. Performance increment will be obtained by getting datas from data stores rapidly instead of data bases. The process of encoding with Php and mysql will be told and the obtained performance results will be investigated. Furthermore, access to these data will be provided and dynamic sites will be formed with javascript as a result of being formed a web service producing outputs in json format. Debian operation system is installed on the testing server; also nginx web server and memcached are existing on the testing server.This project was accomplished via a common data base which composes the content of more than one web site. It will be unnecessary for the other usage purposes.

KEYWORDS Performance on web sites, Dynamic structure with JavaScript, data store in memcached.

1

2

In this study, the Project functions as follows.  Server settings are made then nginx, memcached, mysql, php5, memcache applications are set up with options (Library, 2013) .  Pages, activities, announcements are held site basis in databases as the slides  Questioning of the site by domain name.  Dynamic data on the site is withdrawn from database if it wasnt found on cache, then convert it to json format and is taken to cache.  The web page is created in accordance obtained data with the format of web browser.

INTRODUCTION

Php (Personel Home Page) is a script programming language that can be embedded on html and working on apache web server. It has widely usage area in web projects. Its usage area is progressively widening and improvements are extensively carried out. Today, it composes so many web projects and the most important property is being fast comparing to the other languages. It provides a great flexibility in web projects because of being embedded in html (Php, 2013). Php composes a rapid data flow with mysql data base. Thus, it has better performance than the other

ISCSE 2013 (http://iscse2013.gediz.edu.tr)

FUNCTIONS OF PROJECT

58

October 24-25, 2013, Kuşadası, Aydın, Turkey

Gediz University

3

3rd International Symposium on Computing in Science & Engineering

INFRASTRUCTURE PROJECT

4

3.1 AJAX (Asynchronous JavaScript and XML)

ORGANIZATION CHART

In figure 1 the organization chart can be seen.

Ajax, is the name of the technique that created interactive applications with the use of JavaScript and XmlHttpRequest on web pages. As Turkish that means asynchronous JavaScript and xml. Without reloading the page, the page allows you to make transactions through making dynamic queries (Wikipedia, 2013a).

3.2 JSON (Javascript Objects Notation) It is a programming language that is used to store data that is easy to use. While smaller size of data flow, transfer time of the data is small (Wikipedia, 2013b). Most web projects are used with JavaScript. It also frequently utilized in applications developed for smart phones. The use of example as below: {"pages": [ {“id”:1, "title": “Hakkımızda", "content": “Hakkımızda sayfası”}, {“id”:2, "title": “Hizmetlerimiz", "content": “Hizmetlerimiz sayfası”}

Figure 1: Organization chart of project

The steps from figure 1 could be described below in detail.

4.1

3.3 MEMCACHED

It will show the data in accordance to design from Application. Website’s content part was formed at this stage. The data that is used taken from Application and enabling to display on the page that is controlled with php.

It is high performance server system running through TCP/IP as an open source. Memcached was recorded continuous data to memory areas and the flow of data take place very quickly. Data Exchange process is performed 11211 port as default and the data that was added through identified period, stored in the memory areas that we have identified (Yılmaz, 2013). Data that is passing determined the amount of time will be automatically deleted. Installation of this is very simple. The following code is applied for the installation of memcached end unit on Debian server (HowtoForge, 2013):

4.2

JAVASCRİPT VIEW

In this section Php are used only as a guide. JavaScript with the help of Jquery Ajax pulls out related dynamic services as json format from Application. The data is captured as json format that is processed with JavaScript is created in HTML tags. So a dynamic structure is provided with JavaScript.

apt-get install memcached

4.3

3.4 MEMCACHE

APPLICATION

Application is a section that links of web page. It is a section that produces output for display all referrals, queries, modules. It process information that coming out of the url link, which allows to display the requested page rendered by setting required variable and data.

Memcache, is a PHP library that is processed on memcached server. This software's library allows users to data exchange and other operations connect to mamcached server (Yılmaz, 2013). We applied the following codes to set up memcache library server (HowtoForge, 2013):

4.4

apt-get install php5-memcache

CONTROLLER

Controller in charge of returning the requested withdrawal data in JSON format. First the data wants to be obtained with the help of the memcache and see if the data memory area:

apt-cache search memcache

ISCSE 2013 (http://iscse2013.gediz.edu.tr)

PHP VIEW

59

October 24-25, 2013, Kuşadası, Aydın, Turkey

Gediz University

3rd International Symposium on Computing in Science & Engineering

If not, goes to Web Service and the relevant data is drawned from databases. Drawned data translates to json format and store to memory area with the help of memcache for future use. It returns data as json format to application the next stage. If it is, without connection to the database it returns the data from memory area as json format with the help of memcache. Here is an example of the encoding used to draw the pages on the website. static public function pages($id = NULL) { $cacheName = (is_null($id)) ? "pages" : "pages_" . $id; $cache = mem_cache::get($cacheName); if (empty($cache)) { $pages_json = json_encode(web_service::getPages($id)); mem_cache::set($cacheName, $pages_json); return $pages_json; } else { return $cache; } } Figure 3: Site view that is created with Javascript View

4.5

DESIGN OF PROJECT In table 1 the numbers of requests are shown that which withdraw from cache memory.

The designed trial web page’s loading time for testing project is shown in figure-2 and figure 3. The study was developed with javascript view of the application is more effective.

Table 1: The load time for number of requests (second) Number of Cache Memory Database(Second) Request (second)

Figure 2: Site view that is created with PHPVIEW

ISCSE 2013 (http://iscse2013.gediz.edu.tr)

60

1

0,00449800

0,00730600

2 3 4 5 6 7 8 . . . 1491

0,00462000 0,00463200 0,00467100 0,00555600 0,00474600 0,00648300 0,00467400 . . . 0,00438100

0,00757300 0,00771000 0,00741100 0,00788200 0,01040200 0,00751800 0,00728400 . . . 0,00781000

1492

0,00466100

0,00801100

1493

0,00468400

0,00726400

1494 1495 1496 1497 1498

0,00457000 0,00451100 0,00503500 0,00439300 0,00442700

0,00739300 0,00794700 0,00720400 0,00784000 0,01092800

1499

0,00465200

0,00747700

1500

0,00464200

0,00746700

October 24-25, 2013, Kuşadası, Aydın, Turkey

Gediz University

3rd International Symposium on Computing in Science & Engineering

Average page load time can be seen that withdraw from cache memory and database. The performance of this %60 averagely.

2013. Mysql Hakkında [Online]: http://www.mysql.com.tr/tr/KonuDetay.php? BKey=34. [Accessed 3 April 2013]. Bilgisayarkavramları. 2013. Caching Mekanizmaları [Online]: http://www.bilgisayarkavramlari.com/2012/1 1/07/caching-mekanizmalari/ [Accessed 6 April 2013]. Library, L. 2013. Nginx and PHP-FastCGI on Debian 6 [Online]: http://library.linode.com/webservers/nginx/php-fastcgi/debian-6-squeeze [Accessed 10 April 2013]. Wikipedia. 2013a. Ajax (programming) [Online]: http://en.wikipedia.org/wiki/Ajax_(programm ing). [Accessed 2013 2013]. Wikipedia. 2013b. JSON [Online]: http://en.wikipedia.org/wiki/JSON [Accessed 15 April 2013]. Yılmaz, S. 2013. Memcached ve memcache nedir [Online]: http://www.seyhanyilmaz.com/yazilim/webprogramlama/php/memcachephp/memcached-ve-memcache-nedir [Accessed 21 April 2013]. Howtoforge. 2013. Install Memcached And PHP5MemCached Module On Debian 6.0 [Online]: http://www.howtoforge.com/installmemcached-and-php5-memcached-moduleon-debian-6.0-squeeze. [Accessed 21 April 2013]. Mysql.

Table 2: Average Page Load time and percent of performance for cache and database Database Cache (Second) (Second) Average Page 0,00492214 0,00823815 Load Time Percent of %59,748165 performance In figure 4 cache memory and database average load time are shown.

Figure 4: Graphical representation of the site for loading times

5

CONCLUSION

In this application, we examine the performance impact of the case if the data si so much in the database. For small-sized data sets would not be major changes in performance. On average, a %59 performance increase is seemed for site loading times. This ratio may vary based on several factors. For example, the amount of RAM in the server area is of great importance. Low memory area may negatively impact the performance of the servers to this process. It allows creating dynamic pages with JavaScript for interface coders because of using json format. So without the need for the programmer dynamic pages can be created.

REFERENCES Php.

2013. Php Nedir [Online]: http://php.net/manual/tr/intro-whatis.php [Accessed 3 April 2013].

ISCSE 2013 (http://iscse2013.gediz.edu.tr)

61

October 24-25, 2013, Kuşadası, Aydın, Turkey