slow login, the rest is speedy

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

slow login, the rest is speedy

Postby geevee » Sun Nov 10, 2013 7:46 pm

Hello,

For a small project I used your library since I didn't know yet if that "standard" sftp stuff was installed on the server.

All works fine technically but when I moved the stuff from my home pc, which is behind a weak 1Mb line
, I hoped that the sequential downloads would fly in like hell on their 100MB+ line.

I noticed that the download icons updated every 3 seconds, no matter if the download (and zip extraction) was 60Kb or hundreds of Kb
so I went into detail and spotted that the login always takes 3 seconds while the download+extract is always in a second. (see below)

Sun Nov 10, 2013 20:40:50 pm start login
Sun Nov 10, 2013 20:40:53 pm login end/start download
Sun Nov 10, 2013 20:40:53 pm download end
Sun Nov 10, 2013 20:40:53 pm upzip end
Sun Nov 10, 2013 20:40:53 pm end

starting the application from scratch it needs to download and extract 205 files, so that 615 seconds (10 minutes) delay caused by the login.

Since I could remove several include files to make this working I was wondering if some other code could be
removed when using only this server to speed up things even more? (remove certain encryption checks that fail for this server or something like that)
geevee
Traveler
 
Posts: 6
Joined: Sun Nov 10, 2013 7:31 pm

Re: slow login, the rest is speedy

Postby TerraFrost » Mon Nov 11, 2013 7:34 pm

I noticed that the download icons updated every 3 seconds, no matter if the download (and zip extraction) was 60Kb or hundreds of Kb

I'm not sure what these download icons you're talking about are.

That said, the login phase uses diffie-hellman key exchange, which uses extensions like gmp, bcmath or openssl. For the symmetric ciphers mcrypt is needed to get the fastest possible speeds out of them but the auth it's the gmp, bcmath and openssl extensions you need to check for.

Hope that helps. Good luck!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: slow login, the rest is speedy

Postby geevee » Tue Nov 12, 2013 8:40 am

about the icons...

it's just a page that fetches a list of missing files on an external sftp server.

I loop through them via jquery to download them one by one so it requires the log on each time since it happends in a different page.

I might change it so that it downloads 'm all in one go and add a timer on the main page to poll for what's already downloaded.

besides that I did some timing last sunday and noticed that it's the modpow or powmod routine that needs 1.10 seconds and it's used atleast twice in the process.
geevee
Traveler
 
Posts: 6
Joined: Sun Nov 10, 2013 7:31 pm

Re: slow login, the rest is speedy

Postby geevee » Tue Nov 12, 2013 3:08 pm

ok, here's an update...

I recoded most of it so that it fetches all files in one go while I update status icons every 1-2 seconds.

All looked fine while testing with a handfull files but when I do a lot of them
the transfer seems to halt after 20-40 files.

Is there some clean-up that I need to do or is there a way to trap errors?
(the last downloaded zip file can still be opened tho so it's pulled in completely, no clue why it freezes.)
geevee
Traveler
 
Posts: 6
Joined: Sun Nov 10, 2013 7:31 pm

Re: slow login, the rest is speedy

Postby TerraFrost » Tue Nov 12, 2013 4:18 pm

besides that I did some timing last sunday and noticed that it's the modpow or powmod routine that needs 1.10 seconds and it's used atleast twice in the process.

To speed that up you'd have to use the extensions I mentioned earlier. Install gmp if it's not. If you can't do that do openssl. Failing that do bcmath. A discussion of how the various extensions impact the speed can be found here:

http://phpseclib.sourceforge.net/math/intro.html

All looked fine while testing with a handfull files but when I do a lot of them
the transfer seems to halt after 20-40 files.

Maybe try the latest Git version. I've made some changes relating to the window size that fixed issues like that for me.
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: slow login, the rest is speedy

Postby geevee » Tue Nov 12, 2013 7:42 pm

interesting chart, unfortunately I doubt they will install gmp on that server for me
and I didn't find a good example yet on how to link seclib with openssl to have that speed gain.


the problem mentioned before has nothing to do with seclib the php script stops at random places and times
maybe it took too much resources.
geevee
Traveler
 
Posts: 6
Joined: Sun Nov 10, 2013 7:31 pm

Re: slow login, the rest is speedy

Postby TerraFrost » Tue Nov 12, 2013 8:01 pm

geevee wrote:interesting chart, unfortunately I doubt they will install gmp on that server for me
and I didn't find a good example yet on how to link seclib with openssl to have that speed gain.

phpseclib automatically uses openssl if it's available.

the problem mentioned before has nothing to do with seclib the php script stops at random places and times
maybe it took too much resources.

Did you try the latest Git version like I asked?
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: slow login, the rest is speedy

Postby geevee » Tue Nov 12, 2013 8:55 pm

yes, I downloaded it a few days ago.

I changed the structure a bit, now it's posting only in chuncks of 20 files to be downloaded
that seems to free up enough resources to complete the 260 downloads without halting (tried 3 times)

problem solved for now :)
geevee
Traveler
 
Posts: 6
Joined: Sun Nov 10, 2013 7:31 pm

Re: slow login, the rest is speedy

Postby TerraFrost » Tue Nov 12, 2013 9:23 pm

Oh ok. Well I guess next time you encounter the issue try doing define('NET_SSH2_LOGGING', 4); and define('NET_SSH2_LOG_REALTIME_FILENAME', 'sftp.log'); before initializing the Net_SFTP object. That'll enable real-time logging and set it up such that it saves those logs to a file. If you could provide me with that file that'd be helpful.

Thanks!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: slow login, the rest is speedy

Postby geevee » Thu Nov 14, 2013 4:24 pm

no problem, I'll do that tonight or tomorrow.

by the way, soon you will have 12345 posts on this forum, nice number :)
geevee
Traveler
 
Posts: 6
Joined: Sun Nov 10, 2013 7:31 pm


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 1 guest

cron