获取边缘与源站延迟
获取边缘与源站延迟百分位数(GET /v2/apps/:app_id/network/performance),按国家、colo 和最慢路径细分。适用于 Pro 和 Enterprise。
GET
/
v2
/
apps
/
{app_id}
/
network
/
performance
获取边缘与源站延迟
curl --request GET \
--url https://api.squarecloud.app/v2/apps/{app_id}/network/performance \
--header 'Authorization: <authorization>'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/network/performance"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/network/performance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/network/performance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/network/performance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.squarecloud.app/v2/apps/{app_id}/network/performance")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/network/performance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"status": "success",
"response": {
"summary": {
"edge": { "p50": 42, "p95": 180, "p99": 320 },
"origin": { "p50": 28, "p95": 150, "p99": 280 },
"requests": 12450
},
"timeseries": [
{
"date": "2025-12-01T12:00:00.000Z",
"requests": 540,
"edge": { "p50": 41, "p95": 175, "p99": 310 },
"origin": { "p50": 27, "p95": 148, "p99": 270 }
}
],
"countries": [
{ "type": "BR", "p50": 35, "p95": 160, "requests": 8200 },
{ "type": "US", "p50": 55, "p95": 210, "requests": 3100 }
],
"colos": [
{
"type": "GRU",
"city": "São Paulo",
"country": "BR",
"p50": 34,
"p95": 158,
"requests": 8100
}
],
"slowest_paths": [
{
"path": "/api/reports/generate",
"p95": 820,
"p99": 1500,
"requests": 230
}
]
}
}
返回应用在某个时间窗口内的边缘与源站响应时间百分位数(
需要具有
p50、p95、p99),以及按国家、按 colo 和最慢路径的细分。适用于诊断延迟劣化并识别哪些路由或区域最慢。
仅在 Pro 和 Enterprise 套餐可用。缓存未命中在 analytics、errors、logs 和 performance 这几个端点之间共享同一个限制:每个应用所有者每 60 秒 20 次请求。已缓存的响应不计入。在全平台繁忙期间,该端点可能会改为返回所请求时间窗口的最新缓存数据。
你账户的 API 密钥。你可以在账户设置中找到它。
apps:read 权限范围的 API 密钥。
边缘延迟(edge)衡量的是在 Cloudflare 网络处的首字节时间;源站延迟(origin)衡量的是边缘触达应用后,应用自身响应所花费的时间。如果两者之间的差距在窗口期内不断扩大,通常说明问题出在应用或其所在的集群节点;如果两者同时上升,则说明问题出在客户端与边缘之间的网络状况。
这里衡量的是网络延迟,而不是容器资源使用情况;如需从容器本身采样的 CPU、RAM 和带宽数据,请参见 获取应用指标。在优先安排修复之前,可以结合 网站分析 查看 colos 和 countries,确认一个延迟较高的地区是否同时也是低流量地区。
参数
响应
该窗口的延迟百分位数与细分。
显示 属性
显示 属性
{
"status": "success",
"response": {
"summary": {
"edge": { "p50": 42, "p95": 180, "p99": 320 },
"origin": { "p50": 28, "p95": 150, "p99": 280 },
"requests": 12450
},
"timeseries": [
{
"date": "2025-12-01T12:00:00.000Z",
"requests": 540,
"edge": { "p50": 41, "p95": 175, "p99": 310 },
"origin": { "p50": 27, "p95": 148, "p99": 270 }
}
],
"countries": [
{ "type": "BR", "p50": 35, "p95": 160, "requests": 8200 },
{ "type": "US", "p50": 55, "p95": 210, "requests": 3100 }
],
"colos": [
{
"type": "GRU",
"city": "São Paulo",
"country": "BR",
"p50": 34,
"p95": 158,
"requests": 8100
}
],
"slowest_paths": [
{
"path": "/api/reports/generate",
"p95": 820,
"p99": 1500,
"requests": 230
}
]
}
}
常见错误
| 代码 | HTTP | 说明 |
|---|---|---|
INVALID_TIME_RANGE | 400 | start/end 缺失、格式错误,或起止时间顺序颠倒。 |
UPGRADE_REQUIRED | 403 | 性能分析仅在 Pro 和 Enterprise 套餐上可用。 |
RATE_LIMITED | 429 | 已达到缓存未命中的共享限制。请稍候重试。 |
UNABLE_TO_FETCH_PERFORMANCE | 500 | 从边缘提供商获取性能数据失败。 |
ANALYTICS_BUSY | 503 | 边缘分析暂时繁忙;请 1 分钟后重试。 |
相关内容
- CLI:
squarecloud app network performance - SDK:
api.apps.network.performance()(JavaScript)、client.apps.network.performance()(Python)、c.Apps.Network.Performance()(Go)
⌘I
获取边缘与源站延迟
curl --request GET \
--url https://api.squarecloud.app/v2/apps/{app_id}/network/performance \
--header 'Authorization: <authorization>'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/network/performance"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/network/performance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/network/performance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/network/performance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.squarecloud.app/v2/apps/{app_id}/network/performance")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/network/performance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"status": "success",
"response": {
"summary": {
"edge": { "p50": 42, "p95": 180, "p99": 320 },
"origin": { "p50": 28, "p95": 150, "p99": 280 },
"requests": 12450
},
"timeseries": [
{
"date": "2025-12-01T12:00:00.000Z",
"requests": 540,
"edge": { "p50": 41, "p95": 175, "p99": 310 },
"origin": { "p50": 27, "p95": 148, "p99": 270 }
}
],
"countries": [
{ "type": "BR", "p50": 35, "p95": 160, "requests": 8200 },
{ "type": "US", "p50": 55, "p95": 210, "requests": 3100 }
],
"colos": [
{
"type": "GRU",
"city": "São Paulo",
"country": "BR",
"p50": 34,
"p95": 158,
"requests": 8100
}
],
"slowest_paths": [
{
"path": "/api/reports/generate",
"p95": 820,
"p99": 1500,
"requests": 230
}
]
}
}

