The LAMP (linux-apache-mysql-php) website architecture is currently the international popular web framework, which includes: Linux operating system, Apache network server, MySQL database, Perl, PHP or Python programming language, All components are open source software, is a mature international architecture framework, many popular commercial applications are to take this framework, and JAVA/J2EE architecture, lamp with rich web resources, lightweight, rapid development features, Microsoft's. NET architecture, lamp has the advantage of universal, Cross-platform, high-performance, low price, so lamp whether it is performance, quality or price are the preferred platform for enterprises to build the site.
For large traffic, large concurrent amount of Web Site system architecture, in addition to the hardware using high-performance servers, load Balancing, CDN, etc., in the software architecture needs to focus on the following aspects: the use of high-performance operating system (OS), High-performance Web server (Web servers), High-performance Database (DATABSE), efficient programming language, etc. Below I will discuss from these points to its one by one.
Operating system
The Linux operating system has many different distributions, such as Red Hat Enterprise Linux, SUSE Linux enterprice, Debian, Ubuntu, CentOS, and each distribution has its own characteristics, such as rhel stability, Ubuntu's ease of use, based on stability and performance considerations, operating System Selection CentOS (Community ENTerprise operating system) is an ideal solution.
CentOS (Community ENTerprise operating System) is one of the Linux distributions, a streamlined free version of rhel/red Hat ENTerprise Linux, and Rhel for the same source code, but Enterprise editions, such as Rhel and SuSE le, offer upgrades that are not available for free online upgrades, so requiring a free, highly stable server can be used CentOS instead of Red Hat Enterprise Linux.
Lamp Web site Architecture Map
Web servers, caching, and PHP acceleration
Apache is the core of the lamp architecture Web Server, open source, stable, modular rich is the advantage of Apache. But the disadvantage of Apache is that it is bloated, memory and CPU overhead, performance loss, less efficient than some lightweight Web servers (such as Nginx), and lightweight Web servers are far more responsive to static files than Apache servers.
Apache as the Web server is the best choice for load PHP, if the traffic is very large, you can use Nginx to load non-PHP Web requests. Nginx is a high-performance http and reverse proxy server, Nginx is known for its stability, rich feature sets, sample configuration files, and low system resource consumption. Nginx does not support dynamic languages such as PHP and CGI, but supports load balancing and fault tolerance, which can be used in conjunction with Apache, and is the preferred choice for lightweight HTTP servers.
Web server caching has a variety of scenarios, Apache provides its own cache module, can also use the addition of Squid module for caching, both of which can effectively improve Apache access response capabilities. Squid cache is a Web caching server, support efficient caching, can be used as a Web server cache related requests to the server to improve the speed of the Web server, squid on the front end to cache the Web server generated dynamic content, The Web application only needs to set the actual time of the page. If you have a huge amount of traffic, consider using Memcache as a distributed cache.
The accelerated use of PHP eaccelerator Accelerator, Eaccelerator is a free and open source PHP accelerator, optimized and dynamic content caching, improve performance PHP script cache performance, so that the PHP script in the compiler state, the cost of the server almost completely eliminated. It also optimizes the script to accelerate its execution efficiency. So that the PHP program code efficiency can be increased 1-10 times.
Specific solutions are available in the following ways:
1, squid + Apache + PHP + eaccelerator
Using Apache load PHP, using squid for caching, HTML or picture requests can be returned directly to the user by squid. This architecture is used by many large web sites.
2, Nginx/apache + PHP (fastcgi) + eaccelerator
Use the Nginx or Apache load php,php to run in fastcgi mode with high efficiency.
3, Nginx + Apache + PHP + eaccelerator
This scenario combines the advantages of nginx and Apache, using the Apache load Php,nginx to parse other Web requests, using the Nginx rewrite module, and the Apache port is not open to the outside.
Database
Open source database, MySQL in performance, stability and function is the first choice, can achieve millions other data storage, the site can be MySQL and Web server in the early days together, but when the number of visits reached a certain scale, should be the MySQL database from the Web server Independent, Run on a separate server while maintaining a stable connection between the Web server and the MySQL server.
When database access reaches a greater level, consider using a database cluster such as a MySQL cluster or a hash of a library table.
In general, the Lamp architecture site performance will be far superior to Windows IIS + ASP + access (such as Moonlight blog), such as Web sites, can load the traffic is also very large, a large number of domestic personal sites to support large traffic, the use of lamp architecture is a good solution.
To sum up, based on lamp architecture design with low-cost, flexible deployment, rapid development, security and stability characteristics, is the Web network applications and environmental excellent combination.