From one and a half minutes to one hour to send
还没有人认领这个 Issue。
评估
调研方向
Start with the reported sending loop and the queueNotification() and flush() calls, reproducing the timing difference between web-push-php versions 6 and 8 with 44,000 endpoints. Compare batch behavior and request timing around each flush, then confirm that the sending duration is reduced without changing the notification payload or endpoint handling.
由索引模型根据 Issue 内容生成。
描述
Setup
- Operating System: Linux
- PHP Version: 8.1
- web-push-php Version: 8.0
PHP extensions :
- curl
- gmp
- mbstring
- openssl
browsers:
- Chrome
- Firefox
- Firefox for Mobile
- Opera for Android
- Samsung Internet Browser
- Other
I was using version 6, and 44,000 endpoints were being sent in 1m 40s. After updating to version 8, the time has increased to almost 1 hour, and I don’t know what could be the reason.
This is the portion of sending code
$defaultOptions = [
'TTL' => 300, // defaults (300) to 4 weeks
'urgency' => 'normal', // protocol defaults to "normal"
'topic' => 'new_event', // not defined by default,
'batchSize' => 1000, // defaults to 1000
'verify' => false,
'timeout' => 6, // defaults to 20
'\GuzzleHttp\RequestOptions::ALLOW_REDIRECTS' => false
];
$webPush = new WebPush([], $defaultOptions);
$webPush->setAutomaticPadding(true);
$auth = array(
'VAPID' => array(
'subject' => 'https://www.mydomain.com',
'publicKey' => file_get_contents(__DIR__ . '/../../../../keys/public_key.txt'),
'privateKey' => file_get_contents(__DIR__ . '/../../../../keys/private_key.txt'),
),
);
$webPush = new WebPush($auth);
$i = 0;
$notifications = [];
while ($row_subscription = $result -> fetch_assoc()){
$i ++;
$subscription_id = $row_subscription['subscription_id'];
$payload = [
"title" => $row_notificacion['title'],
"body" => $row_notificacion['body'],
"badge" => $row_notificacion['badge'],
"icon" => $row_notificacion['icon'],
"image" => $row_notificacion['image'],
"url" => $row_notificacion['url'],
"id" => $notification_id,
"sid" => $subscription_id,
"requireInteraction" => true,
"vibrate" => "[300, 100, 400]"
];
$data = json_encode($row_subscription);
$subscription = Subscription::create(json_decode($data, true));
$notifications[] = [
'subscription' => $subscription,
'payload' => json_encode($payload),
];
if ($i % 1000 == 0 || $result->num_rows == $i) {
foreach ($notifications as $notification) {
$webPush->queueNotification($notification['subscription'], $notification['payload']);
}
foreach ($webPush->flush() as $report) {
handleReport();
}
$notifications = [];
}
}
Thank you
- 主要语言
- PHP
- 星标
- 1.9k
- 派生
- 312
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
web-push-libs/web-push-php 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
web-push-libs/web-push-php#441 ·
-
难度 4/5 3-5 天 新手友好度 30/100
web-push-libs/web-push-php#430 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 25/100
web-push-libs/web-push-php#429 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 20/100
web-push-libs/web-push-php#412 ·
-
难度 4/5 3-5 天 新手友好度 25/100
web-push-libs/web-push-php#411 · 5 条评论 ·
查看 web-push-libs/web-push-php 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 83/100
nunomaduro/collision#375 ·
-
enhancement good first issue hacktoberfest help wanted
难度 2/5 1-3 小时 新手友好度 68/100
thetheago/laravel-seeder-versioning#19 ·
维护者通常 1 天内回复
-
HTTP::setGetVar() duplicates the base path for root-relative URLs when the site runs in a subfolder未关闭
难度 2/5 1-3 小时 新手友好度 74/100
silverstripe/silverstripe-framework#12034 ·
-
needs triage
难度 2/5 1-3 小时 新手友好度 72/100
-
loginWithCustomTokenExchange() fails when an organization is configured可能已有人在做 @awss1i 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复