High-performance Site architecture Scenarios

Source: Internet
Author: User
Tags log log mysql manual

High-performance Web site architecture, this paper discusses the seven-point web site architecture, to optimize the response time of the website, the implementation of large-scale Web site technology Architecture solution. Whether it is e-commerce or other websites and is available. First, optimize the site response time of the architecture scheme: the    site can stay in the user, on the one hand is to see the content, on the other hand, look at response time. There are usually several ways to reduce your site response time:    1. Reduce the HTTP request. Includes merging CSS and JavaScript. Reduce the number of images, such as the use of CSS offset technology to select a different location in a picture. Using the browser's cache function, we can declare in the header whether it is cached by the browser.    2, dynamic content static. such as the permanent generation of HTML files. Generate static files and set the time to live, and then query for new dynamic content after expiration.    3, optimize the database. The performance of the database is a priority in the overall performance of the project. Well-designed MySQL has an n magnitude higher than a messy MySQL performance, and more conceivable is introduced to NoSQL, such as Redis,mongodb.    4. Use load Balancing. Distribute the request reasonably to more servers.    5, use the cache. Take time and resource-expensive calculation results out of cache and avoid duplication of calculations. For example, in front of MySQL to block a layer of memcached. For example, generate a file, use the include in the time. Again, such as PHP Opcache. Second, the Pressure test architecture scheme:    throughput rate refers to the number of requests processed per unit of time, Unit reqs/s. Maximum throughput is the maximum number of requests that can be processed within a unit of time. The method of simulating a sufficient number of people and concurrent requests to test the maximum throughput is called a stress test. such as Apache's own AB (Apache Bench). There are many parameters of AB, common number of requests (-N), concurrent users (-c), time-out (-t), long connection (-K), Attachment a cookie (-C name=value)
$ab-C 10-n http://localhost/
Three, long-connected architecture scheme: Each request requires a TCP three handshake, the handshake is more than the formal connection, and then send the data. Then, the n request, it takes 3N times handshake, pass n data, get n response, a total of 5N. If the n request is synthesized by a request, it is 3 handshake, 1 passes the data, 1 returns the response, a total of 5 times. However, sometimes we need the return result of the last response to send a new round of requests, at which point the merge request is not well implemented, which requires a long connection. It is simple to use and contains the following in the header:
Connection:keep-alive
Both the client and server can set the maximum time for a long connection, whichever is the smaller when the two are not uniform. Stress test after opening a long connection:
$ab-C 10-n http://localhost/
Found that ascension is more than 35 times times. This machine is up to 8 times times more performance.

Iv. architecture for improving the response speed of MySQL: Handlerocker was developed by an architect in Japan. A plugin for MySQL. Handlerocker implements the SQL parsing layer that bypasses MySQL. Available in Mysql5.1 or above, see MySQL manual for details. This is not a description.

Five, MySQL master-slave replication Architecture Scheme: In the distributed deployment, 1 main libraries, n from the library. The main library is written only and is only checked from the library. The main library from the library data needs to be unified, this is the master-slave replication.

The advantages are:

1. When backing up from a library, the main library can continue to process updates.

2, optimize the response time.

3, increase the robustness of. The main library is hung and can be switched to from the library as a backup.
The master-slave replication implementation process has three steps, 1 in the main library, 2 in the slave Library:
1. The primary library server saves the user's updates to the database in binary format to the binary log log file. The Binlog dump thread then transfers the binary log log file to the slave library server.
2. Copy the update operation from the binary log log file of the primary library server to a trunk log file called Relay Log from the library server through an I/O thread.
3, from the library server through another SQL thread relay log relay logs files in the local execution, in order to achieve data synchronization between master and slave databases.

This is a simple list of scenarios, and detailed configuration and implementation steps will be written in another article.

Six, the proxy architecture scheme: Read memory speed is read 100000-1000000 times the hard disk.
The pages that have been visited are cached in memory, and the next time they are read directly from memory, they can be effectively accelerated.

1, traditional agent. The client sends a request to the proxy server, and the proxy server takes the data to the Web server and returns it to the browser. A proxy server is a cache with large storage space.
2, reverse proxy. Similar to the traditional proxy principle, but with different objects. The traditional proxy is used by the client, and the reverse proxy is used by the server. The user accesses the Web server through a reverse proxy, and the Web server is hidden. However, the user does not care about these, the right proxy server as a real Web server. The reverse proxy has vamish.

VII. Architecture Scheme for asynchronous computing: more time-consuming, such as distributing user-uploaded files to multiple machines, such as cropping images, video transcoding, etc. You can use asynchronous scenarios.
Instead of waiting for the calculation to end, the user returns the result first. Representative products have and memcache the same home Gearman. For the use of Gearman, you can view the PHP manual.

High-performance Site architecture Scenarios

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.