开发者

Webserver optimization in linux using pipe

开发者 https://www.devze.com 2023-03-04 23:08 出处:网络
I have written a web server which reads the requested file and writes to the socket. When I read the file I put开发者_JAVA技巧 the content of the file to the user space of OS and,

I have written a web server which reads the requested file and writes to the socket. When I read the file I put开发者_JAVA技巧 the content of the file to the user space of OS and, when I write it to the socket again I put the content to the kernel space of the operating system.

So I put it to the user space and again to the kernel space. This seems to be a waste of resources.

  1. Isn't there a better option? Like directly sending to the kernel space rather than going through user space?
  2. How can I optimize this process?
  3. Can I use PIPE to optimize this?


Try those, which can copy data from a file to a socket directly through kernel :

  • http://linux.die.net/man/2/sendfile
  • http://linux.die.net/man/2/splice
0

精彩评论

暂无评论...
验证码 换一张
取 消