In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
one。 A user reports to you that the website you developed is very slow, but it is normal for the user to access other problems. Analyze the reasons, what tools are available to analyze the reasons, and how to solve the problems?
(1) the possible reason is that the bandwidth of the server exit is not enough. This is a very common bottleneck. On the one hand, it may be that the server egress bandwidth purchased by the enterprise is very small (it is quite expensive for enterprises to purchase bandwidth). Once the user traffic comes up and the concurrent volume is large, the egress bandwidth allocated to users will naturally be even smaller, so the access speed of some users will drop a lot. The other is that cross-operator networks lead to bandwidth reduction. For example, many companies' websites (servers) are placed on telecom networks, and if users connect to the broadband of Great Wall or China Unicom, network transmission between operators will be limited, which may lead to a reduction in bandwidth.
(2) possible reason 2: the server is too busy, for example, CPU and memory consumption, this is easy to understand, do not expand.
(3) possible reason 3: the development code of the website is not well written, for example, the mysql statement is not optimized, which leads to the time-consuming reading and writing of the database.
(4) possible reason 4: database bottleneck is also a very common bottleneck, which can be said together with the third reason above. When our database becomes larger and larger, such as a lot of G and T, it will be very slow to read and write to the database. Index optimization can improve some efficiency, but if the database is already so large, if every query makes a global query on such a large database, it will naturally be very slow. If you have studied the database, it is also easy to understand.
Second, in view of the above possible reasons, what are the methods and tools to detect:
(1) A user reports that the access to the website is slow, how to locate the problem. First of all, open the website yourself to see if there will be problems reflected by users. If there is no problem with your access, it may be the problem of users. This piece is to first determine whether it is the problem of the user or itself, such as the server or the website.
(2) if you find that it is really a problem with your own server or website, you can use the debugging feature of the browser (usually available in browsers) to debug the network to see the speed of loading various kinds of data, and you can see which one takes too much time, is the image loading is too slow, or some data loading can not be found out for a long time.
(3) then, according to the load of the server, you can check the consumption of server hardware (network bandwidth, CPU, memory). In terms of bandwidth, check whether the traffic monitoring has reached its peak and the bandwidth is not enough. If the company buys its own server to build a website server, it needs to build its own monitoring environment; if you use Aliyun and Tencent Cloud, these platforms will provide various aspects of monitoring, such as CPU, bandwidth, etc., which can be seen in the backend.
(4) if you find that the consumption of hardware resources is not high and are relatively abundant, it is necessary to see if it is a problem with the program. This can be found by checking the log, such as the error log of PHP log, Apache log, mysql log, etc., especially if mysql has a slow query log feature, you can see whether a mysql statement is particularly slow. If a statement takes too long, there may be something wrong with this statement.
(5) as for the large database, you can see it directly, for example, the file size of a table has become very large.
In view of the above problems, what are the solutions and optimization:
(1) the problem of exit bandwidth is very simple, add bandwidth, buy more bandwidth if you have money, it is very simple.
(2) mysql sentence optimization.
(3) the database is too large, in order to read and write speed, to "disassemble the table", "dismantle the library" is to split the data table or database.
(4) the above disassembly and disassembly tables are all done in view of the fact that the database is too large. Generally, there are other optimization methods before this, such as master-slave replication of mysql, a master server dedicated to writing, and other slave servers for reading. After writing, it will be synchronously updated to other read servers. For example, Ali's Singles' Day activities, I do not know how many tens of thousands of servers are carrying together.
(6) there is also a non-relational database that has been widely used in recent years, which uses a caching mechanism, which caches the data into memory, and the user accesses the data to read directly from the memory, which is much faster than reading on disk, as well as its key-value reading mechanism, which I didn't understand after listening to what my brother said.
(7) CDN (content-delivery-network: content distribution network), eggs are placed in multiple baskets and the data is placed closer to the user (such as some static files on the website, such as pictures or js scripts). When users visit, they determine that the source of IP is Guangzhou, then parse it to the server in Guangzhou through intelligent DNS and get the data directly from the basket in Guangzhou. There is a concept of static data and dynamic data, such as pictures and some js files are generally unchanged, then their images can be distributed throughout the country to speed up, while some of the data that need to be dynamically generated in the background of the site, you need to go to the server where the site is located to generate and get. This involves the display of two kinds of data, which is left to the browser. At the same time, asynchronous loading technology, such as front-end Ajax technology, asynchronous request data, can delay the loading of these dynamic data, which is not well understood and may not be well expressed. Front-end developers should know better.
(8) none of the above mentioned the optimization of the architecture. If the website can't handle it, does it mean that the website architecture can no longer adapt? for example, if you do a small blog and use the same server for both the database server and the web server, then all the loads will be on the same server. However, if you can't handle the number of visits, you have to add servers, and you have to optimize the architecture, for example, cluster on database, cluster on web server, such as web server cluster, add a load balancer in front of the server, and load balancer is specially responsible for distribution, distributing user requests evenly to each server.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.