简体   繁体   English

IP地址作为AppHarbor / App Engine urlfetch的主机名,用于缓存DNS查找

[英]IP address as the hostname for AppHarbor / App Engine urlfetch to cache DNS lookups

I have an AppHarbor app that I'm using as an external service which will get requested by my other servers which use Google App Engine (python). 我有一个AppHarbor应用程序,我将其作为外部服务使用,我的其他服务器将使用Google App Engine(python)。 The appharbor app is basically getting pinged a lot to process some data that I send it. appharbor应用程序基本上会被处理很多,以处理我发送的一些数据。

Because I'll be constantly pinging the service, and time is important, is it possible to reference my appharbor app through its IP address and not the hostname? 因为我会经常ping服务,时间很重要,是否可以通过其IP地址而不是主机名引用我的appharbor应用程序? Basically I want to eliminate having to do DNS lookups and speed up the response. 基本上我想消除必须进行DNS查找并加快响应速度。

I'm using Google App Engine's urlfetch ( https://developers.google.com/appengine/docs/python/urlfetch/overview ) to do the request. 我正在使用Google App Engine的urlfetch( https://developers.google.com/appengine/docs/python/urlfetch/overview )来执行请求。 Is caching the ip address something urlfetch is already doing under the covers? 缓存ip地址urlfetch已经在做什么了? If not, is it possible to do so? 如果没有,是否可以这样做?

我怀疑DNS查找将成为你的瓶颈,但无论如何,只要我能看到DNS查找被系统缓存(至少对于TTL)。

You can theoretically send requests directly to an IP address, but you would have to also pass the host header so that the AppHarbor routing layer can figure out what application gets the request. 理论上,您可以将请求直接发送到IP地址,但您还必须传递主机头,以便AppHarbor路由层可以确定哪个应用程序获取请求。

As Shay mentions, you shouldn't do this though - DNS queries are cached and are not likely to be a bottleneck and you're setting yourself up for breakage because the IP address might change with the domain being pointed to a new IP. 正如Shay所提到的,你不应该这样做 - DNS查询被缓存并且不太可能成为瓶颈而你正在为破坏做好准备,因为IP地址可能会随着域指向新IP而改变。

注册AppEngine Sockets Trusted Tester( 这里 )并使用普通的python:

socket.gethostbyname(...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM