0

(This is a follow up to rails app fast on server, but slow when accessed from another machine.)

I have a Rails web app that's incredibly slow when I access via its hostname, but runs at normal speeds when I access via its IP address (or via localhost, if I access it on the same server machine it's running on). This makes me think the problem is with the DNS. (Also, all these machines are running on the same corporate intranet.)

However, when I ping the hostname from a terminal, the ping seems to run fine. Does the fact that pinging works suggest that the problem is not with the DNS? (I don't really know much about DNS or servers and networking, so I'm kind of floundering around a bit here.)

Update to add: I also ran a simple "Hello world" Sinatra app, and this also runs super slowly when accessed via hostname (but not when accessed via IP address).

Community
  • 1
  • 1
grautur
  • 29,955
  • 34
  • 93
  • 128

2 Answers2

1

Fast ping from your terminal suggests that DNS between you and DNS server was fine and that network between you and server is fine.

This still does not help with the DNS on your server. Do you have any network operations that your server performs? If so, you need to make sure the network is reachable.

I suggest you get a simple "hello world" Rails application deployed there and see if it is Rails issue related (server wide) or your application related (very easy to do).

The other suggestion is to profile your Rails app and see which operation is taking the time to complete.

Zepplock
  • 28,655
  • 4
  • 35
  • 50
  • Yep, I tried a "hello world" Sinatra app, and this also run super slowly when accessed via hostname (but fine from the IP address). What's the difference between A) the DNS between me and the DNS server being fine, and the network between me and the server being fine, and B) the DNS on the server? – grautur Apr 13 '11 at 18:49
  • 1. Well, when the request comes into your webserver, it might want to resolve it to something (depending on server and its configuration). In this case the DNS client on the server needs to access the DNS server. In your case that link might be broken. 2. Do you use just a bare rails/sinatra (like mongrel server) or you have apache/thin/nginx webserver as well? – Zepplock Apr 13 '11 at 18:59
  • I was just using Webrick. (I had problems getting Thin and Mongrel installed. I did try running a "Hello Word" app in Django as well, but I had the same problem.) – grautur Apr 13 '11 at 20:37
  • 2 more suggestions: make sure you have `127.0.0.1 localhost` in your hosts file and try to disable IPV6 on that computer – Zepplock Apr 13 '11 at 20:59
0

Your ping command is probably using cached DNS instead of hitting the server every time. Google for "flushdns" to find the right syntax to purge your cache for your particular operating system, then try it. You'll need to do this every time if you want to use ping to see about DNS response.

Brian Glick
  • 2,201
  • 18
  • 20