it to the front-end Web server, the last to reach the user. This approach consumes a lot of memory when you need to download a large file, or even triggers a PHP process to timeout or crash. The Cache is also a headache, not to mention the interruption of the heavy connection.
An ideal solution should be, by the PHP program, such as the right to check the logic of the decision, all through the front of the Web server directly to send the file to the user-like Nginx such as the front desk is bet
Sendfile essence is an optimization technology in Linux system, in order to send files and network communication, reduce the user-state space and disk switching data, and directly at the core level of data copy, This technology is linux2.4, it is now very common in the C network-side server, and for Java, because Java is a high-level language in the advanced language, at least at the level of the C language can provide the interface
Linux quot; zero copy quot; sendfile function Chinese description and actual operation analysis-Linux general technology-Linux programming and kernel information, the following is a detailed description. Sendfile Function Description
# Include
Ssize_t sendfile (int out_fd, int in_fd, off_t * offset, size_t count );
Se
Address: http://www.vpsee.com/2009/07/linux-sendfile-improve-performance/
Currently, the popular Web servers provide the sendfile option to improve server performance. What is sendfile? How does it affect performance? Sendfile is actually a system call launched after Linux 2.0 +. The web server can adjust its own confi
Original address: http://www.vpsee.com/2009/07/linux-sendfile-improve-performance/
The popular Web server now offers Sendfile options to improve server performance, what exactly is sendfile and how does it affect performance. Sendfile is actually a system call after Linux 2.0+, and the Web server can adjust its own con
, and then send it to the front-end web server before reaching the user. When the files to be downloaded are large, this method will consume a lot of memory, and even cause the php process to time out or crash. The Cache is also a headache, not to mention the reconnection interruption.
An ideal solution is to perform permission check and other logic judgment by the php program. After everything passes, enable the front-end web server to directly send files to users-a front-end such as Nginx is b
Today, when looking at the Nginx thread pool, frequently see sendfile, in fact, often see sendfile, but I usually selectively ignore it ... First, Sendfile, tomorrow in a good chat on the nginx thread pool Some of the sudden, through the pseudo-official blog introduced how to use the Nginx thread pool AIO, achieve 9 times times the performance .... Personally, hi
Nginx sends static files at extremely fast speeds. The x-sendfile mechanism in Nginx relies on the X-Accel-Redirect feature. However, after my tests, it cannot meet my needs, I want to use lua to process the business logic and then send the file content. It is implemented in the following method at the beginning. If the file size is small, it doesn't matter, but when the file size is large, it has a great impact on performance. [Cpp] local file = io.
In Nginx, what scenarios are suitable for enabling sendfile, what scenarios are suitable for enabling directio in Nginx, what scenarios are suitable for enabling sendfile, And what scenarios are suitable for enabling directio?
Reply content:
In Nginx, which scenarios are suitable for enabling sendfile and direo o?
Http://nginx.org/en/docs/http/ngx_http_co
me see the hope.
Access to information, we can use the X-sendfile module to achieve more efficient file downloads.X-sendfile is a modern operating system supported by a high-performance network IO, server-side scripting such as PHP is responsible for building the request header information, and then download the time does not require PHP to participate in the Web servers directly processing X-
BBS or website often have only you have permission to see this page, or download this resource, a few days ago visited the Nginx server how to realize this file control, used to X-sendfile.
One, what is x-sendfile.
X-sendfile is a mechanism for transferring file download requests from back-end applications to front-end Web server processing, which eliminates th
This article mainly introduces a way to make file downloads faster in PHP, that is, using the X-SendFile header, which is supported by servers with active traffic, in general, we can direct the URL to a file under the Document Root to guide users to download the file.
However, in this way, we can't do some statistics, permission checks, and so on. so, in many cases, we use PHP for forwarding to provide users with file downloads.
The code is as follo
Use the X-SendFile header in PHP to make file download faster. In general, we can direct the URL to a file under DocumentRoot to guide users to download the file. however, in this way, we can't make some statistics. In general, we can direct the URL to a file under the Document Root to guide users to download the file.
However, in this way, we can't do some statistics, permission checks, and so on. so, in many cases, we use PHP for forwarding to prov
Using Nginx's X-Sendfile mechanism to improve PHP file download performance many times users need to download files from the website. if the files can be publicly obtained through a fixed link, you only need to store the file in the webroot directory. However, in most cases, permission control is required. for example, to download P, the Nginx X-Sendfile mechanism is used to improve the php file download pe
-Disposition: attachment; filename * = \" utf8'' ". $ filename .'"');} Else {Header ('content-Disposition: attachment; filename = "'. $ filename .'"');}Header ("Content-Length:". filesize ($ file ));Readfile ($ file );Well, it seems much better now, but there is another problem, that is, readfile. Although PHP's readfile is trying to be as efficient as possible, it does not occupy the PHP memory, but in fact, it still needs to use MMAP (if supported), or a fixed buffer to read the file cyclicall
Sendfile
Now the popular Web server has the Sendfile option to improve server performance, what exactly is sendfile, how does it affect performance? Sendfile is actually a system call after linux2.0+, and the Web server can decide whether to take advantage of the Sendfile sy
Use nginx x-sendfile mechanism to improve PHP file download performance
Many times users need to download files from the site, if the file can be obtained through a fixed link publicly, then we just need to store the file in the directory under Webroot. But in most cases, we need to do permission control, such as downloading a PDF bill, or downloading files from a Web disk. At this point, we usually use scripting code to implement, and this will undou
Use nginx x-sendfile mechanism to improve PHP file download performance
Many times users need to download files from the site, if the file can be obtained through a fixed link publicly, then we just need to store the file in the directory under Webroot. But in most cases, we need to do permission control, such as downloading a PDF bill, or downloading files from a Web disk. At this point, we usually use scripting code to implement, and this will undou
Tags: offset write-back posmmapmap pre descriptor inux Loop Sendfile function Description #include ssize_t sendfile (int out_fd, int in_fd, off_t *offset, size_t count); Sendfile () is an action function for copying data between two file descriptors. This copy operation is operating in the kernel, so it is called a "0 copy". The
In the APACHE,NGINX,LIGHTTPD and other Web servers, there is a sendfile-related configuration, in some online information has talked about Sendfile will improve the file transfer performance, that sendfile what is it? What is the principle of it?In the traditional file transfer inside (Read/write way), in the implementation is actually more complex, need to go th
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.