I have two Servers
Server 1 -> AMD Epyc 7371 - 16c/32t - 3.1 GHz/3.8 GHz Ram 256Gb
Server 2 -> 2× Intel Xeon Gold 6242R - 20c/40t - 3.1 GHz/4.1 GHz Ram 384Gb
on both servers I have installed a websocket that is the same in all respects
On server 1 with 20/30 users Client Server calls are fast
On Server 2 with 3 connected users the service is very slow it takes about 10 seconds before the server responds to the client
this is the code
// SSL context.
$context = stream_context_create([
'ssl' => [
'local_cert' => "./certificate/a2699ad7df6c0f70bde860be9b807edd.crt",
'local_pk' => "./certificate/a2699ad7df6c0f70bde860be9b807edd.key",
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false
],
]);
$socket = stream_socket_server("ssl://".$addrSocket.":".$port."", $errno, $errstr, STREAM_CLIENT_ASYNC_CONNECT| STREAM_SERVER_BIND | STREAM_CLIENT_PERSISTENT| STREAM_SERVER_LISTEN, $context);
while (1) {
try
{
// look for new connections
if (($c = stream_socket_accept($socket, empty($connections) ? -1 : 0, $peer)) && $info = handshake($c)) {
$connections[$peer] = $c;
$data = (new \DateTime())->format('Y-m-d H:i:s');
stdout('Open - online: '.count($connections).' - '.$peer.' - '.$data);
}
// wait for any stream data
if(count($connections) > 0){
$read = $connections;
if (stream_select($read, $write, $except, 10)) {
foreach ($read as $c) {
$peer = stream_socket_get_name($c, true);
if (feof($c)) {
$data = (new \DateTime())->format('Y-m-d H:i:s');
if(isset($connections[$peer])){unset($connections[$peer]);}
stream_socket_shutdown($c, STREAM_SHUT_RDWR);
stdout('Close '.$peer.' - '.$data);
}
else {
$contents = fread($c, $maxBufferSize);
$resp_ = onMessage($c, $contents, $peer, $addrProcess, $useCertificate, $opId, $contents);
$mode = $resp_['mode'];
$opId = $resp_['opId'];
$contents = $resp_['contents'];
if($mode == "close"){
$gid = "**";
if(isset($connections[$peer])){unset($connections[$peer]);}
stream_socket_shutdown($c, STREAM_SHUT_RDWR);
$data = (new \DateTime())->format('Y-m-d H:i:s');
stdout('rClose '.$peer.' - '.$data.' - '.$gid);
}
}
}
}
}
}
catch (Exception $e)
{
stdout('Caught exception: '.$e->getMessage());
}
}
TCP ports are set to 65000 on both servers, MySql 8.0 is installed on both servers
with the same configurations.
The difference is the processor how can I fix it? Thanks