×
Community Blog Best Practices of Web Applications Development and Hosting

Best Practices of Web Applications Development and Hosting

Want to learn web applications development and hosting on Alibaba Cloud with high availability, fault tolerance and load balancing.

The demand in business applications is growing fast and developers are facing many challenges such as evolutivity, scalability, and re-usability. In order to satisfy business needs, developers around the world need to create new tools that will help them solve the above presented challenges.

How to Develop Web Applications on Alibaba Cloud with Django Framework

With the development of cloud infrastructure, some of these challenges, particularly scalability and evolutivity, can be easily solved. It is now possible to do anything in the cloud, even coding with function-as-a-service (FaaS) products like Function Compute. But, to solve the re-usability problem, the solution must come from the code used for the application we are developing. This is where the Django framework comes in handy, in the way it is a useful tool to develop reusable web app and in a short time.

The purpose of this tutorial is to show you how you can build your an application right from the cloud, by using a web framework tailored to address current challenges web developers face. I hope this tutorial will help you to understand how you can build your own development environment on the cloud and benefit from the ubiquity of that solution.

Why Django?
Before we discuss about Django, let's take a step back to better understand what a web application is. A web application is a set of code written in a programming language that will be rendered on a browser, which typically addresses a well-defined problem. For example, it can be a blog post (like this article!), an e-commerce website, or even a social network.

Okay, that's pretty straightforward, but what is a web framework? Web frameworks are reusable collections of components that handle many of the common and repetitive tasks of web-application development in an integrated fashion. Instead of requiring you to obtain disparate libraries of code and find ways to make them work together, web frameworks provide all the necessary components in a single package and take care of the integration work for you.

Great. Now that we're familiar with the concepts of web apps and frameworks, let's talk about Django. Django is one of the most recent web frameworks that is aimed at simplifying web app creation. Django gives you a set of tools that will help you quickly develop highly dynamic web applications that are re-usable, scalable and clean.

Django is built upon the DRY (Don't Repeat Yourself) paradigm, which means that in every step of the development process, you will have to write less code that the average needed using another framework.

In these series of tutorials, I'll guide you through the development of several applications and show you how the various components and applications bundled with Django can help you write less code at each stage of the development process, and how you can do all these things in the cloud. We will be running our web application on an Alibaba Cloud Elastic Compute Service (ECS) instance. I will not be covering the steps for setting up Django on your ECS. Instead you can refer to these two tutorials to learn more:

  1. https://www.alibabacloud.com/getting-started/projects/how-to-deploy-django-application-on-alibaba-cloud
  2. http://www.alibabacloud.com/blog/how-to-deploy-a-django-application-with-docker_581157

Defining Our Project

The project we are going to build is an e-commerce web application where people can buy or sell items. For flexibility and maintainability reasons, the project will be split in three independent apps: the Core app, the Cart app and the Payment.

Used Blog

Automated Web App Deployment from GitHub Push Using Alibaba Cloud EDAS

Alibaba Cloud Enterprise Distributed Application Service (EDAS) is providing PaaS platform for hosting applications and micro services with high availability, monitoring and release management capabilities. To extend the EDAS capabilities, we can build continuous integration/deployment solution using EDAS and Jenkins.

In this tutorial, I'll demonstrate how a sample website can be hosted in EDAS platform and can be website upgraded automatically as soon as the new version of code is committed into GitHub.

Architecture

For this article, we'll be using a web application written in Java and war build of this application is deployed in EDAS. Also, source code of this application is maintained in GitHub repository.

Any changes of the GitHub repository will be pushed to Jenkins and build of Jenkins pipeline project will be automatically triggered to generate new war file with latest version of the source code and to deploy the war file using EDAS API into same EDAS application.

Configure OSS, ECS and EDAS

Please decide a single region (Preferably China- Beijing) for configuring all the required Alibaba cloud services before you proceed. This will help you to avoid any technical challenges of integrating multi region services.

  1. Create a new bucket in OSS console to store web application java war file, which will be deployed as EDAS application. Make sure bucket access policy is set to public read. Otherwise, EDAS instance may not be able to fetch the war file for deployment.
  2. Keep a note of bucket name and OSS end point. Later you'll have to update the configuration file of this solution with bucket name and OSS end point.
  3. Create ECS Instance with minimum 1 GB memory and CentOS 7.4 OS in Alibaba cloud console. Choose region same as OSS region. Also, create a new VPC network for this host and allocate public IP.
  4. Once ECS instance is up and running, install EDAS agent after connecting to the host using VNC. Below is the command to be executed for installing agent. Please change the region part depending on the region of ECS host. In this example"e cn-beijing" is the region of our ECS.

Deploy Web Apps with High Availability, Fault Tolerance, and Load Balancing on Alibaba Cloud

1. Introduction

High Availability (HA), Fault Tolerance (FT), and Horizontal Scale Friendly (HSF) are as equally important as to functionality for web applications to run and succeed today. Existing or new web applications shall be designed and provisioned with such architecture underlying. Fortunately, you can easily and promptly deploy mentioned architecture in the Cloud era today (compared to the on-premises bare-metal machine era)! However, this flexibility comes with a caveat – how to choose the right cloud provider? We are spoiled with choice when it comes to choosing cloud providers and it can be really challenging (and hectic!) when evaluating and choosing the right one.

This post is intended to discuss and provide a walkthrough on deploying web applications on Alibaba Cloud from the ground up, including HA, FT, and HSF. There is no intention to discuss on requirement analysis and capacity planning on particular specific domain (I’m a newbie to Alibaba Cloud). Anyway, throughout this post, I will briefly introduce several services & tools provided in Alibaba Cloud. Yes, briefly! If you wish to learn more on particular services or tools, please visit the Documentation Center. In addition, the post would also highlight the concerns and considerations when deploying such services.

WordPress is used as the demo web application that would be deployed on Alibaba Cloud in this post. The same deploying principle shall apply to many other web applications. This post is not intended to discuss on WordPress configuration at all. It shall not (and not able to) serves as reference for WordPress configuration. There are tons and tons of good resources out there regarding best practices on WordPress administrative.

2. High-level Architecture:

Like many other web applications, the demo web application consists of application layer (WordPress) and DB layer (MySQL).

In order to achieve such “simple” goal, the demo web application must deployed with the following ‘minimum’ requirements:

  1. One sites: Single main site.
  2. Minimum two physically separate running WordPress instances on each site for redundancy and load balance purpose.
  3. Auto spawning on WordPress instance when existing instance stopped/failure.
  4. The DB instance (MySQL) must also be running in redundancy mode. Automatic failover to active standby instance when necessary.
  5. Centralized dataspace. Shared resource must be accessible and available to all running WordPress instances. For e.g. document uploaded by a user via WordPress should be synced across all running WordPress instances.

Fortunately, Alibaba Cloud provides a list of services and tool for us to fulfill such ‘minimum’ requirements. In this post specifically, we would utilize Cloud DNS (DNS), Auto Scaling Group (ASG), Server Load Balancer (SLB), Elastic Compute Service (ECS), Relational Database System (RDS), Object Storage Service (OSS), and Object Storage File System (OSSFS) tool to achieve mentioned Goal. The high-level architecture diagram for the deployed WordPress would be as following:

high-level architecture diagram

Related Products

Simple Application Server

Simple Application Server is a new generation computing service for stand-alone application scenarios.

Elastic Compute Service

Deploy ECS instances with just a few clicks from the easy-to-use console and scale capacity up or down based on real-time demands.

Related Courses

Using ECS to Construct a Dynamic Website

Want to learn how to construct a dynamic website that can actively update its content? In this Clouder lesson, you will learn how to build a WordPress website on Alibaba Cloud. The language of instruction in the video course is Cantonese. All presentation materials and exam questions are in English.

Using ECS to Construct a Dynamic Website

Want to learn how to construct a dynamic website that can actively update its content? In this Clouder lesson, you will learn how to build a WordPress website on Alibaba Cloud.

Related Documentation

Get started with Web Hosting

Web Hosting is equipped with built-in OS, databases, FTP sites and other services, which enable you to readily build a website. This article helps you familiar with the preparations and process on building a website.

Preparations

Before you start building a website with Web Hosting, you need to consider and prepare the following:

Domain name

A domain name represents the server of a website on the Internet. With a domain name, one can search and visit your website. Therefore, before you start building and publishing your website, you need to register a domain name.

Website source code and data

Prepare the source code and data of your website and compress them into a package.

  1. If you have written the website source code in your computer, and you want to use a Web Hosting instance to be the server, you need to migrate the code and data to the Web Hosting instance.
  2. If you want to use a website content management system to build a website on a Web Hosting instance, choose a website content management system, such as WordPress, and download its compressed package.

Why is verification required for logon to the background through a Web Hosting instance with WordPress

After you install WordPress in a Web Hosting instance, you have resolved CNAME to the test domain of the Web Hosting instance. After you bind the formal domain name, you can use the formal domain name to access the website. However, logon verification is required when you log on to the background.

Cause

A test domain name is entered during the installation of WordPress, so WordPress calls the address suffixed with *.aliwebs.com and jumps to the test domain name. The test domain name of the Web Hosting instance is used for debugging the website. Therefore, verification is required when you log on to the background.

Related Market Products

Protect Your Web Application on Alibaba Cloud

Understand application security and common network attacks. You will master the core skills of application security on the cloud, including how to access Alibaba Cloud WAF, avoid tampering website, prevent CC attacks, and how to conduct business risk management.

LAMP Stack PHP 7

Classical web application environment with LAMP stack and the next generation of PHP version 7. It also includes Selfmanagement Preset, a self-management, self-monitoring and self-healing components and phpMyAdmin, a web interface tool for the administration of MySQL.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 758 followers

You may also like

Comments