Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running a website, and I have some fastcgi apps that I want to call - however, the apps are not directly accesible to the public - they access them indirectly, through a RESTFUL service, which will then use Curl (or some other mechanism) to fetch the data from the fgci app.

My question is that of bandwith. Assume I am using Curl or PHP's readfile(), it involves specifying the URL - which would be something like http://localhost/fastcgi-bin/test.fgci

So is the "network" clever enough to know that the address resides locally and therefore it does not need to go "outside", or will the request still be sent to external DNS which will resolve the address to my machine IP address?

Basically, I wan to know if employing this architecture will increase my bandwidth consumption or not.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Any packets you send to the same machine should go out (and back in) over your loopback interface -- they won't go out over the network. You won't be charged for them.

You can verify this by looking at your routing tables. You don't mention what platform you're using, so I can't give a specific example, but from my laptop:

sveiss@brakiri:~$ route get 192.168.1.1
   route to: 192.168.1.1
destination: 192.168.1.1
  interface: en1
      flags: <UP,HOST,DONE,LLINFO,WASCLONED,IFSCOPE>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500      1198

sveiss@brakiri:~$ route get 192.168.1.63
   route to: 192.168.1.63
destination: 192.168.1.63
  interface: lo0
      flags: <UP,HOST,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
   49152     49152         0         0         0         0     16384         0 

sveiss@brakiri:~$ route get 127.0.0.1
   route to: localhost
destination: localhost
  interface: lo0
      flags: <UP,HOST,DONE,LOCAL>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
   49152     49152         0         0         0         0     16384         0 

Look at the interface: lines: traffic to addresses local to the machine (192.168.1.63 and 127.0.01) is sent over lo0, the loopback interface. Traffic going elsewhere will go out over the network via interface en1.

Now, for name resolution, you're right that if you use a DNS name for your machine, the DNS query and response might well go outside the local box. The application traffic won't, though: it'll follow the rules in your routing table and use the loopback interface, as described above.

Depending on your OS and configuration (is DNS caching turned on? is the DNS name you're using listed in the local hosts file?) the amount of bandwidth consumed by DNS queries will range from zero to tiny -- orders of magnitude less than the rest of your external traffic.

share|improve this answer
    
Hi Steve. Sorry for the late reply and acceptance. My local (dev) machine is Ubuntu, but the server is Debian (IIRC, Ubuntu is a fork of Debian, so the commands should [hopefully] be similar or the same). Waht cmds may I use to check network traffic, and also, how do I find out if DNS cacheing is enabled? mtia –  user25312 Jan 16 '10 at 18:21
add comment

Any loopback packets never hit the network as the poster mentioned above. You won't be using any bandwidth for local requests.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.