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.
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.
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.
Click on the VPC in the left pane.
Select the region as Singapore and click on "Create VPC".
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.
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.
Now click OK.
The VPC and the 2 vSwitches are successfully created. Now the infrastructure stays as shown in the figure below.
Step 3: Create a Virtual Machine and generate its image
Get into the console of Elastic Compute Service (ECS).
Click on "Create Instance".
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.
Select the type of ECS instance, mention the number of instances and scroll down.
Specify the operating system and its version and then click "Next".
Select the VPC and vSwitch. Then select to assign private and public IP addresses.
Scroll down and click "create a security group".
Click on "Create Security Group".
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.
Set the rules for inbound and outbound connections. Then click "Create Security Groups".
Now go back to the tab of ECS instance and click on Reselect Security Groups.
Select the security group created recently and click OK. Then click on Next.
Set the ECS instance to have a custom password and enter the password to login.
Enter a name for the instance and then click Next.
Select the resource group and click Next.
Review the configurations, check on the terms of service and then click "Create Instance".
Now the ECS instance is created. Go to the instances section of ECS console and click on the instance ID of the ECS instance.
Click on Connect.
Sign in to the workbench.
Update the libraries using apt update command.
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.
Click on "Create Instance".
Select the options as shown in the figure and scroll down.
Select the nodes and product type. Then scroll down again to select the instance type with more than 6000 connections.
Click Next.
Select the VPC we created and added the ECS earlier. Now scroll down for more options. Select the resource group and click "Confirm Order".
Check on the terms of service and click "Pay Now". Then go back to the RDS console.
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.
Click on Whitelist and SecGroup to add the internal IP address of the ECS instance.
Similarly click on Security Group and select the apt one we created earlier.
Click on Databases. Create a database named wordpress and associate with a standard account created.
The access mode topology of the RDS instance is shown below.
Go back to the overview of instance. Click on "View Details" in network type.
Copy the internal endpoint for further usage. Similarly, click on Database Connection.
Click on "Log on to Database". DMS interface opens and try add the instance by entering all details.
Click on Test Connectivity.
Click OK and then click "Submit". Once the connection is successful, the database created will be seen.
Step 5: Create custom image of ECS instance
Go to the ECS console and click on the ECS instance created.
Scroll down and click "Create Custom Image".
Enter the name of the image, select resource group and click 'OK'. Click on the Images in left pane.
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.
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.
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.
Step 6: Connect all the ECS instances to a Server Load Balancer
Enter this IP address in your browser and see how the database is accessed by multiple ECS instances.
Cloud Monitor for RDS
Cloud Monitor for one of the ECS instances
Cloud Monitoring of Server Load Balancer
With this blog, we can understand the usage of Alibaba Cloud products to develop a 3 tier application.
Developing and Deploying a Tensorflow Model Using PAI DSW and PAI EAS for a Custom Image Dataset
Setting Alibaba Cloud ECS Instance With NGINX Supporting PHP and MySQL
Hironobu Ohara - February 3, 2023
Alibaba Clouder - October 29, 2018
Alibaba Clouder - June 10, 2020
Alibaba Clouder - August 14, 2020
ferdinjoe - February 28, 2024
JJ Lim - January 4, 2022
Respond to sudden traffic spikes and minimize response time with Server Load Balancer
Learn MoreMulti-source metrics are aggregated to monitor the status of your business and services in real time.
Learn MoreCustomized infrastructure to ensure high availability, scalability and high-performance
Learn MoreBuild business monitoring capabilities with real time response based on frontend monitoring, application monitoring, and custom business monitoring capabilities
Learn MoreMore Posts by ferdinjoe