sendfile for sending files

Forwarding files from one file to another is not effective, because this approach copies every chunk of data to the memory before sending it. Popular servers such as NGINX use the sendfile system call to send files from one file descriptor to another. This helps to save a lot of resources, because sendfile allows for zero copy, which means that we can write the buffer directly to the necessary device. To use sendfile with tokio, you have to implement a wrapper for it, but I don't think it's a good idea to serve static files with a microservice. You may prefer to use NGINX for this task or use object storage such as AWS S3, which can provide static files to a client.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.30.19