NGINX.COM
Web Server Load Balancing with NGINX Plus

Open source is the driving force for more and more innovation in technology and business, and open source is the new standard for application development, as described in our blog post, The Three Waves of Open Source Development.

NGINX is one of the most significant open source projects, powering nearly half of the world’s busiest websites. We’re proud of the many significant contributions from our team, both at work and individually. Open source technology and contribution are core to our values as a company.

Now NGINX has teamed up with our partner Netflix, another driving force in open source, to offer a new implementation of the sendfile(2) system call, for FreeBSD only, which further speeds up TCP data transfers.

sendfile runs fast because it avoids copying file data into a buffer before it’s sent. The new version of sendfile further speeds up and simplifies large data transfers by supporting asynchronous I/O.

The new sendfile is a product of the ongoing development partnership between NGINX and Netflix, and was released in tandem with Netflix’ recent service expansion to nearly 200 countries. Netflix is using it in production to send multiple tens of gigabytes per second.

The new implementation of sendfile adds two new flags and redefines an existing flag:

  • SF_NOCACHE tells the kernel that data is not to be cached after it’s sent.
  • SF_READAHEAD is a macro that allows you to specify the read-ahead size in pages.
  • SF_NODISKIO no longer blocks, and returns EBUSY in the rare
    situations where the file is temporarily busy. In this case, you can retry the operation in a moment.

The new sendfile is a drop-in replacement for the previous one. You don’t need to make any changes to your applications. However, you can now expect significantly better performance in cases where the old sendfile blocked on disk I/O, and you can add the SF_NOCACHE flag and the SF_READAHEAD macro, with a page count, to modify the action of sendfile.

For more information, please see these related links:

Note: sendfile bypasses user space, so filters that change content, such as gzip, do not normally work in combination with sendfile. To avoid bypassing filters, NGINX automatically disables sendfile when a configuration context includes both sendfile and one or more directives that activate a filter which modifies content.

Image appearing for this post on the NGINX, Inc. blog home page is courtesy of NASA.

Hero image
免费 O'Reilly 电子书:
《NGINX 完全指南》

更新于 2022 年,一本书了解关于 NGINX 的一切

关于作者

Owen Garrett

产品管理高级总监

Owen is a senior member of the NGINX Product Management team, covering open source and commercial NGINX products. He holds a particular responsibility for microservices and Kubernetes‑centric solutions. He’s constantly amazed by the ingenuity of NGINX users and still learns of new ways to use NGINX with every discussion.

关于 F5 NGINX

F5, Inc. 是备受欢迎的开源软件 NGINX 背后的商业公司。我们为现代应用的开发和交付提供一整套技术。我们的联合解决方案弥合了 NetOps 和 DevOps 之间的横沟,提供从代码到用户的多云应用服务。访问 nginx-cn.net 了解更多相关信息。