Google and Python

N

Nick Craig-Wood

Hendrik van Rooyen said:
Ok got it - so instead of starting a thread, as is current practice, you fork
a process (possibly on another machine) and "hand over" the client.

It is trivial to pass a socket to a new thread or a forked child - you
don't need this mechanism for that. It doesn't work on different
machines though - it has to be on the same machine.

It is for passing a socket to an already running process. For example
you could implement fast cgi like this.

Fast cgi is a process which runs continuously which avoids startup
times and can track more state more easily.

Instead of the client talking to the web server and the web server
taking to the fast cgi process which is what normally happens, the web
server could first writes some headers on the socket then pass the
socket on to the fast cgi process directly, cutting out a whole lot of
copying of the data.
Can't you do this by passing the client's IP addy and the negotiated socket
on the clients machine?

No, because the state of the open TCP connection is kept in the kernel
not in the user process.
Or is this where the heavy lifting comes in? - "spoofing" the original local IP
addy on the new server? - seems you would have to route to a local machine
based not on IP addy only, but on (IP,socket) tuples. - This might work if
you have only one entry point to the local LAN, but would be harder to do
if there are two points of entry, and packets could hit from
outside on either..

It is all done in the kernel. The kernel has the state of the TCP
connection - it is just accessed from a different process.
 
H

Hendrik van Rooyen

Nick Craig-Wood said:
It is trivial to pass a socket to a new thread or a forked child - you
don't need this mechanism for that. It doesn't work on different
machines though - it has to be on the same machine.

8< ------------- nice explanation by Nick-----------------------

How does a very large volume site work then? - there must be some
way of sharing the load without bottlenecking it through one machine?

- Hendrik
 
D

David

It is trivial to pass a socket to a new thread or a forked child - you
8< ------------- nice explanation by Nick-----------------------

How does a very large volume site work then? - there must be some
way of sharing the load without bottlenecking it through one machine?

Large sites do load balancing (caching, dns round robin, reverse
proxies, etc) over many hosts. Passing connection handles around on a
single host is a different type of optimization.

See this link for info on how Wikipedia handles their load-balancing:

http://en.wikipedia.org/wiki/Wikipedia#Software_and_hardware
 
B

Bryan Olson

How does a very large volume site work then? - there must be some
way of sharing the load without bottlenecking it through one machine?

Several ways. The Domain Name System can provide multiple IP
addresses for the same name. IP addresses often often lead
to HTTP "reverse proxies" that shoot back cached replies to
common simple requests, and forward the harder ones to the
file/application servers, with intelligent load balancing.

The services are surprisingly basic, and some excellent
software is free:

http://en.wikipedia.org/wiki/Round_robin_DNS
http://en.wikipedia.org/wiki/Reverse_proxy
http://en.wikipedia.org/wiki/Squid_proxy


Web apps tend to scale just great, except when they need
data that is both shared and modifiable.
 
A

asdfjehqwjerhqjwljekrh

I don't have those numbers at hand, and if I did they would be
confidential

I would be curious to know whether they code much "mixed model"
coding. By that I mean (a) code your application in Python, and then
(b) optimize it as necessary by moving some functionality into Python
C/C++ modules. (Some of (b) may happen during design, of course.)

I think of this as the state of the art in programming practice, and I
wonder whether Google's doing this, or has a superior alternative.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top