[PECL-DEV] ssh2 / performance issue
[email protected] Sat, 28 Sep 2024 16:30:08 +0200
| Newsgroups | php.pecl.dev |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format.
------=_NextPart_000_0001_01DB11C3.AEE48B70
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi all
After I got ssh2 running, I'm struggling with performance issues.
Same file, same server system (Ubuntu), same client system (Ubunut), same
network connection, only difference is the transfer protocol - sftp vs.
https.
File to download:
Size: 33.6 MB
Type: Zip file
Download time
with ssh2/sftp: 45 sec
with wget/https: 1.6 sec
with openssh-client/sftp: 6 sec
That's quite a huge difference!
I played around with the buffer_size of the input stream but no improvement
was achived.
$buffer_size = 64*1024;
$j = 0;
while ($data = fread($remote_stream, $buffer_size)) {
++$j;
fwrite($local_stream, $data);
}
echo $j;
The data is received in 4314 buffers, which indicates the chunk size the
server is using to transfer data is 8k (33.6 * 1024 * 1024 / 4314). So
setting buffersize on the client side or in ssh2 seems to have no effect.
The results make me conclude the problem can't be sftp as such nor the
server. So it's probably me :-) Is there anything performance-wise I'm
missing? Something in need to tweak in the PHP configuration? .. ?
Thanks a lot for your support.
Have a nice weekend
Mark
------=_NextPart_000_0001_01DB11C3.AEE48B70
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 14 (filtered =
medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:812022093;
mso-list-type:hybrid;
mso-list-template-ids:-1054984982 1054609958 134676483 134676485 =
134676481 134676483 134676485 134676481 134676483 134676485;}
@list l0:level1
{mso-level-start-at:1024;
mso-level-number-format:bullet;
mso-level-text:-;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-font-family:Calibri;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DDE-CH link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal>Hi =
all<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal><span lang=3DEN-GB>After I got ssh2 running, I’m =
struggling with performance issues. <o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB>Same file, same server system =
(Ubuntu), same client system (Ubunut), same network connection, only =
difference is the transfer protocol – sftp vs. =
https.<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB><o:p> </o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>File to download:<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB> Size: 33.6 =
MB<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-GB> Type: =
Zip file <o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB><o:p> </o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>Download time <o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB> with ssh2/sftp: 45 =
sec<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-GB> with =
wget/https: 1.6 sec<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB> with openssh-client/sftp: 6 sec<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB>That’s quite a huge =
difference! <o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>I played around with the buffer_size of the input stream =
but no improvement was achived.<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB>$buffer_size =3D =
64*1024;<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-GB>$j =
=3D 0;<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>while ($data =3D fread($remote_stream, $buffer_size)) =
{<o:p></o:p></span></p><p class=3DMsoNormal =
style=3D'text-indent:35.4pt'><span =
lang=3DEN-GB>++$j;<o:p></o:p></span></p><p class=3DMsoNormal =
style=3D'text-indent:35.4pt'><span lang=3DEN-GB>fwrite($local_stream, =
$data);<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>}  =
; <o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>echo $j;<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB><o:p> </o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>The data is received in 4314 buffers, which indicates the =
chunk size the server is using to transfer data is 8k (33.6 * 1024 * =
1024 / 4314). So setting buffersize on the client side or in ssh2 seems =
to have no effect. <o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB><o:p> </o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>The results make me conclude the problem can’t be =
sftp as such nor the server. So it’s probably me :-) Is there =
anything performance-wise I’m missing? Something in need to tweak =
in the PHP configuration? …. ?<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB>Thanks a lot for your =
support.<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB>Have a nice weekend<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-GB>Mark<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
lang=3DEN-GB><o:p> </o:p></span></p></div></body></html>
------=_NextPart_000_0001_01DB11C3.AEE48B70--