×
Community Blog Development to Deployment of 3-Tier Architecture of a Simple Web Application Using Alibaba Cloud

Development to Deployment of 3-Tier Architecture of a Simple Web Application Using Alibaba Cloud

Three tier applications are a base for development of modern-day dynamic websites. It all started by having on premises servers hosting server-side scripts running on a database engine.

Introduction
Three tier applications are a base for development of modern-day dynamic websites. It all started by having on premises servers hosting server-side scripts running on a database engine. Developers were using FTP applications to manage the files associated with the application.

blogpic

The picture above shows the basic framework on how a 3-tier application works. The presentation tier and application tier are developed using client-side scripting languages like HTML, CSS, JavaScript etc., and server-side scripting languages like PHP, JSP, ASP etc. The data tier is governed by database engines like MySQL, Oracle, SQL server etc. The end users access the application from the presentation tier using a thin client and the requests are processed using the application tier holding the server-side scripts. These scripts communicate with the database engine in the data tier and brings information to the user interface accessed in presentation tier. Whenever there is any change in the records stored in the data tier, it automatically reflects in the presentation tier. This is how the traditional 3-tier web application has been working. For providing security and better storage to the application, products from third party vendors were used.

With the advent of Cloud Computing, there has been a huge transformation in IT infrastructure for developing these applications. Public cloud service providers are providing a buff et of IaaS and PaaS services to leverage a faster and more eff ective software development. Alibaba Cloud, being the 3rd largest IaaS and PaaS service provider according to Gartner is providing a plethora of cloud services to enable the development of web and mobile applications. In this blog post, we discuss on how a prospective customer wanted to have a web application and how the solution architect provided a holistic solution to cater the needs of the customer.

Customer Scenario
Mr. Anuwat, an entrepreuner from the Kingdom of Thailand has been running a local business Anuwat Autoparts to manufacture EV chargers to fit all the EV cars available in the current market. He wants to expand the business to Singapore. So he and his CTO Sombat checked with quotations from leading cloud service providers and was not satisfied with the cost and the product functionalities from them. Finally Anuwat walked into the booth of Alibaba Cloud which was hosted during the IT Expo held in BITEC Bangna and met with the BD Wat and Solution Architect Zing. During this meeting, Anuwat explained about his requirement of having a web application hosted for Singapore users and to have more traffic to be managed. He expressed concerns that the current website he owns is prone to DDoS attack with a volume of 7 GBps. The network traffic is huge in such a way that the databases and applications must be isolated to provide a faster application catering the increasing number of visitors. He also mentioned that the database traffic can go upto 6000 connections per second.

Solution Architecture
Wat, the BD with Alibaba Cloud Thailand listened to this requirement and mentioned about the availability of coupons and free products to try with in the beginning. He also explained the client Anuwat on the cost optimization he could do on the products used. Anuwat was happy with the cost efficiency available with Alibaba Cloud and wanted a solution to his application. So there was a meeting scheduled between the clients Anuwat and his CTO Sombat with Zing, the Solution Architect with Alibaba Cloud Thailand. During this meeting, Zing presented the below architecture to cater the needs of Anuwat and the deal was finalized.

blogpic
After explaining the functionalities, Zing explained the Well Architected Framework to audit the cloud services consumed by the account Anuwat owns. The Cloud Governance Center was demonstrated to Anuwat on how to use it to analyze cost optimization, security and reliability of the products used.

Development and Deployment of Application
Sombat, the CTO of Anuwat Autoparts consults with his team of developers and gives the solution architecture proposed by Zing to develop a 3-tier web application. The step by step process on developing the web application of Anuwat Autoparts using the IT infrastructure from Alibaba Cloud is explained below.

Step 1: Identifying the regions and zones
Since the EV charger business is targetted on the users from Singapore, the developer team has identifi ed Singapore as the region of deployment. Inorder to have a high availability, it was decided to have a Virtual Private Cloud (VPC) in Singapore with vSwitches in Zone B and C.

Step 2: Creating the VPC
Get into the console of VPC.

blogpic

Click on the VPC in the left pane.
blogpic

Select the region as Singapore and click on "Create VPC".
blogpic

Enter a unique name for VPC as we have entered "AnuwatVPC" and select a IPv4 CIDR block. Here we have selected 10.0.0.0/8 and scrolled down.
blogpic

Select a resource group where the VPC should be grouped in. Then create the vSwitches in Zone B and C with the subnet CIDR for each vSwitch. The architecture preview is generated as shown in the picture below.
blogpic

Now click OK.
blogpic

The VPC and the 2 vSwitches are successfully created. Now the infrastructure stays as shown in the figure below.
blogpic

Step 3: Create a Virtual Machine and generate its image
Get into the console of Elastic Compute Service (ECS).
blogpic

Click on "Create Instance".
blogpic

Select the options as highlighted and scroll down. These options are selected to opt for pay as you go instance in the Zone B of Singapore region.
blogpic

Select the type of ECS instance, mention the number of instances and scroll down.
blogpic

Specify the operating system and its version and then click "Next".
blogpic

Select the VPC and vSwitch. Then select to assign private and public IP addresses.
blogpic

Scroll down and click "create a security group".
blogpic

Click on "Create Security Group".
blogpic

Enter a name for security group, select the VPC and the resource group. Now configure the inbound and outbound rules. Since we use a web application accessing web ports and databases, we allow the ports 80, 443 and 3306. To keep things simple for the purposes of this example, we will use 0.0.0.0/0. However, for safety reasons in actual practice, we recommend that you allow access only over addresses and ports that you trust.
blogpic

Set the rules for inbound and outbound connections. Then click "Create Security Groups".
blogpic

Now go back to the tab of ECS instance and click on Reselect Security Groups.
blogpic

Select the security group created recently and click OK. Then click on Next.
blogpic

Set the ECS instance to have a custom password and enter the password to login.
blogpic

Enter a name for the instance and then click Next.
blogpic

Select the resource group and click Next.
blogpic

Review the configurations, check on the terms of service and then click "Create Instance".
blogpic

Now the ECS instance is created. Go to the instances section of ECS console and click on the instance ID of the ECS instance.
blogpic

Click on Connect.
blogpic

Sign in to the workbench.
blogpic

Update the libraries using apt update command.
blogpic

Now install php, php-msqli and configure the default fi le of nginx.

Step 4: Create RDS Instance
Get into the console of ApsaraDB RDS.
blogpic

Click on "Create Instance".
blogpic

Select the options as shown in the figure and scroll down.
blogpic

Select the nodes and product type. Then scroll down again to select the instance type with more than 6000 connections.
blogpic

Click Next.
blogpic

Select the VPC we created and added the ECS earlier. Now scroll down for more options. Select the resource group and click "Confirm Order".
blogpic

Check on the terms of service and click "Pay Now". Then go back to the RDS console.
blogpic

It takes some time to create the RDS instance. Once it gets created, it will have a green tick mark. Click on the RDS instance.
blogpic

Click on Whitelist and SecGroup to add the internal IP address of the ECS instance.
blogpic

Similarly click on Security Group and select the apt one we created earlier.
blogpic

Click on Databases. Create a database named wordpress and associate with a standard account created.
blogpic

The access mode topology of the RDS instance is shown below.
blogpic

Go back to the overview of instance. Click on "View Details" in network type.
blogpic

Copy the internal endpoint for further usage. Similarly, click on Database Connection.
blogpic

Click on "Log on to Database". DMS interface opens and try add the instance by entering all details.
blogpic

Click on Test Connectivity.
blogpic

Click OK and then click "Submit". Once the connection is successful, the database created will be seen.
blogpic

Step 5: Create custom image of ECS instance
Go to the ECS console and click on the ECS instance created.
blogpic

Scroll down and click "Create Custom Image".
blogpic

Enter the name of the image, select resource group and click 'OK'. Click on the Images in left pane.
blogpic

The interface lists the custom image which is getting created. This image enables easier setup of ECS instances without installing wordpress and other tweaks.

Step 6: Connecting PHP files in ECS with MySQL in ApsaraDB RDS
Enter the public IP address of the ECS instance in the browser. It should open the welcome page of nginx. Edit the index.php fi le as below.
blogpic

Save this fi le and exit to the command prompt. Enter the public IP of this ECS instance from the browser and it should display as below.
blogpic

Now we create this ECS instance as a custom image and load it into the other ECS instances we create. Now the ECS instances are created in the vSwitches of VPC.
blogpic

Step 6: Connect all the ECS instances to a Server Load Balancer
blogpic

Enter this IP address in your browser and see how the database is accessed by multiple ECS instances.
blogpic

Cloud Monitor for RDS
blogpic

Cloud Monitor for one of the ECS instances
blogpic

Cloud Monitoring of Server Load Balancer
blogpic

With this blog, we can understand the usage of Alibaba Cloud products to develop a 3 tier application.

0 1 0
Share on

ferdinjoe

21 posts | 137 followers

You may also like

Comments