Baidu App Deployment Cheats

Source: Internet
Author: User
Tags network function virtual environment

"Introduction to the Background"

Traditional PAAs uses sandbox to implement the resource security isolation between the app, sandbox needs the operating environment and programming language for the underlying functional limitations, such as: Prohibit the creation of processes and threads, prohibit some system calls, prohibit the reading and writing of some system paths, prohibit the loading of C language modules, Prohibit certain network function, this greatly increases the developer's development cost, also makes the application development and the cross-platform migration difficulty calls the handover and the study cost to be big, is unfavorable to the platform promotion. Another major problem for developers is that the application's cloud environment is inconsistent with the developer's local development environment, and many features are limited. Developers in the local development of debugging applications, published to the cloud in the face of the sandbox restrictions can not run, have to be modified for the cloud environment. BAE uses lightweight virtual machine technology for resource isolation, with no restrictions on the operating environment and programming language level, and the application's cloud-based environment is consistent with the developer's local development environment, minimizing learning costs, development and migration costs, and maximizing developer productivity. The difference between resource isolation (left) and light-weight virtual machine technology for resource isolation (right) is shown in sandbox technology:

One, server deployment assessment

There may be an incremental optimization process for application deployment computing traffic, in order to prevent avalanche benefits from sudden traffic bursts, for the PHP execution Environment (code Hello World), a single execution unit concurrently 20, the QPS reaches the 530 maximum threshold, and again increases the QPS will decrease, Single Execution unit configuration: Single core, memory 512, bandwidth 10M. Some of the test data are as follows:

Note: Current pressure measurement data is the simplest throughput check for the execution unit. is a secondary check on and off-line, and this data is reduced in magnitude when there is a backend service

Second, the characteristics

The execution unit consists of a set of processes running within a lightweight virtual machine, and each execution unit corresponds to a light-weight virtual machine. Developers don't need to be concerned with the existence of a lightweight virtual machine, just focus on the execution unit of the deployment.

Suppose there is a BAE deployment that allocates two execution units, each of which corresponds to a lightweight virtual machine that, after the execution unit starts, corresponds to a set of processes within the lightweight virtual machine, including the LIGHTTPD and PHP-FPM processes. If one of the lightweight virtual machines fails, the BAE platform automatically assigns them a lightweight virtual machine and deploys the execution unit to the new lightweight virtual machine, which is the migration of the execution unit. This technology ensures high reliability of the application.

There are no restrictions on the operating environment and programming language: There are no restrictions on the running environment and programming languages, including creating processes, creating threads, system calls, executing C extensions, and file system access.

Multiple programming language support: PHP, Python, Java, and node. JS are currently supported, and support for mainstream development languages will be added in the future. Current bae4.0 developers can also customize the operating environment

Programming Framework Support: There is no limit to the programming language level and supports all programming frameworks for specific programming languages accordingly. Whether it's a mainstream or niche framework, the cloud can run as long as it works in a developer's local environment.

Automatic installation of dependent packages: by configuring a dependency package file, the cloud environment can automatically install user-specified dependency packages. For example, Package.json is a NPM configuration file for the Nodejs-web deployment type that configures the dependency package at node. JS compile time and the portal file at startup, and the dependencies that are configured from Package.json are installed at compile time at the application root. bae/node_ The modules directory. Similarly, Requirements.txt is a user-defined dependency profile for the Python-web/python-worker deployment type that configures the dependency package at compile time. When the developer deploys the code, the Requirements.txt file is added, and the specified dependent packages are downloaded to the Deps directory that is installed in the app's root directory.

Rich Service Support: provide a variety of extended services, including MySQL, MongoDB, Redis, Log, port, etc.

Free Network access: Most PAAs external network access needs to go through HTTP proxy or socket proxy, while BAE external network access without proxy layer forwarding. In addition, BAE provides extension services port, which allows developers to customize TCP ports for external services for more complex business logic.

New worker type: Most PAAs only provides the type of Web deployment, BAE on this basis to provide worker types, mainly for background tasks, such as crawlers, long-running in the background, and constantly crawl all kinds of network resources.

Local development environment: BAE provides a local development environment based on the cross-platform virtualization tool VirtualBox and virtual machine creation tool vagrant, which simulates a virtual environment that is fully consistent with BAE's cloud execution unit, ensuring that local debug code is deployed to the cloud and released smoothly It saves the debugging cost due to the inconsistency of the local and the cloud environment, and improves the development efficiency to some extent.

Environment deployment: The local development environment is the Ubuntu virtual machine (12.04.2 LTS, 64bit) provided by BAE for developers to use the BAE CLI tool for local debugging.

Relying on the cross-platform virtualization tool VirtualBox and virtual machine creation tools vagrant, the local development environment ensures that the code deployed to BAE can be released smoothly by simulating a virtual environment that is fully consistent with the BAE remote execution unit. The cost of debugging caused by inconsistency between local and remote environment is saved, and the development efficiency is improved to some extent.

Note: Building and using the local development environment can help developers to circumvent the potential problems caused by inconsistencies between local and remote environments, in the optional (optional) category, not the necessary action to deploy Web apps using Bae

Install dependent packages under Windows

A. Download the localenv package and unzip it.

B. Install vagrant and virtual Box from the Localenv/software directory in the unpacking package

C. Add the installation path of the dependent package to the executable path.

1) Click Start, right-click Computer in the pop-up menu, and select Properties from the drop-down menu to open the System Properties dialog box.

2) Click Advanced System Settings in the right panel to open the Advanced System Settings dialog box.

3) Click Environment Variables at the bottom right of the advanced view to open the Environment Variables dialog box.

4) Edit the user executable path or the system execution path, add the installation path of the dependent package and save it. Use semicolons (;) separated by default to install the dependency package as an example, and the path you need to add is as follows:

D:\HashiCorp\Vagrant\bin; C:\Program files\oracle\virtualbox\

Attention:

Modifying a user-executable path affects only the current user, and modifying the system execution path affects the user.

Linux Install dependent packages

A. Download the dependent package. Vagrant (version higher than 1.2.2) VirtualBox

1. Install the dependent packages.

Install vagrant 1.3.5 and virtual Box with debian-based system (Ubuntu, Debian)

4.2.4 For example, execute the following command:

$ sudo dpkg-i ~/downloads/vagrant_1.3.5_x86_64.deb

$ sudo dpkg-i ~/downloads/virtualbox-4.2_4.2.16-86992~ubuntu~precise_amd64.deb

Common development debugging commands that use the local development environment are as follows:

• Publish locally using the BAE CLI tool

$ BAE App publish--local

For more information on how to use the BAE CLI tools, see the CLI Getting Started guide.

• View a locally released deployment

php/python/node.js/static:$ Curl 127.0.0.1:8080-h "Host: $app _domain"

java:$ Curl 127.0.0.1:8080/$war _name/

• Add support for additional languages in a single-language virtual machine environment: $ bae_install <Programming_Language>

If the current virtual machine environment only supports PHP language, execute ' bae_install,java, then you can debug both PHP and Java language applications locally.

Third, the local environment to build

If the user wants to set up a local real-world environment, here is an example of a Linux environment setup, such as: Determine what domain name you want to use to access the application, the following example with Phpoffline.duapp.com.

/home/bae (should already exist, BAE user home directory, run entry directory)

/home/bae/bae (PHP directory, PHP Environment)

/HOME/BAE/LIGHTTPD (lighttpd directory, lighttpd-1.5.0)

/home/bae/wwwdata

/home/bae/wwwdata/htdocs (lighttpd access root directory)

/home/bae/wwwdata/htdocs/phpoffline.duapp.com (the application directory of the BAE platform is the domain name you define)

Deploying LIGHTTPD with BAE users

Download the tar package to my Web disk:

http://pan.baidu.com/share/link?shareid=78893&uk=1846015233

After unpacking, the LIGHTTPD directory in the package corresponds to the/HOME/BAE/LIGHTTPD directory, (by this directory structure will save a lot of configuration work, self-measurement:)

Next, modify the LIGHTTPD configuration file:

LIGHTTPD White list: Use the whitelist domain name to access the machine, will be lighttpd allowed.

[[email protected] home]# vi/home/bae/lighttpd/conf/domain_whitelist (Whitelist config file)

Add the domain name you want to use phpoffline.duapp.com, save exit

LIGHTTPD configuration: Configure various parameters and paths for LIGHTTPD

[Email protected] home]# vi/home/bae/lighttpd/conf/lighttpd.conf

Var.rundir = "/HOME/BAE/LIGHTTPD"

Var.wwwdir = "/home/bae/wwwdata/htdocs"

Var.netpath = "10.40.72.110 (here is your machine IP): 9898/log"

To add a forward using Lua:

$HTTP ["host"] =~ "^ (. *) $" {

Vhost-magnet.path-pattern = Var.wwwdir + "/%_"

Vhost-magnet.attract-raw-url-to = ("/bae_app_conf.lua")

}

Hosts and soft chain

Root account log in to the virtual machine, modify the Hosts file

[Email protected] home]# vi/etc/hosts

Add a line like this:

10.**.**.**.** phpoffline.duapp.com, save exit

BAE users create a soft chain under/home/bae/wwwdata/htdocs, pointing to the app's directory/home/bae/wwwdata/phpoffline.duapp.com

If you are accessing under Windows, configure the domain name in the hosts and the mapping of the application deployment IP, such as: 10.**.**.**.** phpoffline.duapp.com (Linux sebserver server address)

Deploying PHP

First of all, go to My network. Download the TAR Package for PHP deployment: http://pan.baidu.com/share/link?shareid=78968&uk=1846015233

After the download, there are three directories, put under the/home/bae/bae

Modify the appropriate configuration file for PHP:

First check the/home/bae/bae/php/etc/php-fpm.conf, the 2 configuration is consistent with the path

Then check the/HOME/BAE/BAE/PHP/SBIN/PHP-FPM, these 3 places with consistent

Finally, Vi/home/bae/bae/phplib/php.ini

Locate the Open_basedir key and replace the/home/bae/wwwdata/htdocs/*******.com with:/home/bae/wwwdata/htdocs/phpoffline.duapp.com

Find the Error_log item and confirm it is this:/HOME/BAE/LIGHTTPD/LOG/PHP.LOG.WF

Start the service

PHP Start/stop:

[[email protected] home]#/home/bae/bae/php/sbin/php-fpm start (stop)

LIGHTTPD Start/stop:

[[email protected] home]#/home/bae/lighttpd/bin/lighttpd_control start (stop)

Deploying Apps

First from SVN on the co-need version (4-bit version to be developed or the latest baseline, etc.)

Enter the virtual machine under the/home/bae/wwwdata/htdocs/phpoffline.duapp.com, through the SVN Co command to get the code under the directory (should be a appid**** directory, directory structure should be: app.conf, index.php). The URL for the second scene is Https://svn.duapp.com/appid0d9c295kd8. The/home/bae/wwwdata/htdocs/directory below establishes a soft link to the Appid0d9c295kd8 of the domain name phpoffline.duapp.com to the CI directory.                                                   The app can be accessed through Windows or Linux. Ln–s appid0d9c295kd8/home/bae/htdocs/phpoffline.duapp.com

Iv. conversion relationships between app.conf and Bae_app_conf.lua

The code is uploaded using app.conf, but when it is forwarded, it is lighttpd when it is used. This is because when the code is released when the platform to app.conf forwarding switch, app.conf Introduction please refer to: https://bce.baidu.com/doc/BAE/GUIGettingStarted.html#. E9.85.8d.e7.bd.aeapp.conf

This generates conversions with a benchmark app.conf and Bae_app_conf.lua:

For other conversions please refer to: Http://pan.baidu.com/s/1bnTUijP

For more dry foods, please pay attention to "Baidu MTC Academy" Http://mtc.baidu.com/academy/article

Baidu App Deployment Cheats

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.