如何 improve/minimize 改变 api 的响应时间

How to improve/minimize varying response time of api

我创建了一个休息 api 我对它的表现不是很满意。我花了一些时间调查并偶然发现了一个工具来轻松跟踪我的 api (www.apiscience.com).

的性能

他们将总体响应时间分为 4 个类别 - 连接、解析、处理和传输。解析部分通常需要大约 150 毫秒,而调用本身的处理只需要大约 18 毫秒,这导致平均响应时间为 160 毫秒(我在这里尝试的调用非常简单,所以平均值通常会更高)。

我的问题是如何 improve/minimize 我的电话解决时间?

(附带信息:我的服务器位于爱尔兰,我也选择爱尔兰作为测试地点)

提前致谢!

编辑 - Resolve Time 是什么意思? (https://www.apiscience.com/blog/what-do-api-sciences-curl-based-timings-mean/)

API Science’s “Resolve Time” is the equivalent of Ken’s “DNS Lookup.” DNS stands for Domain Name System. A URL consists of text (and sometimes numbers); however, the communication addresses that compose the Internet are formulated as IP (Internet Protocol) addresses, for example, 208.80.152.2. Before a request can be routed between the requesting client and the server that will process the request, the IP address that the URL refers must be looked up. A request is sent to a DNS resolver by curl, and the resolver returns the correlated IP address. API Science’s “Resolve Time” is the time in milliseconds that it took this operation to complete.

正如文档中提到的,DNS 解析时间是 API 消费客户端在找到将实际呼叫路由到您的 API 服务器的位置之前等待的时间 - 您的服务器之间的映射服务器的名称和 IP 地址。

您的 DNS 托管地可以完全独立于您的 API 服务托管地和您的域名注册地,市场上有多种 DNS 托管服务选择。 DNSPerf(我与它没有隶属关系)对服务进行了比较,如果您想 select 一个新的 DNS 提供商,这可能是进一步研究的一个很好的起点。