英文:
Why is the latency of my GAE app serving static files so high?
问题
我正在检查我的Go应用程序在GAE上的性能,并且我发现静态文件的响应时间相当高(183毫秒)。是吗?为什么会这样?我该怎么办?
英文:
I was checking the performance of my Go application on GAE, and I thought that the response time for a static file was quite high (183ms). Is it? Why is it? What can I do about it?
64.103.25.105 - - [07/Feb/2013:04:10:03 -0800] "GET /css/bootstrap-responsive.css
HTTP/1.1" 200 21752 - "Go http package" "example.com" ms=183 cpu_ms=0
答案1
得分: 1
对于比较,我使用tools.pingdom.com测试了一个网站。
Pingdom报告了一个加载时间为218ms
。
以下是日志的结果:
2013-02-11 22:28:26.773 /stylesheets/bootstrap.min.css 200 35ms 45kb
另一个测试结果是Pingdom的238ms
和日志中的2ms
。
因此,我认为你的183ms
相对来说还不错。有很多因素在起作用:
- 你与服务器的位置
- 提供资源的服务器是否过载?
你可以尝试使用Go实例来提供文件,而不是使用App Engine的静态文件服务器。我之前测试过,结果有时更快,但速度不太一致。在负载下,响应时间也会增加,因为App Engine实例限制为10个并发请求。更不用说你还要为实例时间付费。
编辑:
与其他云/CDN提供商进行比较,请参阅Cedexis的-免费国家报告。
英文:
For a comparison I tested a site using tools.pingdom.com
Pingdom reported a Load time of 218ms
Here was the result from the logs:
2013-02-11 22:28:26.773 /stylesheets/bootstrap.min.css 200 35ms 45kb
Another test resulting in 238ms
from Pingdom and 2ms
in the logs.
Therefore, I would say that your 183ms
seems relatively good. There are so many factors at play:
- Your location to the server
- Is the server that is serving the resource overloaded?
You could try serving the files using a Go instance instead of App Engine's static file server. I tested this some time ago, the results were occasionally faster, but the speeds were less consistent. Response time also increased under load, due to App Engine Instance being Limited to 10 Concurrent Requests. Not to mention you will be billed for the instance time.
Edit:
For a comparison to other Cloud / CDN providers see Cedexis's - Free Country Reports
答案2
得分: 1
"Regular" 200 ms似乎对于静态文件来说有点高。我从我的应用程序中提供了同样的"bootstrap-responsive.css"的静态版本,我可以看到两种类型的响应时间:
- 50-100ms(大部分时间)
- 150-500ms(有时)
由于我对Google App Engine的ping往返大约为50ms左右,所以这个文件通常在50ms左右内提供。
我猜测150-300ms的响应时间与Google App Engine前端服务器的“冷缓存”有关。我假设从某个持久存储中检索文件会比从前端服务器缓存中检索文件的延迟更高。
我还假设您可以访问各种前端服务器并获得零星的较高延迟。
最后,浏览器的整体感知延迟应该与以下内容密切相关:
(tc)ping往返时间 + 前端服务器上的tcp/http排队/缓冲 + 文件提供应用程序时间(在您的Google应用程序日志中可见)+ 传输文件的时间。
如果前端服务器没有超载且文件很小,则延迟应该接近ping + 提供时间。
在我的情况下,50ms(ping)+ 35ms(提供)= 85ms,与我在浏览器中看到的95ms非常接近。
最后,如果您的应用程序正在提供大量请求,它们可能会排队,引入了在应用程序日志中不可“看见”的延迟。
英文:
"Regular" 200 ms seems on the high side of things for static files. I serve a static version of the same "bootstrap-responsive.css" from my application and I can see two types of answer times:
- 50-100ms (most of the time)
- 150-500ms (sometimes)
Since I have a ping roundtrip of more or less 50ms to google app engine, it seems the file is usually served within 50ms or so.
I would guess the 150-300ms response time is related to google app engine frontend server being "cold cached". I presumed that retrieving the file from some persistent storage, involves higher latencies than if it is in the frontend server cache.
I also assume that you can hit various frontend servers and get sporadic higher latencies.
Lastly, the overall perceived latency from a browser should be closely approximated by:
(tc)ping round trip + tcp/http queuing/buffering at the frontend server + file serving application time (as seen in your google app logs) + time to transfer the file.
If the frontend server is not overloaded and the file is small, the latency should be close to ping + serving time.
In my case, 50ms (ping) + 35ms (serving) = 85ms, is quite close to what I see in my browser 95ms.
Finally, If your app is serving a lot of requests, they maybe get queued, introducing a delay that is not "visible" in the application logs.
答案3
得分: 0
你应该尝试在静态文件上设置缓存。
英文:
You should try setting caching on static files.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论