multithreading - Can a slow network cause a Python app to use *more* CPU? -


Let's say we have such a system:

  ______ {application example - - Network --- (______) {Application Example --- Network --- | | Request --- & gt; Load balancer {application example --- network --- | Data | {Application Example --- Network --- | Base | {Application example --- Network --- \ ______ /  

Comes in a request, a load balancer sends it to an application server instance, and speaks to the App server instance database Examples of applications (anywhere on the LAN) can be different processes or separate threads. Just to cover all the bases, suppose there are several similar processes, each with a pool of similar application service threads in the same way.

If the database is performing slowly or the network is stuck, then obviously the servicing request is getting worse.

Now, in all my pre-python experiences, this application will be done with frequencies related to drop in CPU usage - they spend more time on I / O and CPU-intensive Spend less time doing things.

However, I am told that with Python, this is not the case - in some Python conditions, due to this situation the CPU usage of Python should be up , probably 100 All the way up to% Global Interpreter Lock and many threads are considered to be something that causes Python to spend all its time to switch between threads, to see if None of the above from the database yet Level does not. "So increase in one-day process-based libraries."

Is that correct? Does the Python application service thread actually use more when their I / O latency increases?

In theory, no, in practice, it is possible; It depends on you what you are doing.

A complete and, but essentially, it emerges with some unforeseen consequences of GIL, in which CPU vs. Io bound thrakes are accompanied by multicore. In fact, the thread awaiting the IO needs to wake up, so the Python "foot-residing" starts the other positions with each python "tick" (instead of every 100 stacks). The IO thread is causing trouble with the GIL from the CPU thread, due to which the cycle repeats.

This is largely exaggerated, but there is more information in the summary videos and slides. It appears itself and is a major problem on multi-core machines, it can also happen if the signal from the process OS is received (since it also triggers the switch switching code).

Of course, as the other poster has said, it ends when everyone has their own process. Incidentally, slides and videos explain why you can not always do CTRL + C in Python.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -