web-push-php icon indicating copy to clipboard operation
web-push-php copied to clipboard

12x performance difference between windows and linux

Open dotthor opened this issue 2 years ago • 0 comments

Please confirm the following:

  • [X] I have read the README entirely
  • [X] I have verified in the issues that my problem hasn't already been resolved

Setup

Please provide the following details, the more info you can provide the better.

  • Operating System: Win Server 2008 (ram4/cores4) | Win Server 2019 (ram32/cores8) | Oracle Linux 8 (ram2/cores4)
  • PHP Version: 7.4.13 | 7.4.13 | 7.2.24
  • web-push-php Version: 7.0

Please check that you have installed and enabled these PHP extensions :

  • [x] curl
  • [X] gmp
  • [X] mbstring
  • [X] openssl

Please select any browsers that you are experiencing problems with: Please specify the versions (i.e. Chrome Beta, Firefox Beta etc).

Problem

This is my code:

`<?php require_once("vendor/autoload.php"); use Minishlink\WebPush\Subscription; use Minishlink\WebPush\WebPush;

$endpoint = ""; $publicKey = ""; $privateKey = "";

$subscription = Subscription::create(json_decode($endpoint, true)); $auth = [ "VAPID" => [ "subject" => "mailto:[email protected]", // can be a mailto: or your website address "publicKey" => $publicKey, // (recommended) uncompressed public key P-256 encoded in Base64-URL "privateKey" => $privateKey, // (recommended) in fact the secret multiplier of the private key encoded in Base64-URL //"pemFile" => "private_key.pem", // if you have a PEM file and can link to it on your filesystem ], ]; $temp = new StdClass(); $temp->title = "Notifica da PHP"; $temp->body = "Questo testo arriva dal server"; $temp->url = "/";

$payload = json_encode($temp); $webPush = new WebPush($auth); $start_time = microtime(true); $report = $webPush->sendOneNotification($subscription, $payload, ["TTL" => 5000]); $end_time = microtime(true); $elapsed_time = $end_time - $start_time; echo "Tempo trascorso: " . number_format($elapsed_time, 4) . " secondi"; print_r($report->isSuccess() ? "SUCCESS" : "FAILED"); print_r($report->getReason());`

Sending the notification takes 12 seconds on the old windows server, 6 seconds on the new windows server and 0.5 on linux. Is this expected/normal? Is there anything I can do to improve this/am I doing something wrong?

Expected

A gap less big.

Features Used

  • [X] VAPID Support
  • [X] Sending with Payload

Example / Reproduce Case

Aformentioned.

Other

dotthor avatar Nov 28 '23 09:11 dotthor