Efficiency of Plug.Conn.send_file/5 in Elixir

131
clicks
Efficiency of Plug.Conn.send_file/5 in Elixir

Source: lucassifoni.info

Type: Post

Lucas Sifoni takes a detailed look into the Elixir function Plug.Conn.send_file/5, exploring community questions on its efficiency, particularly whether it utilizes Linux syscalls to send files – confirming that it does. The article guides through a journey from Phoenix to Plug, Cowboy, Ranch, Erlang's source code, and finally into C NIFs within Erlang's source, where it's shown that file transfer is handled efficiently by using the Linux 'sendfile' syscall. This syscall operates within the kernel, bypassing the need to transfer data to and from user space, making the operation more efficient than a combination of read and write operations that move data through user space. The investigation concludes with Lucas Sifoni affirming the efficiency of the send_file function on Linux.

© HashMerge 2024