sftp icon indicating copy to clipboard operation
sftp copied to clipboard

Slow connection on Kubernetes

Open remyduthu opened this issue 4 years ago • 4 comments

Hello,

I use this image on Kubernetes with a CPU limit and the connection takes a lot of time (about 20 seconds). Can we change the configuration so that SFTP uses less CPU?

Here is my configuration :

...
spec:
  containers:
    - name: sftp
       image: atmoz/sftp:alpine # also tried with :latest

       resources:
         limits:
           cpu: "40m" # also tried with "100m" and "200m"
       ...

Here is the output from SSHd when the process is stuck :

...
Starting session: forced-command (config) 'internal-sftp' for foo from 10.244.0.123 port 55910 id 0
debug2: fd 4 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x20
debug2: fd 10 setting O_NONBLOCK
debug2: fd 9 setting O_NONBLOCK
debug2: fd 12 setting O_NONBLOCK
debug3: send packet: type 99

Potentially related to: https://github.com/amimof/sftp/issues/1 and https://unix.stackexchange.com/questions/10543/ssh-slow-at-starting-session.

remyduthu avatar Jul 17 '20 06:07 remyduthu

Disabling CPU limit as a workaround:

...
spec:
  containers:
    - name: sftp
       image: atmoz/sftp:alpine

       resources:
         limits:
           cpu: 0
       ...

remyduthu avatar Jul 29 '20 14:07 remyduthu

Same issue here, disabling the limits works but i can't do it in production. Has anyone found out the reason for this behavoir?

luca-esse avatar May 07 '21 19:05 luca-esse

Hi,

I'm running my setup on a RPi 4 with 8 GB RAM, an external Samsung QVO 860 SSD, 2021-03-04-raspios-buster-arm64-lite image and plain k8s with cri-o. I had a similar problem described at https://github.com/amimof/sftp/issues/1 After I played a little bit with the resources limits I found the following working settings:

resources:
  sftp:
    limits:
      cpu: 3000m
      memory: 256Mi
    requests:
      cpu: 100m
      memory: 128Mi

The client connects quite fast and the download went up to 25MB/s. I'm just a bit confused why I only get 25MB/s and not almost 1GB/s maybe someone has the same experience?

steled avatar Jul 29 '21 17:07 steled

I am having this issue without any defined resource limits, as well as with high ones like in the comment above. Its also on a Raspberry Pi 4, tho it is one with only 4 GB of ram. It isn't on an external SSD, but connecting to the host system using sftp is pretty much instant, so I don't think the disk speed is the issue.

ToMe25 avatar Oct 08 '21 19:10 ToMe25