• 沒有找到結果。

4.1 Experiments

4.1.3 Test link speed 1Gbps

1Gbps

Web Server

& Database Server

Request Response

Figure 4.4: Simulation 1Gbps link

With this kind of link between end users and web server, we can see that the outgoing of system is approximate 500Mbps, and the number of user -access at the same time- is about 1000 users.

Response Number

Time

35

4.1.4 Test with Amazon Web Services

AWS Elastic Load Balancer 1

AWS Elastic Load Balancer 3

…..

AWS EC2

AWS RDS DB

Amazon Route53

Internet

AWS Elastic Load Balancer 2

…..

AWS EC2

…..

AWS EC2 32

Figure 4.5: AWS experiment architecture

In these experiments, I create some virtual machines at another cloud platform as these machines are supposed to help me to generate big mount of requests.

a) 02 AWS EC2 instances

Figure 4.6: 02 AWS EC2 m1.large instances – 02 Elastic Load Balancers When we run 02 EC2 instances, the number of user access at the same time is about 1100 per second. However, as illustrated in the diagram,

Response Number

Time

36

sometimes the number of user access decreases because the CPU of one or both of EC2 instances is overloaded. Therefore, these EC2 instances are marked unhealthy and ELB does not route traffic to these instances.

b) 04 AWS EC2 instances

Figure 4.7: 04 AWS EC2 m1.large instances – 02 Elastic Load Balancers With this kind of model, the number of access can reach 1500 per second. Nevertheless, in some cases, one of the EC2 instances is overloaded, so the number of access may fall.

c) 06 AWS EC2 instances

Figure 4.8: 06 AWS EC2 m1.large instances – 02 Elastic Load Balancers With this kind of model, the number of access can reach 1500 per second. Nevertheless, in some cases, one of the EC2 instances is overloaded, so the number of access may fall.

Last experiment

Last experiment

Response Number

Time

Response Number

Time

37

d) 06 AWS EC2 instances with 03 Elastic Load Balancer

Figure 4.9: 06 AWS EC2 m1.large instances – 03 Elastic Load Balancers In this experiment, the number of access can reach 2000 per second, but the drawback is that the system is not really stable.

e) 12 AWS EC2 instances

Figure 4.10: 12 AWS EC2 m1.large instances – 03 Elastic Load Balancers In this experiment, the number of access almost reaches 3000 per second while the whole system remains quite stable.

f) 18 AWS EC2 instances

Last experiment

Last experiment

Response Number

Time

Response Number

Time

38

Figure 4.11: Running 18 AWS EC2 large instances and RDB db.m2.2xlarge

Figure 4.12: Running 18 AWS EC2 large instances and RDB db.m2.4xlarge When we migrate our system to Amazon Web Services, our new system can respond up to 4000 user’s requests at the same time. The new system is 3 to 4 times as efficient as our original system.

And the new system running with RDB db.m2.4xlarge gives a little bit better results than the others.

4.2 Monitoring System Scaling

4.2.1 Requirements

- Replace Nameserver of our Domain Name by Nameserver of Amazone Route53

Response Number

Time

Response Number

Time

39

Figure 4.13: Replace Nameserver

- Prepare an Amazon Machine Image that includes all of the software we need such as Apache, php5, php5-mysql, OpenSSH-Server, etc.

- Our web application can be stored in AMI or uploaded to Amazon S3 or new EC2 instances (web server) have to send a message to a machine that will upload web directory to the new EC2 instances.

4.2.2 Structure

We set 1 condition that is CPU usage under 20 percent within 10 minutes for scale-in

40

Scale-In

Under 20 percent

AWS-EC2 instances CPU usage within 10 minutes

yes

Remove EC2 instances no

Figure 4.14: AWS scale-in

However, it’s essential we set several conditions for scale-out operations. If the CPU usage is over 50 percent, we will launch 01 EC2 instance. If the CPU usage is increased to over 70 percent, we will launch 02 EC2 instances. As the system is subject to pressing demand, the system capacity needs to be enhanced more quickly.

We also set another condition for scale-out operation. The condition is when two or more EC2 instances are unhealthy instances, we will launch 01 EC2 instances because those instances will be back on track soon after they are detected as healthy instances.

With several policies, we can see that when our system have to response too much requests, some of instances maybe overload for few minutes and the whole system’s CPU usage increase more quickly. At that time, we better launch several EC2 instances instead of launch one by one; it gives us a more effective system. [4]

41

Scale-Out

Over 50 percent

AWS-EC2 instances CPU usage within 1 minute

yes Launch new EC2

instances no

Scale-Out

Over 70 percent

AWS-EC2 instances CPU usage within 1 minute

yes Launch new EC2

instances no

Scale-Out

Over 2

The number of AWS-EC2 unhealthy instances within 1 minute

yes

Launch new EC2 instances no

Figure 4.15: AWS scale-out

* Simplified code file looks at appendix 1

42

4.2.3 Result

Figure 4.16: AWS scaling

By default, our account is limited to a maximum of 20 instances per EC2 region. If we want to run more than 20 instances, we have to get approval directly from Amazon. Actually, RDS Database bandwidth is limited, so we do not need to launch too much EC2 instances. We will create three Elastic Load Balancers that make an optimized system for us; the number of EC2 instances of every Load Balancer is scaled from 1 to 6 instances depends on the system work load.

43

4.3 Cost of using Amazon Web Services for Course Selection System

The content of the table above is estimated for Selection Course System.

A Course Selection System is often opened from 9:00 AM to 12:00 AM every weekday of two weeks. Normally, in the first week, the system still works well with original system. This means we do not need to change our original system.

In the second week, actually, the system needs to be more powerful at the end of the week. Assuming that the last two days is the time of vast number of students using the system. Therefore, the first three days of the second week, we just launch three AWS EC2s for running web server. After that, for the last two days of the second week, the system maybe

44

automatically scaled out to its highest level that includes 18 EC2 instances running giving us a really powerful system..

If we apply this model of cloud computing for our Course Selection System, the estimated cost is $600 per semester.

Some references of server pricing:

Figure 4.17: References of server pricing

45

Chapter 5:

5 Conclusion and Future Works

As a matter of fact, some kinds of websites, such as NCTU’s Course Selection System or the railway ticket selling system in my country, always meet traffic overload situation a certain time. After doing this research, I have reached the conclusion that the system overload may be improved by applying cloud computing technology. It is certain that it depends on how well a system performs. If we compare 1Gbps-link system and AWS new system, we can see that the power of AWS new system is approximately 3 times as big as that of the 1Gbps-link system. We should migrate the system before congestion and set reasonable conditions for scaling to make our system highly available and redundant.

With Amazon Web Services, Database server bandwidth is limited, so we cannot make a more powerful system. But AWS has provided Database Replicas function. Unfortunately, it does not seem to work very well.

I may consider changing testing method– insert one row into the database at every loading webpage time, creating the ratio of read/write is 50:50 while this ratio should be 66 percent reads [1] or 60:40 [2]

I believe that the system will be more powerful when we combine EC2 Auto Scaling and Database Replicas functions.

I will also do research migrate systems based on Windows platform.

46

6 REFERENCES

[1] Microsoft TechNet “Understanding Database and Log Performance

Factors”, April 2013

[2] White paper of EMC Corporation, “Deploying Oracle Database on EMC

VNX Unified Storage”, May 2011

[3] Bianca Schroeder, Mor Harchol-Balter, “Web servers under overload:

How scheduling can help”, May 2002

[4] Marshall, P.; Tufo, H.; Keahey, K. "Provisioning Policies for Elastic

Computing Environments", Parallel and Distributed Processing

Symposium Workshops & PhD Forum (IPDPSW), 2012 IEEE 26th International, On page(s): 1085 - 1094

[5] Wikipedia - Cloud Computing

http://en.wikipedia.org/wiki/Cloud_computing

[6] Peter Mell, Timothy Grance, “The NIST Definition of Cloud Computing”, September 2011

[7] Database Replication

http://en.wikipedia.org/wiki/Replication_(computing)

[8] Database Journal, “Very Large Databases and High Availability

Evaluating Replication Options”, Nov 8, 2006

[9] A. Sousa L. Soares A. Correia Jr. F. Moura R. Oliveira, “Development

and evaluation of database replication in ESCADA”

http://citeseerx.ist.psu.edu/viewdoc/similar?doi=10.1.1.160.3801&type=sc

[10] Webopedia – Cloud Computing

47

http://www.webopedia.com/TERM/C/cloud_computing.html [11] Amazon Documentation

http://aws.amazon.com/documentation/

[12] AWS SDK for Python

http://aws.amazon.com/sdkforpython/

[13] Amazon Relational Database Service Command Line

http://docs.aws.amazon.com/AmazonRDS/latest/CommandLineReference /StartCLI.html

[14] Paramiko

http://docs.paramiko.org/

[15] Abhijit’s World of .Net

http://abhijitjana.net/2010/10/01/what-is-the-difference-between-web-farm-and-web-garden/

[16] Performance test tools

http://www.opensourcetesting.org/performance.php

48

APPENDICES

Appendix 1: AWS Scaling

def AutoScaling(ELB):

AutoScalingGroup_name='my-group-' + ELB scale_up_policy_name= 'scale-up-' + ELB scale_down_policy_name = 'scale-down-' + ELB

scale_up_alarm_avarageCPU_name = 'scale-up-on-cpu-' + ELB scale_up_alarm_Unhealthy_name = 'scale-up-on-unhealthy-' + ELB scale_down_alarm_name = 'scale-down-on-cpu-' + ELB

try:

filename = '/home/lecaocon/masterproj/src/AWS_Userdata.py' f = open (filename, 'r')

conn = AutoScaleConnection(aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY, region=region)

print conn

#autoscale = boto.ec2.autoscale.connect_to_region(region_name=HomeRegion)

#Launch Config print 'Launch Config'

lc = LaunchConfiguration(name='my-launch-config', image_id=image_id,

ag = AutoScalingGroup(group_name=AutoScalingGroup_name, load_balancers=[ELB], availability_zones=['ap-southeast-1a', 'ap-southeast-1b'],

desired_capacity=1,

launch_config=lc, min_size=1, max_size=6, connection=conn)

conn.create_auto_scaling_group(ag) conn.create_scaling_policy(scale_up_policy)

print 'scale down'

49

scale_down_policy = ScalingPolicy(

name=scale_down_policy_name, adjustment_type='ChangeInCapacity', as_name=AutoScalingGroup_name, scaling_adjustment=-1, cooldown=180) conn.create_scaling_policy(scale_down_policy)

scale_up_policy = conn.get_all_policies(

as_group=AutoScalingGroup_name, policy_names=[scale_up_policy_name])[0]

scale_down_policy = conn.get_all_policies(

as_group=AutoScalingGroup_name, policy_names=[scale_down_policy_name])[0]

cloudwatch_conn = CloudWatchConnection(aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY,

region=region)

#cloudwatch = boto.ec2.cloudwatch.connect_to_region(HomeRegion) print 'dimensions'

alarm_dimensions = {"AutoScalingGroupName": '%s' % AutoScalingGroup_name}

print 'alarm up'

cloudwatch_conn.create_alarm(scale_up_alarm)

#CPU Average > 70 percent scale_up_alarm = MetricAlarm(

name=scale_up_alarm_avarageCPU_name+ '-CPU70percent', namespace='AWS/EC2', metric='CPUUtilization', statistic='Average',

comparison='>', threshold='70', period='60', evaluation_periods=1,

alarm_actions=[scale_up_policy.policy_arn], dimensions=alarm_dimensions)

cloudwatch_conn.create_alarm(scale_up_alarm) cloudwatch_conn.create_alarm(scale_up_alarm)

50

comparison='<', threshold='20', period='60', evaluation_periods=10,

alarm_actions=[scale_down_policy.policy_arn], dimensions=alarm_dimensions)

cloudwatch_conn.create_alarm(scale_down_alarm)

except Exception, ex:

print ex

51

Appendix 2: Database migration

def MigrateDBToAWS():

#migrate database from a database server to another database server #Local DB

ListVars.RootDBServerUsername = 'username' ListVars.RootDBServerPassword = 'xxx' ListVars.database_name = 'databasename' ListVars.DBRootUsername = 'root' ListVars.DBRootPassword = 'xxx' ListVars.dbusername = 'webaccess' ListVars.dbpassword = 'xxx'

ListVars.OriDB_ip = '192.168.0.100' #AWS DB

ListVars.AWSDBMasterName = 'root' ListVars.AWSDBMasterPassword = 'xxx' ListVars.DBid = 'AwsNctu'

ListVars.HomeRegion = 'ap-southeast-1' ListVars.AWS_ACCESS_KEY_ID = 'KEY_ID' ListVars.AWS_SECRET_ACCESS_KEY = 'xxx' db_instance_type= 'db.m2.2xlarge'

temp = raw_input('Do you want to load the information that you had saved (Yes/No)?') if (temp.upper() == 'Y' or temp.upper() == 'YES'):

temp = raw_input('Do you want to load execute state that you had saved (Yes/No)?') if (temp.upper() == 'Y' or temp.upper() == 'YES'):

52

# state 1

SaveMigrateDBState(CreateFile=True, Function='CreateMySQLDB') else: print 'MySqlSecurityGroupAddListServers'

b = MySqlSecurityGroupAddListServers(filename='hosts') if(b == True):

# state 2

SaveMigrateDBState(CreateFile=False, Function='MySqlSecurityGroupAddListServers') else:

result = GetAWSDBInstanceStatus(DBid=ListVars.DBid, region=ListVars.HomeRegion,

ssh_local = paramiko.SSHClient()

ssh_local.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_local.connect(hostname=ListVars.OriDB_ip,

username=ListVars.RootDBServerUsername, password=ListVars.RootDBServerPassword)

# Check this function has done or not?

if(b_CreateAWSDatabaseUserViaLocalMySQLCommandLine == False):

print 'DumpDBFromLocalToAWS\n'

53

if(not b):

print '...' time.sleep(20)

print 'CreateAWSDatabaseUserViaLocalMySQLCommandLine\n'

b = CreateAWSDatabaseUserViaLocalMySQLCommandLine(ssh=ssh_local, host_ip=ListVars.AWSDB_ip ,

if(b_DoMySqlGrantForListServersAWS == False):

print 'DoMySqlGrantForListServersAWS\n'

b = DoMySqlGrantForListServersAWS(filename='hosts', ssh=ssh_local,

SaveMigrateDBState(CreateFile=False, Function='DoMySqlGrantForListServersAWS') else:

#Write DB configuration info to AWS message queue b = WriteDBConfigToSQS()

54

Appendix 3: Web migration

def MigrateWebsiteToAWS():

#migrate website from a server to another server

ListVars.WebsiteDirectory = os.environ['HOME'] +'/web' ListVars.Key_Pem_File = os.environ['HOME'] + '/lcc.pem'

ListVars.AWSWebServerRootUsername = 'ubuntu' ListVars.AWSWebServerRootPassword=''

ListVars.AWSWebsiteDirectory = '/var/www'

ListVars.ami = 'ami-bae2abe8' ListVars.instance_type = 'm1.large' ListVars.key_name = 'my_key'

ListVars.security_group = 'quick-start-1'

web_path = ListVars.WebsiteDirectory zip_file = 'web_temp.tar'

config_file = 'config.ini'

remote_folder = ListVars.AWSWebsiteDirectory

temp = raw_input('Do you want to load information that you had saved (Yes/No)? ') if(temp.upper() == 'Y' or temp.upper() == 'YES'): UpdateAWSListFile(ip=ip)

zip = zip_web_directory(zip_file=zip_file, web_path=web_path, new_config_db=config_file)

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try:

if(toAWS==True):

# AWS

55

print ListVars.AWSWebServerRootUsername print 'connect to remote server failed'

print e return False

print "SFTP connected successfully!"

remote_file_data = sftp.open(zip_file).read() md2 = md5.new(remote_file_data).digest()

print "Website copied successfully!"

AWSLoadBalanceAddInstance(instance=str(id))

相關文件