使用Go语言在App Engine中出现TTFB(延迟)过慢的问题。

huangapple go评论80阅读模式
英文:

too slow TTFB(latency) with go language in appengine

问题

你好!以下是你要翻译的内容:

使用Go语言在App Engine中出现TTFB(延迟)过慢的问题。

我正在测试在App Engine中使用Go语言。但是响应速度太慢了。我用Chrome进行了检查,发现问题是“等待(TTFB)”。

源代码非常简单,是官方示例(https://github.com/GoogleCloudPlatform/appengine-try-go)。

出了什么问题?这正常吗?

英文:

使用Go语言在App Engine中出现TTFB(延迟)过慢的问题。

I'm testing go lang in appengine. But it's too slow response. I've checked with chrome and found that the problem is 'Waiting(TTFB)'

The source code is very simple and official example(https://github.com/GoogleCloudPlatform/appengine-try-go).

What's wrong? Is this normal?

答案1

得分: 2

本地测试性能与生产性能无关。你所看到的没有问题。

通常,首次请求比后续请求慢,因为AppEngine SDK执行文件系统扫描、编译和首次加载和执行应用程序代码包的init()函数。

你所看到的是1秒的“等待(TTFB)”时间,它代表首字节到达时间(来源):

等待初始响应的时间,也称为首字节到达时间。这个时间包括了往返服务器的延迟以及等待服务器传送响应的时间。

这1秒的TTFB很可能包括了我上面列出的SDK需要执行的所有任务,如果你考虑到这一点,其实并不算太糟糕。

不用担心,生产环境运行的是“预编译”的本机二进制代码,这些任务都不需要执行,你很可能会看到大约20-30毫秒的响应时间(TTFB)。

英文:

Local test performance has nothing to do with production performance. There is nothing wrong with what you see.

Usually first requests are slower than subsequent ones as the AppEngine SDK performs file system scans, compiling and first-time loading and execution of package init() functions of your application's code.

What you see is a 1-second Waiting (TTFB) time, it stands for Time To First Byte (source):

> Time spent waiting for the initial response, also known as the Time To First Byte. This time captures the latency of a round trip to the server in addition to the time spent waiting for the server to deliver the response.

This 1 second TTFB most likely includes all the tasks I listed above the SDK has to perform, which isn't so bad if you think about that.

Don't worry, production environment runs "pre-compiled" native binary code, none of these have to be performed and you will see most likely a response time (TTFB) around 20-30 ms.

huangapple
  • 本文由 发表于 2015年11月26日 23:50:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/33942583.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定