Three Python-based Web sites: Know, watercress, v2ex are the problems of the lag, is the problem of Python?

Source: Internet
Author: User
1. Sometimes it is very slow to open a link, and a lot of comment is unbearable. Sometimes the page is refreshed and no connection is answered.
2. Watercress often hangs up, 502 kind of (of course I know this is not related to Python), there are the same problem, from time to time will respond very slowly, a page to wait more than 10s.
3. V2ex is a little bit smaller and a similar problem, but it is very different from the network environment when it is fast and slow.
======================================
Every day to brush the page, these three sites lag is very obvious phenomenon.
Please don't mess up if you don't have this problem.

And I did not derive the language "related", I was asking "whether".
A, B, C Use the same technology, with the same symptoms, can't you doubt that this technique is common/likely to have such symptoms?
Why did Twitter move from Ruby to Java in the year?

Reply content:

One more knife, I didn't see it before.
Although I've never met 502 with a watercress.
But if you do come across, and be sure that this 502来 from the front of the Watercress HTTP server
So this is The only onemay be related to the later Python phenomenon.

------------

A web site is not stuck, there may be too many situations, the accompanying details of the performance of the difference is worth analyzing the problem.
    • Line
    • Dns
    • CDN/File Services
    • Static resources
    • Dynamic Resources
    • Cache synchronization
Line
The domestic famous north-South division, the Electric Union split. Although these years rarely heard the focus on this issue, but really met who did not do a double-line machine room settings can only consider themselves unlucky is not? To ping the site domain name, see the ping delay, if unusually large (for example, hundreds of milliseconds to 1 seconds or more, mostly the problem here).

Dns
It's just as relevant as the line. A good DNS (e-dns extension) assigns the appropriate server to the user based on the user's current location. Of course, if there is no way to support E-dns, the server has only one IP and nothing to do.

CDN/File Services
A CDN is the most important channel for releasing static content that will not change for a moment to the user. File Services (Amazon S3, etc.) often do something similar to CDN/CDN. A CDN dynamically caches static files to so-called edge servers-typically located in a room close to the ISP's access, allowing users to access these resources in a shorter and lower-latency way. At the same time, due to the large number of CDN host, correct use can also reduce the site itself server pressure. The picture of the unknown comes from / http p4.zhimg.com such as a series of domain names, 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:
Not python, I am very quick here, but it seems to be really a bit of a lag phenomenon (it is also possible to see the problem after the brain repair realized ...). ).

2, why not Python-led
Or, any website is very card, it should not be said that the back end of a language caused (although the bad writing will lead to the lag, but it is certainly not the reason), for this kind of traffic is very large, but also a large number of text content of the site, will use a lot of cache, That is, direct access to data from within the database is no longer frequently, from this level of basic language is not too much, even the HTML page is the cache out.

3, what causes the lag
Most likely the result of a large number of Ajax requests, I noticed that the mouse moved to the person name, the topic will trigger 3 new AJAX requests, new into a page about 30~40 HTTP request sent out, although the amount of data is not large, but if the browser performance is poor or the system allocated to the browser is not enough memory , frequent calls to Ajax may require a bit of memory to be released somewhere else.

I did not look closely, but it seems that some of the pages that are known are AJAX asynchronous rendering of the entire HTML page, because the structure of the DOM tree is also very expensive, so if the machine is too old, or the network is too poor will appear this problem.

4. How to Solve
In fact, I did not pay particular attention to the landlord said the phenomenon of the lag, the solution may be to upgrade the machine it ... For the knowledge, may need to consider some network bad users, as little as possible to send HTTP requests, a page more than 30 requests I feel pretty much.

or learning Quora to delay loading (intuitive guessing), is not to enter the page when the AJAX request to send all the way out, but first wait for the user to enter the page (such as 8 requests), and then the page basic information rendered and then sequentiallySend other AJAX requests. Finally understand why not on YouTube I would also like to add that PHP is also garbage ah, Facebook so big Web site, with PHP do, basically do not go. Know that always good time bad, sometimes turn the wall to on. It has nothing to do with Python, maybe it's been attacked. Don't blame the weapons on your hands,
Website Slow don't blame the language used. I feel that Google is also doing a very bad, and occasionally can go up, and now completely up. "屙 excrement is not hard" strange yarn language, is a habit problem. First, Python is slow, which is compared to the compiler language, such as C,c++,java, which is not slow in dynamic languages, it is faster than Ruby, and it is comparable to Perl performance. If you choose a dynamic language, Python is not very slow. On the other hand, if you do Web development, the language is not the bottleneck of speed, such as the current program in Python written in C, the program will certainly be faster, but the change is not very big. Web sites generally have a lot of operations on the IO, such as access to the database, access to the hard disk to respond to the user's request, 80%,90% your time is spent on Io, language speed, relative, not so important. It can also be said that the performance of the site depends largely on the reasonableness of the architecture design. Because the site needs to respond to a large number of concurrent requests, if your design is not good, even if you write in C, you may not be able to cope. Therefore, the more consideration is the architecture design, in order to make the architecture system does not create a speed bottleneck.
  • 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.