Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System...

59
Optimization of LMS for Improving User Response Time M.Tech Dissertation Report Submitted in partial fulfillment of the requirements for the degree of Master of Technology by B. RAJU Roll No: 123050091 under the guidance of Prof. Deepak B. Phatak Department of Computer Science and Engineering Indian Institute of Technology, Bombay Mumbai June 2014

Transcript of Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System...

Page 1: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Optimization of LMS for Improving UserResponse Time

M.Tech Dissertation Report

Submitted in partial fulfillment of the requirements

for the degree of

Master of Technology

by

B. RAJU

Roll No: 123050091

under the guidance of

Prof. Deepak B. Phatak

Department of Computer Science and EngineeringIndian Institute of Technology, Bombay

Mumbai

June 2014

Page 2: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Dissertation Approval Certificate

Indian Institute of Technology, Bombay

The dissertation titledOptimization of LMS for Improving User Response Time

submitted by

B.RAJU

(Roll No. 123050091)

is approved for the degree of

Master of Technology in Computer Science and Engineering

Prof. Deepak B. Phatak Prof. Ganesh RamakrishnanDept. of CSE, IIT Bombay Dept. of CSE, IIT BombaySupervisor Internal Examiner

Mr. Avinash Awate Prof. Uday N. GaitondeExternal Examiner Dept. of ME, IIT Bombay

Chairperson

Date: 23 June 2014Place: IIT Bombay, Mumbai

1

Page 3: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Abstract

Moodle is one of the LMS, which is an Open Source. Moodle has serious performanceissues where number of participants attempting quiz at same time or collecting feedbackfrom participants, etc,. The entire optimization was tested on load testing moodle system,identifying bottleneck and removing bottlenecks. The major bottleneck while performingload testing was acquiring DBMS lock to update the moodle sessions table. The majorproject aim to come up with alternative logging strategy so that session update informationis inserted as new record. And deletion is done in bulk so that the logging process worksfaster.

Page 4: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Acknowledgements

I am highly indebted to Prof. Deepak B. Phatak for his guidance and constantsupervision as well as for providing necessary information regarding the project & also fortheir support in completing the project. Without his guidance and persistent help, I amafraid, this dissertation would not have been possible. I would also like to thank Mr.Nagesh Karmali for his valuable inputs. i would like to express my gratitude towardsMr. Abhilash(DBP Moodle Admin), Sheweta(Project Staff), Silpa(Project Staff) fortheir valuable support and suggestions. Due to their consistent encouragement and rightdirections, I am able to contribute better to this project work. Lastly, I would like to thankFiruza, Srinu, Sheweta, Silpa for proof reading this report and providing their valuablefeedback.

Page 5: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

DeclarationI declare that this written submission represents my ideas in my own words and where

others ideas or words have been included, I have adequately cited and referenced the orig-inal sources. I also declare that I have adhered to all principles of academic honesty andintegrity and have not misrepresented or fabricated or falsified any idea/data/fact/source inmy submission. I understand that any violation of the above will be cause for disciplinaryaction by the Institute and can also evoke penal action from the sources which have thusnot been properly cited or from whom proper permission has not been taken when needed.

B.RAJU(123050091)

Page 6: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Contents

1 Introduction 31.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Learning Management System . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2.1 LMS Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3 Moodle LMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.3.2 Moodle as Modular System . . . . . . . . . . . . . . . . . . . . . . . 61.3.3 Developers perspective . . . . . . . . . . . . . . . . . . . . . . . . . . 71.3.4 Standard Moodle Functionalities . . . . . . . . . . . . . . . . . . . . 7

1.4 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.5 Moodle Three Layer Architecture . . . . . . . . . . . . . . . . . . . . . . . . 111.6 Moodle Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.6.1 Tables in Moodle Database . . . . . . . . . . . . . . . . . . . . . . . 131.6.2 Logical view of MySQL server architecture[22] . . . . . . . . . . . . 141.6.3 MySQL Log file analysis . . . . . . . . . . . . . . . . . . . . . . . . . 15

2 Design and Implementation 172.1 List of existing Functionalities . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.1.1 Moodle session Manager . . . . . . . . . . . . . . . . . . . . . . . . . 172.1.2 Moodle session database . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.2 Changed functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.2.1 Creation of temp table . . . . . . . . . . . . . . . . . . . . . . . . . . 192.2.2 Insert new empty session record . . . . . . . . . . . . . . . . . . . . 192.2.3 UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.4 Cron temp table data . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3 Tools used in project 233.1 JMeter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.1.1 JMeter settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.1.2 Summary report[7] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.1.3 Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3.2 mk-query-digest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.3 PhpMyadmin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.4 MySQL Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

3.4.1 SQL Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283.4.2 Data Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

1

Page 7: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

4 Sanity testing 304.1 Guest user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.2 User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.2.1 Valid user login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.2.2 Update user session time . . . . . . . . . . . . . . . . . . . . . . . . 314.2.3 View course page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.2.4 Valid user logout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

4.3 Admin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.3.1 Admin logged-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.3.2 Admin logout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

5 System Setup for load testing 345.1 Creating Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.2 Jmeter settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

5.2.1 Testing static pages . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.2.2 Testing dynamic pages . . . . . . . . . . . . . . . . . . . . . . . . . . 35

5.3 Enabling memcached to moodle . . . . . . . . . . . . . . . . . . . . . . . . . 365.4 MySQL configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

6 Results 376.1 Hardware Configuration details . . . . . . . . . . . . . . . . . . . . . . . . . 376.2 Software Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376.3 Test cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386.4 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

7 Conclusion and Future work 417.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

A 42A.1 Retrieving data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42A.2 Session Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43A.3 Some observations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

A.3.1 phpMyAdmin setup . . . . . . . . . . . . . . . . . . . . . . . . . . . 45A.4 Results in detailed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

A.4.1 Test case1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45A.4.2 Test case2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48A.4.3 Lines of Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

A.5 Memcached . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

2

Page 8: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Chapter 1

Introduction

1.1 Motivation

Moodle LMS is an open source software, which is used in 239 countries all over the

world. Moodle has a strong support of communities where the experts are involved in the

discussion. Moodle LMS has performance issues with respect to user response time. By

improving the user response time of Moodle, it is going to be useful for 73.7 Million users

and also 1.3 Million teachers, and so on, across the world. User response time can improve in

many ways, i.e., by changing the Moodle architecture, hardware or software configuration,

database, and so on.

1.2 Learning Management System

Distance education represents the mode of delivering a course of study, in which most

of the communication between teacher and student take place asynchronous learning. e-

learning is interactive learning, in which the learning content is accessible online, which

offers feedback to students learning behavior[17].

E-learning is broadly inclusive of all forms of educational technology in learning and

teaching[1]. e-learning is useful for students and teachers. It includes computer based

learning like conducting online exams, and providing feedback to students, etc., which also

tries to remove the time constraints and location constraints. It is suited to distance learning

and flexible learning.

3

Page 9: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 1.1: Learning management system[21]

Comparison of traditional and e-learning method is shown in Figure 1.1 By looking at

Figure 1.1 , we can say that the process of learning is easy using internet. Students can

interact with their instructor 24 hours and seven days per week, via discussion forums,

email, chat, and so on. In traditional classroom lecture, content is manually distributed,

and once the class is over, the students cant interact with lecturer. e-learning provides the

opportunity to the students to communicate with teacher, and as well as themselves. This

communication is done through email or using discussion forums or chat rooms.

LMS is a software application for the administration, documentation, tracking, reporting

and delivery of e-learning education courses or training programs[1]. Open and Distance

learning mode is especially for working adults who need to support their families as well as

manage their career while pursuing higher education.

1.2.1 LMS Features

The following features[10] are required for LMS in an e-learning process.

• Multiple language support

• Modular structure

4

Page 10: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

• Discussion forums, group work

• Ease of installation

• Database support

• Video conferencing support

• Creating input in different input format (like Office file, JavaScript, php, MPEG file,

etc..)

• Online exam, exam module

• chat, wiki, survey, search

• Whiteboard

• Backup support

• XML support to work with different systems

LMS softwares are available in commercial as well as Open source softwares.

• Open Source LMSs include Moodle, edX, SAKAI, WebCT, Bscw, Illias, eduplone,

Claroline, ATutor, Dokeos and so on. These open source softwares have wide developer

communities, which presents robust arguments for considering open source software, as

a straightforward and potentially feasible competitor to commercial products[10, 11].

• Commercial LMSs include Blackboard, Desire2Learn, KEWL, Blackboard Learning

System, ANGEL Learning Management Suite, eCollege, etc.

1.3 Moodle LMS

1.3.1 Introduction

Moodle is an open source software e-learning platform (also known as Course Management

System (CMS), or Learning Management System (LMS), or Virtual Learning Environment

(VLE)), which provides educator’s tools to create a course website[16, 11]

It is a web-based Learning Content Management System (LCMS) i.e. a CMS, and LMS,

which provides information and collaboration among the Moodle Users such as System

Administrators, developers, course designers, etc.

5

Page 11: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Moodle community has grown extensively, and both developers and users have actively

participated in the discussion forums, by sharing their ideas, tips, resources, and also help-

ing new users.

Some of the reasons for using Moodle are listed below[9]

1. Moodle is Open Source software. This means that anyone can download, and modify

Moodle source code according to our needs. Also, we can distribute it, under the same

license.

2. Easy to learn and provides high quality online courses. Instructors are sharing doc-

uments/lecture materials, graded assignments, discussion forums, etc., amongst stu-

dents.

3. Provides good educational tools/plugin, and easy to install.

4. Can be used on almost all servers that run PHP. Moodle can be easily downloaded

from http://moodle.org, and can be upgraded to the latest version.

5. One Million users are registered who interact through Moodle Community, which

helps share ideas. Non-core developers also provide their efforts to develop plugins

based on their requirements. Due to these factors and support, Moodle has emerged

as a global project[1].

6. Moodle allows users to post news items, assignments, electronic journals and resources,

and to collect assignments, etc.

7. Moodle is CMS & VLE, and lets teachers provide and share documents, graded as-

signments, quizzes, discussion forums, etc. with their students in an easy-to-learn

manner and to create quality online courses.

1.3.2 Moodle as Modular System

Moodle is structured as an application core, surrounded by numerous plugins to provide

specific functionality. Moodle is designed to be highly extensible and customizable without

modifying the core libraries. So when you are trying to upgrade to a newer version, it always

creates problem. Standard Moodle distribution includes Moodle core and number of plugins

of different types. These are helpful for users to start teaching and learning immediately.

Moodle basic code contains minimum functionalities needed to build the LMS. Moodle

core needs to be used by every newly developed plugins. Moodle core includes the following

1. Courses and Activities like wikis, quizzes, etc.

2. Users

3. User functionalities

6

Page 12: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 1.2: Technologies used in Moodle

4. Logs and Statistics

5. Libraries

1.3.3 Developers perspective

Lines of code useful for measuring the complexity or productivity or volume of code in

Moodle. Total lines of code for entire Moodle is 1.488Millions. Organization of code

follows transaction script approach. Lines of code for Moodle directory wise shown in

appendix A.1. The following Figure 1.2 shows the moodle structure in technologies view

which is useful for developers. LAMP define as Linux,Apache,MySQL, and PHP.

1.3.4 Standard Moodle Functionalities

The various features[1] of Moodle are as follows

1. Assignment submissions

2. Discussion forums

3. File download

4. Grading

5. Chat

6. Online calendar

7. Online news and announcement (College and course level)

8. Online quiz

9. Wiki

10. Multi language support

7

Page 13: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

11. Modular, i.e., can be extended by creating plugins

12. Report (Which can be used for tracing or analyzing the user logs)

1.4 Problem Statement

Moodle LMS contains some performance issues. According to DBP Moodle system ad-

ministrator, DBP moodle supports 2500 users at a time for conducting online quiz with

configuration of 96GB of RAM, 100 TB HDD. When we run moodle on normal PC then

we found that moodle database is using database locks for updating records. We planned

to remove those locks from moodle database. These updation is done on moodle session

database table which is accessed by user frequently. While updating these, other queries

are going to sleep state till completion of updating session record in moodle session table.

we decided to remove those locks so that we can improve Moodle LMS performance.

When we were running 400 users on server then we found following observations

8

Page 14: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 1.3: CPU usage

Most of the CPU(433.9% ) is spend on processing mysql requests. This gave us the

basic way to find the bottleneck of Moodle LMS.

While observing mysql server then following results found

9

Page 15: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 1.4: Updating session table

Whenever database server is updating mdl session table then remaing all other connec-

tions are going to sleep state. A simple experiment of killing update query then this update

on sessions table is the bottleneck. The figure 1.4 shows the processing list when users were

acessing moodle.

The figure A.2 shows time taken by the query. For updating or inserting sessdata in

session table, it is locking that particuler record.

10

Page 16: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 1.5: Locks used on session table

The figure 1.5 shows the locks used on moodle session table whenever it is going to

update the table.

1.5 Moodle Three Layer Architecture

Moodle can be represented in a three layer architecture as shown in the Figure 1.6. Moodle

distinguishes between code (PHP, HTML, and CSS) and data. Moodle library, modules

(such as resources and activities), blocks, plugins, and other entities are represented in the

code. This code contains all elements that deal with front-end and back-end operations.

Interface is a boundary, across which the systems communicate. User interface refers to

communication between software and human beings. For example, in Moodle, this is what

we see and click on the web browser, and in our mail programs. It provides ways for us to

access, understand, and change the database at the heart of any Moodle site[15]. The design

of such an interface requires collaboration between software. Users makes this user-friendly

and maximize overall usability.

11

Page 17: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 1.6: Moodle Three Layer Architecture

Moodle administrator can change system settings of Moodle courses, roles, groups, and

other data, such as learning resources added by teachers, and student involved in discussion

forums, chats, and so on. All of these are stored in Moodle database. The pictures up-

loaded by users, conducted workshop tutorials, uploaded assignments, etc., are also stored

in moodledata directory.

1.6 Moodle Database

Moodle database schema contains many tables (more than 310 approximately). These

tables are a collection of core database tables and the tables which are belonging to each

plugin. This Moodle database structure is defined in install.xml file placed under the db

folder in each plugin.

The entire database is defined, edited, and upgraded using the XML system. This

XMLDB is the Moodle database abstraction layer which contains the library code and

this allows Moodle to interact and accessing the database. Moodle uses ADODB, which is

abbreviation ActiveX Data Object. This is the database abstraction library for PHP. For

analyzing the Moodle performance, we used different tools like Jmeter, mk-query-digest,

and http-load, and so on. Detailed explanation of these tools is given in chapter

12

Page 18: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

1.6.1 Tables in Moodle Database

The present Moodle database schema has 314 tables and uses InnoDB by default. Other

storage engines like MyISAM, Merge MyISAM, etc., are also supported. When you create

a table, MySQL stores the table definition in a .frm file.

These tables are categorized[15] based on type of data they store. They are

1. Configuration

2. Users and Profiles

3. Roles and Capabilities System

4. Courses

5. Groups

6. Logging System

7. Blocks System

8. Events

9. Backup and restore

10. Statistics

11. Tags

12. Grade Book

13. Question Bank

14. Messaging System

15. Moodle Network

16. Caching

17. Miscellaneous

18. Activity Modules

19. Blocks

20. Question Types

13

Page 19: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

1.6.2 Logical view of MySQL server architecture[22]

This will help us understand the server in the form of MySQL components. Figure 1.7

shows the logical view of MySQLs architecture. In the Figure 1.7, the topmost layer con-

tains services most network based client/server tools or servers need: connection handling,

authentication, security, etc.

Figure 1.7: Logical view of MySQL server architecture

Second layer consist of query processing, analysis, optimization, caching, and all prede-

fined functions like date, math, time, etc., In this level, storage engine will provide func-

tionalities like views, triggers, etc.

The last layer contains the storage engines like InnoDB, MyISAM, Blackhole, etc., The

response of storage engines are storing and retrieving all data stored in MySQL. The server

communication is done through storage engine API (Application Programming Interface)

only. These storage engines don’t communicate with each other, they simply respond to

the request from server.

14

Page 20: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Moodle Database Storage Engines:

Storage Engines are defined as a particular set of methods, which is used to store and

manage information in a database. Each storage engine offers a different way to store,

index, and lock data. The ability of MySQL is to allow you to use more than one storage

engine. Indexes are implemented in the storage engine layer, not the server layer. List of

Moodle database supported, and default storage engine are shown below

1. InnoDB[15]

• Moodle database server uses InnoDB storage engine as the default one for MySQL

5.5 or later versions.

• This provide the ACID transaction features. Along with this it supports foreign

key, table spaces (it can specify only database storage locations)[1], Full text

indexes from MySQL 5.6 onwards.

• it works more robustly, performs better with big sites, and allows better data

integrity features (transactions).

• InnoDB is better for write-intensive websites, i.e., sites that heavily use inserts

and updates.

• InnoDB uses more system resources (such as RAM) than MyISAM.

2. MyISAM: Allows to perform fast read operation structure of its indexes. Moodle

1.9 or earlier uses MyISAM as the default storage engine.

1.6.3 MySQL Log file analysis

As Moodle uses its own abstraction layer to convert the PHP queries to SQL queries,

it is quite interested to know, if there is a performance issue in the SQL queries that are

generated. Application profiling and server profiling are used for finding the performance.

Application profiling provides the complete picture of system performance. MySQL pro-

filing also provides the entire information, which is not available at application profiling.

For example, PHP code does not show you, how many rows of MySQL are examined for

executing queries.

We can find out where MySQL spends most of the time by using server profiling. MySQL

has two kinds of query logs.

1. General query log

2. Slow query log

General query log[22]

These log have all queries which are received by the server and the queries that may not

be even executed once due to some error. The server writes information to this general log

15

Page 21: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

when the client is connected or disconnected. It logs each SQL statement received from

the clients. This means that, whatever queries a server receives, it will write into the log.

Thus, it contains queries that may not even be executed once due to errors. These will be

useful for any client that is facing connection problem. In this case, administrator will look

at this log. These general query logs do not contain the execution time of queries or after

completion of query information. It also does not maintain general log. Log file records 554

queries per second while attempting quiz.

Slow query log[2, 22]

This contains the list of SQL statements that are taking more time than the general log

query; slow log query maintains query execution time. These can be defined as logs queries

that take more than specified amount of time to execute.

These two log files are useful for finding the bottlenecks of the MySQL server performance.

Out of these two, slow query log has the first preference for finding the problematic queries.

In order to know what queries get executed on performing a particular action on Moodle,

First we have to set up SQL log file. Thus, our first consideration is to get the queries,

and later check the performance of those queries. The minimum and default values of

long-query-time is between one to ten seconds respectively(If the query time is between the

specified limit, or more than that query will be stored in slow log file)[2]. Slow query log

will helpful for optimization because it contains queries which are taking a long time to

execute.

The slow log file contains following metrics,

1. Query time: How many seconds query bring to execute

2. Lock time: How long query waited for table lock in the MySQL server level (not at

the storage engine level)

3. Rows sent: The number of rows the query returned

4. Rows examined: The number of rows query examined

The default storage engine for MySQL is INNODB which supports row-level locking,

MYISAM storage engine supports full table locks. Every storage engine does not support

all functionalities, for example, MYISAM will not implement transactions, and InnoDB

does not support FULL TEXT search indexes.

16

Page 22: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Chapter 2

Design and Implementation

2.1 List of existing Functionalities

Whenever user try to login to moodle, user session is created in moodle sessions table.

In index.php internally calling the moodlelib.php for user-login details which is complete-

user-logging($USER). This function internally checks login user details which is described

in moodle database.php file and manager.php. Initially manager.php generates session of

every user (user can be either guest, admin, student, etc.) in moodle sesion table.

2.1.1 Moodle session Manager

Following functions are present in moodle/lib/classes/sessions/manager.php and moodle

session manager class for creating and maintaining session

• init-empty-session()

– When moodle application is browsed, no user is logged in and an empty session fill

with user not-logged-in information. Once user logged in with valid credentials

then this not-logged-in information is deleted for memory releases.

• initialise-user-session($newsid)

– User information is saved in $ SESSION in PHP which is super global used.

– This function checks if user sessions exists or not with help of session id.

– If session id already exists then this generates new session id to prevent session

fixation attacks.

– And also it verifies the timeout if the user is guest then this timeout expires

otherwise timeout is updated by calling session regenration function.

– Update session tracking record: This plays major role in session table. This

function checks all existing data like last accessed ip, sid, userid, timemodified,

etc. if it is exist then session table is updated, otherwise update the session

modified flag only once a day every 20 seconds.

17

Page 23: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

• login user($user)

– This function to be called only from complete-user-login() only

– Regenerate session id and delete old session, this helps to prevent session fixation

attacks from the same domain

• write close(): No more changes in session expected. Unblocks the sessions, other

scripts may start executing in parallel

• garbage collection(): This function do the following operations

– Kills all sessions of deleted and suspended users

– Deletes expired sessions for guest user account, and then gives them larger time-

out

– Deletes expired sessions for userid = 0 (not logged in) for avoiding memory

wastage.

• add-session-record($userid)

– This function inserts the new session record into moodle session database table

with sid, userid, time created, time modified, firstip, etc.

– This function called by login-user()

2.1.2 Moodle session database

This is executed after session initialization of new users. Remaining done by the moodle

database class using handlers. Session entry is done in the following sequence with help of

handlers

1. read($sid):

• First it checks whether database record exists or not if it doesn’t exist then let

the moodle session manager create. If user is accessing moodle first time then

skip locks on that record.

• Checks whether lock exists or not, if it does not a new record then lock session.

• Finally it reads the full session data by decoding sessdata.

• This sessdata uses SHA1 algorithm for ecncryption and decryption.

2. write($sid, $sessdata)

• First decode the sessdata using SHA1 algorithm and then checks whether last

hash is same or not, if it is not same then updates sessdata otherwise returns

without any action.

• Entry of sessdata also done in two ways

18

Page 24: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 2.1: Moodle session temp table

(a) One is first entry in sessions table with the help of sid (Entry sessdata in

session table with help of sid is done only once)

(b) Second one is id of session table which is used frquently

3. gc(ignore max time): It is garbage collection process.

2.2 Changed functions

2.2.1 Creation of temp table

Creating moodle session temp table

USE moodle ;

CREATE TABLE mdl se s s ions temp AS SELECT ∗ FROM mdl s e s s i on s WHERE 1=2;

ALTER TABLE mdl se s s ions temp ADD primary key ( id ) ;

ALTER TABLE mdl se s s ions temp MODIFY id b i g i n t (10) AUTO INCREMENT;

DESC mdl se s s ions temp ;

backup o f md l s e s s i on s ;

CREATE TABLE mdl se s s i ons backup data AS SELECT ∗ from md l s e s s i on s ;

TRUNCATE TABLE mdl s e s s i on s ;

This database table is created according to moodle session database table. In temp table,

only id is the primary key. In moodle session table which is shown in the figure 2.2 contains

index because they are accessing this table frequently for updating sessdata. Temp table

contains only insertions. This temp table is shown in the figure 2.1

2.2.2 Insert new empty session record

Following function stores session details into moodle session temp table. This moodle

session table is created by executing temp.sh script which contains mysql scripts for creating

session temp table. These session is inserted in two ways.

1. Initial session creation which is defined in moodle session manager file

19

Page 25: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 2.2: Moodle session table

2. Modify existing sesssions which is defined in moodle database handler.

This function is defined in moodle session manager file. Here we are storing sessdata as

empty for initial accessing of moodle.

//Added by raju for Patch-2.6.3-1-log

protected static function add_session_temp_record($userid, $SESSDATA=’’) {

global $DB;

$record = new \stdClass();

$record->state = 1;

$record->sid = session_id();

$record->sessdata = $SESSDATA;

$record->userid = $userid;

$record->timecreated = $record->timemodified = time();

$record->firstip = $record->lastip = getremoteaddr();

$record->id = $DB->insert_record(’sessions_temp’, $record);

return $record;

}

This function is defined in moodle session database handler file. Here we are updating

sessdata with help of session id(sid).

private static function add_session_temp_record_test($sid, $sessdata) {

global $DB;

$record = new \stdClass();

$record->state = 0;

$record->sid = $sid;

20

Page 26: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

$record->sessdata = $sessdata;

$record->userid = $_SESSION[’USER’]->id;

$record->timecreated = $record->timemodified = time();

$record->firstip = $record->lastip = getremoteaddr();

$record->id = $DB->insert_record(’sessions_temp’, $record);

return $record;

}

2.2.3 UPDATE

we are modifying write handler function in moodle session database file.

public function handler_write($sid, $session_data) {

if ($this->failed) {

return false;

}

$sessdata = base64_encode($session_data);

// There might be some binary mess :-(

$hash = sha1($sessdata);

if ($hash === $this->lasthash) {

return true;

}

try {

if ($this->recordid) {

//$this->database->set_field(’sessions’, ’sessdata’,

$sessdata, array(’id’=>$this->recordid));

//Added by Raju for Patch-2.6.3-1-log

self::add_session_temp_record_test($sid,$sessdata);

} else {

// This happens in the first request when

//session record was just created in manager.

//$this->database->set_field(’sessions’, ’sessdata’,

$sessdata, array(’sid’=>$sid));

//Added by Raju for Patch-2.6.3-1-log

self::add_session_temp_record_test($sid,$sessdata);

21

Page 27: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

}

} catch (\Exception $ex) {

// Do not rethrow exceptions here, this should not happen.

error_log(’Unknown exception when writing database session data :

’.$sid.’ - ’.$ex->getMessage());

}

return true;

}

2.2.4 Cron temp table data

For croning the moodle session temp table into original table, we created one temporary

database table which is last-run. This contains the information of last run records session

details. Sessdata, userid will be updated in last run by comparing each record of last run

and temp table sid, modified time. Remaining records is deleted from session temp database

table.

global $DB;

$infname=’Synch_Session’;

$last_run_recs = $DB->get_records(’last_run’, array(’name’=>$infname),

’id DESC’, ’id, last_run’);

foreach ($last_run_recs as $last_run_rec)

{

$id=$last_run_rec->$id;

$sessions_rec = $DB->get_records(’sessions_temp’,’where id in

select max(id) id from mdl_sessions_temp where

timemodified >= $last_run_rec->last_run group by sid,userid’,

array(), ’sid ASC’, ’sid,userid,sessdata’);

foreach($sessions_rec as $session_rec)

{

$sessdata=$session_rec->sessdata;

$sessdata=$session_rec->sid;

$userid=$session_rec->userid;

$sql = "UPDATE {sessions} SET sessdata = :sessdata WHERE sid = :sid and userid =:userid";

$DB->execute($sql, array(’sessdata’=>$sessdata, ’sid’=>$sid,’userid’=>$userid));

$DB->delete_records(’sessions_temp’, array(’sid’=>$sid,’userid’=>$userid));

}

$sql = "UPDATE {last_run} SET last_run = :now WHERE id = :id ";

$DB->execute($sql, array(’now’=>time(), ’id’=>$id));

22

Page 28: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Chapter 3

Tools used in project

For finding the bottlenecks of Moodle, we used the following tools, which are available as

open source. Here, we discuss a brief introduction of some of the tools used in Moodle and

its usage.

3.1 JMeter

JMeter is a tool, that is extensively used for testing the performance of Moodle under

various test conditions. To compare with other servers, extensive tests were done with the

default Moodle configuration.

JMeter, developed in Java, is an open source desktop application. It is also used for Load

testing for analyzing, or simulate a heavy load on a server and measure the performance

of variety of services, and it is mainly focused on web applications. Using JMeter, we can

perform the test on static and also dynamic resources, i.e., databases, and webservers.

3.1.1 JMeter settings

Before going to start load testing, folllowing configurations need to be setup for running

large number of users.

User credentials

Create configure element which is a .csv data set of username and passwords of users.

Accessing these username and password is done by creating variables with USER and PASS.

This is shown in figure 3.1. Wherever credentials required define these variables. JMeter

reads data from csv file using these variables.

23

Page 29: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 3.1: User credentials

Sesskey

Sesskey is randomly generated number while accessing moodle for preventing security

attacks like session hijacking. This sesskey is extracted by using regular expressions. Usage

of sesskey is shown in figure 3.2

24

Page 30: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 3.2: Usage of sesskey

The Figure 3.2 shows storing sesskey value into variable $SESSKEY and usage of sesskey.

Attempt

Regular expressions for extracting attempt value for every quiz attempt. This attempt

value is generated dynamically and it is valid till completion of that particuler quiz. Regular

expression for this attempt similer to sesskey extraction which is shown in Figure 3.3

Figure 3.3: Regular Expression for extracting attempt value

Whenever user attempt the quiz then this value get updated. This attempt quiz is used

for counting number of attempts done by user. This is also useful to restrict the number of

attempts. Usage of this ${ATTEMPT} variable is shown in Figure 3.4.

25

Page 31: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 3.4: Usage of attempt variable

3.1.2 Summary report[7]

The summary report shows values about the measurement JMeter has done while calling

the same page as if many users are calling the page. It gives the result in tabular format

• Samples: number of http request ran for given thread

• Average: average response time for that particular http request

• Min: Minimum response time taken for particuler http request

• Max: Maximum response time taken for particuler http request

• Error rate: Percent of requests with errors

3.1.3 Timers

• Constant timer: constant delay between two requests in same thread.

• Gaussian random timer: It has a random deviation around constant delay offset. This

timer used in our project.

3.2 mk-query-digest

mk-query-digest[3] tool is used for analyzing the query execution logs and it will generate

the report for MySQL. This tool is not only for MySQL, it is also used for PostgreSQL, and

memcached. Better to show sample results of all mysql log files with time taken by each

query, memory occupied, number of times that query called,etc.. Number of times moodle

session database table is identified based on mk-query-digest results shown in figure 3.5

26

Page 32: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 3.5: mk-query-digest tool result

3.3 PhpMyadmin

phpMyadmin[4] is used to handle administration of entire MySQL server as well as a

single database over the web. For accessing the database, we need to setup MySQL server

properly. phpMyAdmin is a free software tool written in PHP. For installing phpMyAdmin,

we also need to install web server (Such as LAMP(Linux,Apache,MySQL,PHP)) because

phpMyAdmin interface is entirely accessed on browser.

Features of phpMyadmin are

• Create, copy, drop, rename, tables, columns and indexes

• Browse and drop database, tables, views, etc..

• Import the text files into tables

• export data to various formats: csv, xml, pdf, etc..

• it will support the InnoDB tables and foreign keys

27

Page 33: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

When user login into phpMyAdmin, the user needs to provide username and password

of MySQL. This tool is useful for better understanding of MoodleDB, and for easy way to

add or delete the database tables, and also we can check the size of each table, etc,. The

detailed installation steps of phpMyAdmin tool is shown in Appendix A.3.1

3.4 MySQL Workbench

MySQL Workbench provides a graphical tool for working with MySQL Servers and

databases. MySQL Workbench fully supports MySQL Server versions 5.1 and above.

MySQL Workbench provides three main areas of functionality:

1. SQL Development

2. Data Modeling

3. Server Administration

3.4.1 SQL Development

Enables you to create and manage connections to database servers. Along with enabling

you to configure connection parameters, MySQL Workbench provides the capability to

execute SQL queries on the database connections using the built-in SQL Editor.

3.4.2 Data Modeling

Enables you to create models of your database schema graphically, reverse and forward

engineer between a schema and a live database.

Out of these, we are working on SQL Development with existing database which will

directly import existing database. These tool is used in analysing existing DBP Moodle

data for creating test cases. These tool displays entire query results in window itself. This

is shown in th figure 3.6

28

Page 34: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 3.6: Workbench Tool

29

Page 35: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Chapter 4

Sanity testing

A sanity testing is testing to determine if a new software version is performing well enough

to accept it for major testing effort.

4.1 Guest user

Guest user id of moodle is set 0. Whenever guest is accessed or any non register user is

accesses the moodle then entry in the moodle session table is occurred with userid 0. It is

shown following below

59 Query INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

’25rg9i3aubtb3i0r6vbc0417d6’,NULL,’1’,’1403510313’,’1403510313’,’127.0.0.1’,’127.0.0.1’)

59 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’25rg9i3aubtb3i0r6vbc0417d6’,’’,’1’,’1403510313’,’1403510313’,’127.0.0.1’,’127.

The above queries represents the modified moodle and original moodle had same entry in

the sesssion tables.

4.2 User

Here, we are checking whether our optimized solution and unoptimized moodle entries is

same or not in moodle sessions table and moodle sessions temp table. Which is shown below

49 Query UPDATE mdl_sessions SET timemodified = ’1403802397’ WHERE id=’423’

49 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’6o2s3on7dluetehd5ukicklop4’,’’,’0’,’1403802397’,’1403802397’,’10.12.16.79’,’10

There is no valid user logged in so the userid is assigned as 0 otherwise userid is changed

into corresponding userid.

30

Page 36: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

4.2.1 Valid user login

Valid user logged-in successfully and view home page then userid is changed from 0 to

userid(below example userid is 8) which shown in below

51 Query DELETE FROM mdl_sessions WHERE sid = ’6o2s3on7dluetehd5ukicklop4’

51 Query INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’0’,’s9nb9h821documpfa69t2guib3’,NULL,’8’,’1403805177’,’1403805177’,’10.12.16.79’,’1

51 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’s9nb9h821documpfa69t2guib3’,’’,’8’,’1403805177’,’1403805177’,’10.12.16.79’,’

4.2.2 Update user session time

After logged-in, user time updated in sessions table as follows in

52 Query SELECT id, sid, state, userid, lastip, timecreated, timemodified FROM mdl_sessions

52 Query UPDATE mdl_sessions SET timemodified = ’1403805178’ WHERE id=’427’

52 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’s9nb9h821documpfa69t2guib3’,’’,’8’,’1403805178’,’1403805178’,’10.12.16.79’,’10.1

52 Quit

4.2.3 View course page

The following queries represents updating moodle sessions table

54 Query SELECT id, sid, state, userid, lastip, timecreated, timemodified FROM mdl_sessions

54 Query UPDATE mdl_sessions SET timemodified = ’1403805524’ WHERE id=’427’

54 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’s9nb9h821documpfa69t2guib3’,’’,’8’,’1403805524’,’1403805524’,’10.12.16.79’,’10.

4.2.4 Valid user logout

Valid user logout then userid made it into 0 which is shown below

50 Query SELECT id, sid, state, userid, lastip, timecreated, timemodified FROM mdl_sessions

50 Query UPDATE mdl_sessions SET timemodified = ’1403807232’ WHERE id=’427’

50 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’s9nb9h821documpfa69t2guib3’,’’,’8’,’1403807232’,’1403807232’,’10.12.16.79’,’10.1

50 Query SELECT * FROM mdl_sessions WHERE sid = ’s9nb9h821documpfa69t2guib3’

50 Query DELETE FROM mdl_external_tokens WHERE sid = ’s9nb9h821documpfa69t2guib3’ AND tokentype

50 Query DELETE FROM mdl_sessions WHERE sid = ’s9nb9h821documpfa69t2guib3’

50 Query INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’0’,’tv7u8bcnfphs6qj0f2rl1ck323’,NULL,’0’,’1403807232’,’1403807232’,’10.12.16.79’,’10

50 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’tv7u8bcnfphs6qj0f2rl1ck323’,’’,’0’,’1403807232’,’1403807232’,’10.12.16.79’,’10.1

31

Page 37: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

50 Query INSERT INTO mdl_log (time,userid,course,ip,module,cmid,action,url,info)

VALUES(’1403807232’,’8’,’1’,’10.12.16.79’,’user’,’0’,’logout’,’view.php?id=8&course=1’,’8’)

50 Query DELETE FROM mdl_chat_users WHERE userid = ’8’

50 Query SELECT * FROM mdl_user WHERE id = ’8’

50 Query SELECT * FROM mdl_events_handlers WHERE eventname = ’user_logout’

50 Quit

4.3 Admin

4.3.1 Admin logged-in

After logging of admin, deffault value of userid is changed from 0 to 2 and also deleted the

default session userid for memory release,

54 Query SELECT * FROM mdl_cache_flags WHERE name = ’2’ AND flagtype = ’userpreferenceschanged’

54 Query DELETE FROM mdl_sessions WHERE sid = ’tv7u8bcnfphs6qj0f2rl1ck323’

54 Query INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’0’,’u1lge94e6oogtd1b5h688e3j12’,NULL,’2’,’1403808766’,’1403808766’,’10.12.16.79’,’10

54 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’u1lge94e6oogtd1b5h688e3j12’,’’,’2’,’1403808766’,’1403808766’,’10.12.16.79’,’10.

54 Query SELECT name,value FROM mdl_user_preferences WHERE userid = ’2’

54 Query UPDATE mdl_user SET lastlogin = ’1403743581’,currentlogin = ’1403808766’,lastaccess

140627 0:22:47 54 Query INSERT INTO mdl_log (time,userid,course,ip,module,cmid,action,url,info)

VALUES(’1403808767’,’2’,’1’,’10.12.16.79’,’user’,’0’,’login’,’view.php?id=2&course=1’,’2’)

54 Quit

4.3.2 Admin logout

79 Query SELECT id, sid, state, userid, lastip, timecreated, timemodified FROM mdl_sessions

79 Query UPDATE mdl_sessions SET timemodified = ’1403809803’ WHERE id=’429’

79 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’u1lge94e6oogtd1b5h688e3j12’,’’,’2’,’1403809803’,’1403809803’,’10.12.16.79’,’10

79 Query SELECT * FROM mdl_sessions WHERE sid = ’u1lge94e6oogtd1b5h688e3j12’

79 Query DELETE FROM mdl_external_tokens WHERE sid = ’u1lge94e6oogtd1b5h688e3j12’ AND tokentype

79 Query DELETE FROM mdl_sessions WHERE sid = ’u1lge94e6oogtd1b5h688e3j12’

140627 0:40:04 79 Query INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’0’,’ctfnmcoi9mga1qfuuk1rj3rc26’,NULL,’0’,’1403809804’,’1403809804’,’10.12.16.79’,’10

79 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’ctfnmcoi9mga1qfuuk1rj3rc26’,’’,’0’,’1403809804’,’1403809804’,’10.12.16.79’,’10

79 Query INSERT INTO mdl_log (time,userid,course,ip,module,cmid,action,url,info)

VALUES(’1403809804’,’2’,’1’,’10.12.16.79’,’user’,’0’,’logout’,’view.php?id=2&course=1’,’2’)

79 Query DELETE FROM mdl_chat_users WHERE userid = ’2’

79 Query SELECT * FROM mdl_user WHERE id = ’2’

32

Page 38: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

79 Query SELECT * FROM mdl_events_handlers WHERE eventname = ’user_logout’

79 Quit

No one is login then

81 Query UPDATE mdl_sessions SET timemodified = ’1403809804’ WHERE id=’430’

81 Query INSERT INTO mdl_sessions_temp (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip

VALUES(’1’,’ctfnmcoi9mga1qfuuk1rj3rc26’,’’,’0’,’1403809804’,’1403809804’,’10.12.16.79’,’10.

33

Page 39: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Chapter 5

System Setup for load testing

5.1 Creating Users

• Following script generates the 5000 users. We are going to use these users details for

course registration purpose. The users information is randomly generated with the

help of following script.

#!/bin/bash

i=1

for ((i=1;i <= 5000; i++ ))

do

echo "username$i;\${RANDOM};firstname\${i};lastname\${i};

email\${i}@cse.iitb.ac.in;cs101" >>users_list_moodle.csv

done

• Valid File format for uploading users is as follows

username,password,firstname,lastname,email,course1

username101,2542,firstname101,lastname101,[email protected],cs101

username536,85645,firstname536,lastname536,[email protected],cs101

• Uploading bulk users in moodle is as follows

– Create file which contains users details which is shown on above for uploading

users

– Go to Settings >Site administration >Users >Accounts >Upload users

– Add file to upload

– Upload users preview - check settings and default user profile settings

– Upload users preview - click ”Upload users”

– Upload users results - shows list of users, exceptions made in upload and summary

of number of users

34

Page 40: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure 5.1: Static Page settings

– Upload users results - click ”Continue”

– Returns to Upload users screen

5.2 Jmeter settings

5.2.1 Testing static pages

Using JMeter, we done the stress testing of single page. In this case, we are supposed to

give the input script as particular page. This is shown in figure 5.1

5.2.2 Testing dynamic pages

• Extract regular expressions of both sesskey and attempt. These variables are used to

change every user generated sesskey and attempt value dynamically.

• Inside JMeter script, replace sesskey value with $SESSKEY variables and similarly at-

tempt value with $ATTEMPT where SESSKEY and ATTEMPT’s are given variables

names while extracting regular expressions.

• Mention number of users as thread group size

• For login user, we enable config element which contains user name, password, file

name, etc. In our case we retrieved username and password from file and stored into

USER, PASS variables.

• For clearing cookies of each user, use HTTP cookies

35

Page 41: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

• Enable listeners (For example summary report, view results in tree, response time

graph, etc.)

5.3 Enabling memcached to moodle

We used memcached for storing sessions table but internally it is storing application de-

tails also. We checked the performance of moodle with memcached and without memcached

but we didn’t get the much improvement.

In moodle configuration file, we need to add the following lines of code for enabling

memcached for storing sessdata.

\${CFG->session_handler_class} = ’\core\session\memcached’;

\${CFG->session_memcached_save_path} = ’127.0.0.1:11211’;

\${CFG->session_memcached_prefix} = ’memc.sess.key.’;

\${CFG->session_memcached_acquire_lock_timeout} = 120;

\${CFG->session_memcached_lock_expire} = 7200; // Ignored if memcached extension <=

These are standard settings provided by organizaation. After enabling memcached, we

have to create instances if you have multiple caches in server. In this case, moodle having

MUC cache and memcached whenever we enable memcached then it will store the data by

defult in MUC cached folder. For differentiating these data and avoiding data corruption,

we created instances.

5.4 MySQL configuration

Whenever we install MOODLE LMS then it will support 150 connections by default.

According to our configuration, we need to configure the MySQL file (my.cnf). Based on

DBP Moodle(DBP Moodle is moodle which is used in IIT Bomaby Institute for conducting

exams from all over india through remote servers) system admin suggested percona tools

for mysql organization. With help of Percona organization, we configure our MySQL file.

For making MySQL configuration file, it uses following parameters

1. Server details (example where this server hosted, How much memory does your server

have?, what is your operating system, how many tables are there, etc.)

2. Workload (IS it dedicated server, and whether this server be a production MySQL

database server, or is it going to use for some other purpose?)

3. storage engine and it’s details

4. cache size

36

Page 42: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Chapter 6

Results

6.1 Hardware Configuration details

Table 6.1: Hardware Configurations detailsRAM Processor HDD OS

2 intel core 2 duo 160GB ubuntu 12.04

4 intel core i3 250GB ubuntu 12.04

Some more details is shown below

• Moodle 2.6.3

• PHP 5.6.3

• JMeter 2.11 for testing moodle

6.2 Software Configuration

We collected live data from DBP Moodle system administrator. Using these live data, we

made our test plan. For making our own test plan, we used these database tables mdl quiz,

mdl quiz attempts, mdl quiz grades, mdl course for retrieving exact scenarios. For retrieving

data from DBP moodle, we used SQL queries those are mentioned in appendix A.1

We created one course in moodle which contains quiz activity. This quiz contains 6

multiple choice questions. Time limit of quiz is 10 minutes. We used worst case scenario

that is most of students submit quiz at time of 9 to 10 minutes. For attempting all users

at a time, we used JMeter script. Inside question, options are jumbled so that answering

questions will be different by every student.

37

Page 43: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Function Test case1 Test case2

Name of quiz SQL Quiz1 SQL Quiz2

Time(min) 10 10

Number of attempts allowed unlimited unlimited

Question order shuffled shuffled

Number of questions per page 1 all

shuffle within question yes yes

Grades uniform uniform

Table 6.2: Different Test cases

6.3 Test cases

Some more details about the test cases

1. Numer of questions : 6

2. Participants: changed dynamically

3. Type of questions: Muliple choice questions

4. Think time or random time: Constant time with 10 min.

These information retrieved from DBP Moodle live data which is collected from abhi-

lash(DBP Moodle admin).

6.4 Results

The following results represents the response time of start attempt page which is taking

more time and one more page which is processing page while conducting quiz. And also

mentioned that average response time of all the pages while attempting quiz. One of the

column represents error rate which is contains the error rate of overall quiz. These details

retrived by running test case individually by changing the number of users. Detailed graphs

is mentioned in appendix.

Number of Users average Response Time Error rate start attempt processing

50 8.1 0 11 8.5

75 8 0 15 7.5

100 9.97 0 14.2 9.94

125 8.5 0.25 20 16

Table 6.3: 2GB RAM Results without optimization for test case1

38

Page 44: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Number of Users average Response Time Error rate start attempt processing

50 6.7 0 9.2 6.9

75 5.9 0 6.1 5.9

100 10.8 0 18 11

125 16.8 0 26 17

150 22.4 6.7 44 23

Table 6.4: 2GB RAM Results with optimization for test case1

Number of Users average Response Time Error rate start attempt processing

50 8.1 0 12 9.7

75 3 0 14 11

100 4.6 0 21 18

125 6.3 0 30 24

150 10.04 8.5 46 35

Table 6.5: 2GB RAM Results without optimization for test case2

Number of Users average Response Time Error rate start attempt processing

50 10.7 0 32 28

75 16 0 47 42

100 21.8 0 66 55

125 27.5 0 77 69

150 28.8 0 96 28

175 31 0 82 60

200 29 0.17 77 36

Table 6.6: 2GB RAM Results with optimization for test case2

Number of Users Response Time Error rate Start attempt processing

50 0.4 0 1.2 0.5

100 0.57 0 2.2 1.6

150 1.6 0 7.5 5.5

200 3.6 0 11 3.9

250 10.3 13.77 7 14

Table 6.7: 4GB RAM Results without optimization for test case1

39

Page 45: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Number of Users Avg Response Time Error rate Start attempt processing

50 2.7 0 0.9 0.5

100 0.7 0 0.8 0.77

150 1.6 0 1.1 1.8

200 4 0 4.4 4.2

250 6.3 0 3.2 2.4

300 7.65 8.9 7.63 7.8

Table 6.8: 4GB RAM Results with optimization for test case1

40

Page 46: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Chapter 7

Conclusion and Future work

7.1 Conclusion

We removed the locks successfully on moodle session database table. We did the cor-

rectness of our optimized solution using sanity testing. We used tool that is JMeter for

load testing of moodle with different parameters, and configure elements like summary re-

port. mk-query-digest tool used for finding number of times that particular sql query was

accessed. In place of locks, we used one database table which is used for storing sessdata

and at the end, we cron temp table into original table. This improved moodle supports

approximately 30% of extra users compared to already existed one.

7.2 Future Work

Whenever system administrator or instructor wants to check the reports of students

then they are able to see either that particular day or all days logs. Instructor or system

administrator is not able to see the details of particular range of days. Here, the problem

is whenever teacher or instructor selects all days logs, then it retrives old users details also.

This is unnecessarly retrieving old users(whoever not active in that particular course or

semester) which is effecting performance or it kills the instructor patience. If this option

can be done with optimized queries, then this will give good performance.

Moodle sessions are not necessary if we are able to redirect the users whenever they are

going to open new tab with moodle page then we no need to maintain sessions. This can

be done only when we are going to conduct quizzes or any other thing.

41

Page 47: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Appendix A

A.1 Retrieving data

For retrieving user data from DBP Moodle, we used workbench tool. Following sql

queries, we run on the existed moodle database.

use moodle;

select * from mdl_quiz where course=74;

select * from mdl_course;

select 1308904800-1308893400 from dual;

select sumgrades,count(*) from mdl_quiz_attempts where quiz =50 group by sumgrades;

select state,count(*) from mdl_quiz_attempts where quiz =50 group by state;

select 11400/60 from dual;

select * from mdl_quiz_feedback where quizid =50;

select count(*),grade from mdl_quiz_grades where quiz=50 group by grade;

select * from mdl_quiz_question_instances where quiz=50;

select * from mdl_rating;

These queries are used for retrieving data from DBP Moodle live data. These queries run

on workbench tool.

42

Page 48: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

A.2 Session Handling

Moodle needs to store the session data in some storage. By default either file or database

session storage is selected. Based on our requirement we were activating one of the storage

as follows

• Storing data into Database [5]: For storing sessdata in moodle database table, we

suppose to make following changes in moodle configuration file because new moodle

versions are storing sessdata in files by default.

\${CFG->session_handler_class} = ’\core\session\database’;

\${CFG->session_database_acquire_lock_timeout} = 120;

• Storing session into file

This driver is used by default in new installation.

Configuration options in config.php:

\${CFG->session_handler_class} = ’\core\session\file’;

\${CFG->session_file_save_path} = \${CFG->dataroot.’/sessions’;}

Limitation of these file storage is that File based sessions require file system that

supports file locking.

A.3 Some observations

Whenever the server exceeds its capacity then slowly system goes down. In webserver,

you will get error which shown in figure A.1

Figure A.1: Server refuse the connection

43

Page 49: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

The following figure A.2 shows the information about the moodle session table updation

which is taking long time to compare other queries.

Figure A.2: moodle session table

Usually, whenever server stops responding then if we check the database using top com-

mand then it shows, most of the time taken by database server at that time you will get

following error figure A.3

44

Page 50: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure A.3: Database stops responding

A.3.1 phpMyAdmin setup

phpMyadmin setup done as follows,

1. Open the terminal (by using CTRL+ALT+T )

2. sudo apt-get install phpmyadmin

3. Choose the web server

4. Setup the database: you need to set up the database in mysql for phpmyadmin

5. Enter MySQL administration password

6. Create the phpMyAdmin password, this will allow you to log onto phpmyadmin in

your web browser

7. check phpMyAdmin by typing localhost/phpmyadmin in web browser

A.4 Results in detailed

A.4.1 Test case1

The following results are related to Test case1. This test case run on without optimized

moodle by changing number of users.

45

Page 51: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure A.4: 50 users run on 2GB RAM in without optimized moodle

Figure A.5: 75 users run on 2GB RAM in without optimized moodle

Figure A.6: 100 users run on 2GB RAM in without optimized moodle

The following results are related to Test case1. This testcase run on optimized moodle

by changing number of users.

Figure A.7: 50 users run on 2GB RAM in with optimized moodle

46

Page 52: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure A.8: 75 users run on 2GB RAM in with optimized moodle

Figure A.9: 100 users run on 2GB RAM in with optimized moodle

Figure A.10: 125 users run on 2GB RAM in with optimized moodle

Figure A.11: 150 users run on 2GB RAM in with optimized moodle

47

Page 53: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

A.4.2 Test case2

The following results are related to Test case2. This test case run on without optimized

moodle by changing number of users.

Figure A.12: 50 users run on 2GB RAM in without optimized moodle

Figure A.13: 75 users run on 2GB RAM in without optimized moodle

Figure A.14: 100 users run on 2GB RAM in without optimized moodle

48

Page 54: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure A.15: 125 users run on 2GB RAM in without optimized moodle

The following results are related to Test case2. This testcase run on optimized moodle

by changing number of users.

Figure A.16: 50 users run on 2GB RAM in with optimized moodle

Figure A.17: 75 users run on 2GB RAM in with optimized moodle

49

Page 55: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Figure A.18: 100 users run on 2GB RAM in with optimized moodle

Figure A.19: 125 users run on 2GB RAM in with optimized moodle

Figure A.20: 150 users run on 2GB RAM in with optimized moodle

50

Page 56: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Directory name LOC Directory name LOC Directory name LOC

mod 1,39,393 lib 8,89,205 backup 58,794

admin 1,02,890 theme 46,178 question 52,200

grade 17,919 filter 24,493 course 17,344

enrol 17,518 blocks 11,451 pix 13,287

lang 10,319 repository 10,777 cache 7,983

auth 9,960 report 6,620 user 7,365

calendar 4,407 install 6,296 badges 3,704

webservice 3,969 message 3,269 group 3,424

mnet 2,390 blog 2,392 cohort 1,553

tag 2,013 portfolio 1,401 completion 1,477

rating 1,050 comment 1,225 files 884

login 1,025 iplookup 381 notes 854

my 161 local 212

Table A.1: Moodle: Lines of Code

Figure A.21: 175 users run on 2GB RAM in with optimized moodle

Figure A.22: 200 users run on 2GB RAM in with optimized moodle

51

Page 57: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

A.4.3 Lines of Code

From Table A.1, we can see that the LOC for admin, mod, and lib has huge LOC. Thus,

from these we can conclude that mod contains additionally developed modules as compared

to basic module. Thus, developers can add/delete modules easily.

A.5 Memcached

Memcached is used for storing user session data.

Figure A.23: Created Memcached instance

Figure A.24: Memcached activated

52

Page 58: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

Bibliography

[1] http://en.wikipedia.org/wiki/Moodle. [Online; accessed 2-July-2013].

[2] http://dev.mysql.com/doc/refman/4.1/en/slow-query-log.html. [Online; ac-cessed 3 October 2013].

[3] http://www.maatkit.org/doc/mk-query-digest.html. [Online; accessed 2-September-2013].

[4] http://docs.phpmyadmin.net/en/latest/. [Online; accessed 5th-August-2013].

[5]

[6] Session handling. http://docs.moodle.org/26/en/Session_handling, Accessed on21st April 2014.

[7] Jmeter tool. http://jmeter.apache.org/, 2001. [Online; accessed 15-July-2013].

[8] Jmeter tool. http://jmeter.apache.org/, 2001. [Online; accessed 2-October-2013].

[9] A. Al-Ajlan and H. Zedan. Why moodle. In Future Trends of Distributed ComputingSystems, 2008. FTDCS ’08. 12th IEEE International Workshop on, pages 58–64, 2008.http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4683115, Accessed on15th July 2013.

[10] Cansu Cigdem Aydin and G Tirkes. Open source learning management systems ine-learning and moodle. In Education Engineering (EDUCON), 2010 IEEE, pages 593–600. IEEE, 2010.

[11] Sadanand Y Bansode and Rajendra Kumbhar. E-learning experience using open sourcesoftware: Moodle. DESIDOC Journal of Library & Information Technology, 32(5),2012. http://ieeexplore.ieee.org/Xplore/home.jsp, Downloaded on 20th June2013.

[12] Tao Chen, Arif Khan, Markus Schneider, and Ganesh Viswanathan. iblob: Complexobject management in databases through intelligent binary large objects. In AlanDearle and RobertoV. Zicari, editors, Objects and Databases, volume 6348 of LectureNotes in Computer Science, pages 85–99. Springer Berlin Heidelberg, 2010.

[13] Ludmila Cherkasova. Scheduling strategy to improve response time for web appli-cations. In Proceedings of the International Conference and Exhibition on High-Performance Computing and Networking, HPCN Europe 1998, pages 305–314, London,UK, UK, 1998. Springer-Verlag.

53

Page 59: Optimization of LMS for Improving User Response Time · System (CMS), or Learning Management System (LMS), or Virtual Learning Environment (VLE)), which provides educator’s tools

[14] Francisco Corbera, Eladio Gutierrez, Julian Ramos, Sergio Romero, and Marıa A Tre-nas. Developing an effective and efficient elearning platform using open source software.In ACM SIGCSE Bulletin, volume 40, pages 349–349. ACM, 2008.

[15] Martin Dougiamas. http://moodle.org/, 2002. [Online; accessed July-2013 to 2-October-2013].

[16] J.C.G. Hernandez and M.A.L. Chavez. Moodle security vulnerabili-ties. In Electrical Engineering, Computing Science and Automatic Control,2008. CCE 2008. 5th International Conference on, pages 352–357, 2008.http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=4723399,Accessed on 29th August 2013.

[17] Sheo Kumar and Kamlesh Dutta. Investigation on secu-rity in lms moodle. pages 233–238, January-June 2011.http://educhalk.org/blog/wp-content/uploads/2012/01/moodle_security_research.pdf,Accessed on 5th September 2013.

[18] Sheo Kumar, Anil Kumar Gankotiya, and Kamlesh Dutta. A comparative study ofmoodle with other e-learning systems. In Electronics Computer Technology (ICECT),2011 3rd International Conference on, volume 5, pages 414–418. IEEE, 2011.

[19] Navita Kumari. Sql server query optimization techniques-tips for writing efficient andfaster queries.

[20] Yi Li and Kevin L. Performance issues of a web database. In Mohamed Ibrahim, JosefKng, and Norman Revell, editors, Database and Expert Systems Applications, volume1873 of Lecture Notes in Computer Science, pages 825–834. Springer Berlin Heidelberg,2000.

[21] M. Phankokkruad and K. Woraratpanya. Web services for learning man-agement systems: Communication architecture. In Communications (MICC),2009 IEEE 9th Malaysia International Conference on, pages 403–408, 2009.http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=5431540&tag=1, Ac-cessed on 6th September 2013.

[22] Baron Schwartz, Peter Zaitsev, and Vadim Tkachenko. High Performance MySQL:Optimization, Backups, and Replication. O’Reilly Media, Inc., 2012.

[23] Wen-Shuenn Wu. Web applications: A proposal to improve response time and itsapplication to moodle. 12th International Conference, pages 218–225, February 15-202009. Downloaded date 27 Auguest 2013.

[24] Hussein Zedan and Ajlan Al-Ajlan. E-learning (moodle) based on service orientedarchitecture.

54