Develop website performance analysis and optimization

Analyzing the website from a procedural point of view is a personal opinion, just take a look at it.

1. Website opening experience, slow optimization solutions:
  @Optimization solutions
    Front-end architecture optimization; adjustment of browser caching, concurrency, and asynchronous features; use of CDN services; reverse proxy, etc.; etc.
  @ Back-end solutions
    cache data to speed up data acquisition; use clusters to improve request throughput; use asynchronous message queues to speed up responses; code optimization; etc.
  @ Operation and maintenance solutions 
    The bandwidth capability and stability of network operators; server hardware configuration; data center network architecture; virtualization technology to optimize resource utilization; etc.

2. The performance analysis of the website should be analyzed from these points:
  @ Response time The time
    to perform an operation, including the time required from the start of the request to the receipt of the final response data.
  @ Concurrency
    refers to the number of requests that the system can process at the same time, that is, the number of concurrent users of the website, which refers to the number of users who submit requests at the same time.
  @ Throughput
    refers to the number of requests processed by the system per unit of time, reflecting the overall processing capability of the system.
  @Performance counters
    describe data metrics of server or operating system performance. Includes metrics such as object and thread count, memory usage, CPU usage, disk and network I/O, and more.
  In actual development, the website can be optimized according to the test results of the above points.

3. Web front-end performance optimization
  @ Browser access optimization scheme
    * Reduce HTTP requests: Merge CSS, merge pictures, merge JavaScript and other means to reduce the number of browser requests to the website.
    * Use browser cache: For static file resources, resources with a relatively low update rate can be cached in the browser to reduce the number of requests.
    * Use compression: The server compresses the file, and the browser decompresses the file to reduce the amount of data transmitted by communication.
               Enabling GZip compression for HTML, CSS, JavaScript files works well.
    * CSS is placed at the top of the page, and JavaScript is placed at the bottom of the page: it can be analyzed according to the time principle of the execution of the two files.
    * Minimize the transmission of cookies, too large cookies will seriously affect data transmission.
  @ CDN solution
    * Content distribution network: CDNs can cache generally static resources, such as pictures, files, CSS, JavaScript scripts, static web pages, etc., and these files are accessed frequently, so
                  caching them in CDN can greatly improve the website’s performance. Turn on speed.
  @ Reverse proxy
    * Proxy server: Reasonably and effectively allocate resources to the corresponding server to achieve the effect of load balancing.
      In addition, the reverse proxy server can also cache static resources, and when a website is requested, the resources are returned to the corresponding client as soon as possible.

4. Application server performance optimization
   The business code of the website is deployed here, and it is also the place where the website has the most changes and the most complicated development.
  @ Distributed cache
    * The first law of website performance optimization: Priority is given to using cache to optimize performance. The 
      cache is mainly used to store those data with a high read-write ratio and rarely changing data. The read data is preferentially obtained in the cache, and the invalid state is used to access the database. .
      According to the 28 law, that is, 80% of the access falls on 20% of the data, and the 20% of the data can be cached to improve the response time of data access.
    * Problems that need to be considered in the rational use of cache
      Do not modify data frequently;
      it is not necessary to use data that does not follow the law of 28;
      preset solutions to the problem of data inconsistency;
    * Prevent cache penetration
      and cache non-existing values, Its value is set to NULL to prevent malicious access to the database for the purpose of operation;
    * The distributed cache architecture
      is not detailed here, everyone should know the principle, and briefly introduce three types. 
        # JBoss Cache: needs to be updated and synchronized, expensive, mostly used in enterprises, medium data volume;
        # Memcached (not communicating with each other), Redis (not communicating with each other), Redis is added by me and it can be used in this way. During the architecture, the logic of the cache can be added to the application,
          record the results of an algorithm and store the data in different cache servers, and then go to the corresponding cache to get the results after the algorithm;
          
  @ Cluster
    multiple servers to distribute to match the load Balanced use.
    
  @Async
    uses message queues to make calls asynchronous, which improves performance.
    Note: After asynchrony, the business process should be analyzed, and the business that does not require asynchronous needs to be dealt with to prevent a bad experience or disputes.
  
  @ Code optimization
    Reasonable optimization of business code can well improve the performance of the website.
    Here are a few issues to pay attention to:
    * Multi-threading 
      and multi-threading concurrently modifying a certain resource will lead to data confusion.
    * Resource reuse
      minimizes the creation/destruction of expensive resources, such as database connections, threads, complex objects, etc.
      The singleton pattern and object pooling can be used appropriately.
    * Reasonable use of data structures to improve data reading and writing and computing characteristics to optimize program performance.
    * Garbage collection mechanism

5. Storage server performance optimization
  @ solid state drive > mechanical hard disk
  @ storage service optimization in terms of data, please refer to the article on database optimization for details.


In the above optimization schemes, the clustering scheme is involved. Distributed can improve the concurrency characteristics of the website, but it will also bring about the problem of communication delay. When designing the architecture, you should be aware of it and adjust the expectations of the scheme reasonably.
 

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324214298&siteId=291194637