1. zhihu sometimes opens a link very slowly, and a large number of comments are unbearable. Sometimes the page is refreshed, and no response is received from any connection. 2. Douban often goes down, such as 502 (Of course I know it has nothing to do with python). The same problem also exists. From time to time, the response will be very slow, and a page will wait for more than 10 s. 3. v2ex is a little less than v2ex, which is also a similar problem. However, the relationship between speed and speed varies greatly with the network environment. 1. zhihu sometimes opens a link very slowly, and a large number of comments are unbearable. Sometimes the page is refreshed, and no response is received from any connection.
2. Douban often goes down, such as 502 (Of course I know it has nothing to do with python). The same problem also exists. From time to time, the response will be very slow, and a page will wait for more than 10 s.
3. v2ex is a little less than v2ex, which is also a similar problem. However, the relationship between speed and speed varies greatly with the network environment.
==============================================
The three websites are choppy every day.
If you have not encountered this problem, do not make trouble.
In addition, I have not pushed the language "related". I am asking "whether it is related 』.
A, B, and C use the same technique and have the same symptoms. Can't you doubt that this technique is common/likely to have such symptoms?
Why did twitter migrate from ruby to java? Reply content: Add a new one. I didn't see it before.
Although I have never met 502
However, if you have met and are sure that this 502 is from the front-end HTTP server of Douban
So this is
The only oneIt may be related to later Python.
------------
If a website is choppy or not, there may be too many situations, and the detailed performance may be different.
- Line
- DNS
- CDN/File Service
- Static Resources
- Dynamic Resources
- Cache Synchronization
Line
China's famous North-South split and Union split. Although I have rarely heard of this issue over the years, I can only find myself unlucky if I have not set up a dual-line data center? Ping the website domain name to check the ping latency. If the latency is unusually large (for example, from several hundred milliseconds to more than one second, it is usually the problem here ).
DNS
It is actually the same as the line. A good DNS (e-DNS extension) allocates an appropriate server to the user based on the user's current location. Of course, e-DNS is not supported, and the server has only one IP address.
CDN/File Service
CDN is the most important channel for distributing static content that will not change for a moment to users. File services (such as Amazon S3) are usually used in a similar way with CDN/with CDN. CDN dynamically caches static files to the so-called edge server, which is usually located near the data center accessed by the ISP, so that users can access these resources in a shorter path and lower latency. At the same time, due to the huge number of CDN hosts, correct use can also reduce the pressure on the website's servers. Zhihu pictures from http://p4.zhimg.com
These domain names are actually redirected to the cloud storage/CDN host, for example:
$ nslookup p3.zhimg.comServer:192.168.1.1Address:192.168.1.1#53Non-authoritative answer:p3.zhimg.comcanonical name = d.qiniudn.com.d.qiniudn.comcanonical name = wsall.36tr.com.wscdns.com.wsall.36tr.com.wscdns.comcanonical name = 08911.xdwscache.glb0.lxdns.com.Name:08911.xdwscache.glb0.lxdns.comAddress: 122.228.218.146
1. Short answer:
This is not caused by Python. I am using Douban very fast here, but it seems like it is a bit choppy (or you may be able to figure out after seeing the problem .......).
2. Why is it not caused by Python?
In other words, a website is stuck in a certain language at its backend, however, zhihu and others are definitely not the reason. For websites with large volumes of traffic and large volumes of text content, zhihu and others will use the Cache in large quantities, that is to say, retrieving data directly from the memory does not frequently access the database. At this level, basically all languages are not much different, and even HTML pages are cached.
3. What caused choppy
This is probably caused by a large number of Ajax requests. I noticed that when the mouse is moved to the person's name or topic, three new Ajax requests will be triggered. About 30 ~ 40 HTTP requests are sent. Although the data size is small, if the browser performance is poor or the memory allocated to the browser is insufficient, frequent calls to Ajax may need to wait for other places to release a little memory.
I did not take a closer look, but it seems that the entire HTML page is asynchronously rendered using Ajax. Because the construction of the dom tree is also very performance-consuming, if the machine is too old, or the network is too bad.
4. Solutions
In fact, I did not pay special attention to the choppy phenomenon mentioned by the landlord. The solution may be to upgrade the machine ...... for some users with poor network conditions, try to send as few HTTP requests as possible. I think there are quite a lot of requests on more than 30 pages.
Or learn how to perform delayed loading on Quora (an intuitive guess). Instead of sending Ajax requests to the page in one breath, wait for the user to enter the page (for example, when there are 8 requests ), after rendering the basic page information
SequentialSend other Ajax requests. I finally figured out why I couldn't get to YouTube. I also want to add that php is also spam. I can't go to a website as big as facebook that uses php. I know it's always good or bad, and sometimes it's only possible to go over the wall. It has nothing to do with Python. It may have been attacked. Do not use any weapons on your hands,
Do not blame the language used for website slowness. I feel that google is also doing a bad job. I used to be able to go up occasionally, but now I can't go up. The strange wool language is a habit problem. First, Python is slow. This is a comparison with compiled languages, such as C, C ++, and Java. In dynamic languages, Python is not slow and Ruby is faster, it has the same performance as Perl. If you select a Dynamic Language, Python is not very slow. On the other hand, for website development, the language is not a bottleneck of speed. For example, if all the programs written in Python are written in C, the program will certainly be faster, but the change is not great. Web websites generally have many IO operations, such as database access and hard disk access to respond to user requests. 80% and 90% of your time is spent on IO, language speed is not that important. It can also be said that the performance of the website depends mainly on the rationality of the architecture design. Because the website needs to respond to a large number of concurrent requests, if your design is poor, even if you write in C, it may not be able to cope. Therefore, more consideration is given to the architecture design, so that the architecture system will not produce a speed bottleneck.