Skip to content

Enable Streaming from SFTP to GCS in SFTPToGCSOperator #34995

Closed

Description

@rynmccrmck

Description

The current SFTPToGCSOperator in Airflow does not support streaming objects directly from SFTP to Google Cloud Storage (GCS). This design poses a challenge since both Composer and Airflow best practices recommend against assigning large amounts of memory to workers. Transferring sizeable files from SFTP to GCS without streaming can potentially max out worker memory.

Use case/motivation

Prevent worker memory exhaustion, especially when dealing with large files.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Oct 17, 2023

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  2. changed the title [-]Enhancement: Enable Streaming from SFTP to GCS in `SFTPToGCSOperator`[/-] [+]Enable Streaming from SFTP to GCS in `SFTPToGCSOperator`[/+] on Oct 17, 2023
  3. hegongwork commented on Oct 17, 2023

    @hegongwork

    hi @ferruzzi
    yesterday in my project I wrote this code and my colleague @rynmccrmck told me I could added the code to Airflow and this PR is his draft for me. I will create a same PR.

  4. ferruzzi commented on Oct 17, 2023

    @ferruzzi
    Contributor

    I'll assign the issue to you then. let me know if you need any help

  5. hegongwork commented on Oct 18, 2023

    @hegongwork

    update: I wrote a PR in my own repo: https://github.com/he-gong-sardine/airflow/pull/1/files
    but I haven't set up airflow environment so I cannot test it.
    I will send PR after I test it locally.

  6. Player00liv commented on Oct 23, 2023

    @Player00liv

    Vhuut

  7. elaye-canopy commented on Dec 21, 2023

    @elaye-canopy

    @he-gong-sardine did you get a chance to test it?
    I am encountering a similar issue and was in the process of testing a fix independent of yours (I will also upload it later for comparison), but if yours already works I might just go with yours.
    I've also left a comment (well, a question, but not a criticism) on your PR.

    Also, not directly related but logically related - perhaps similar logic should be made for the converse operator as well (GCS to SFTP)

  8. hegongwork commented on Jan 3, 2024

    @hegongwork
  9. elaye-canopy commented on Jan 7, 2024

    @elaye-canopy

    @he-gong-sardine
    Great to see this is worked on, we independently solved it on our side and I put a comment in the code about that.

    Your solution does seem to work but seems to have led to significant slowdown when we tested it on files > 60gb (we obviously didn't test the google upload from file version on that file size).

    I put a comment with a snippet of the code we used to solve it, as well as a link to Paramiko's documentation where you can find the signature of the Paramiko maintained methods (getfo) which uses Paramiko's prefetch to solve the performance issues.
    We have a DAG downloading 4 files simultaneously (10GB, 16GB, 60GB, and 166GB) so a slowdown would have meant we would keep doing it all day long.

    The file is in a private repo currently but if you want my version of the fix, to make it PR ready, feel free to contact me and I'll get it to you.

  10. elaye-canopy commented on Jan 7, 2024

    @elaye-canopy

    Also, again, not directly related but logically related - perhaps similar logic should be made for the converse operator as well (GCS to SFTP).

    There is a paramiko funciton putfo similiar to the getfo that I recommended in my comment, which could be useful for that.

  11. Vamsi-klu commented on Jun 13, 2026

    @Vamsi-klu
  12. Vamsi-klu commented on Aug 27, 2026

    @Vamsi-klu
  13. added a commit that references this issue on Aug 27, 2026
    14fd820
  14. added a commit that references this issue on Sep 11, 2026
    cdfc2d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions