[GitHub] tomcat pull request #126: The feature of the transfer rate control are added...

2018-10-12 Thread Yuanuo
GitHub user Yuanuo opened a pull request:

https://github.com/apache/tomcat/pull/126

The feature of the transfer rate control are added to the sendfile.

The Sendfile feature has been added with the characteristics of the 
transfer rate control, which can be individually limited for each sendfile 
process.
Use a double value in megabytes per second.
has been tested by: APR, NIO, NIO2 these three kinds of connector modes.
And the initial parameter "sendfilerate" configuration support for global 
Defaultservlet.

BTW:The org.apache.tomcat.util.net.RateLimiter is copied from 
lucene-core-7.5.0.jar.



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/Yuanuo/tomcat 
feature-sendfile-rate-limit-support

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/tomcat/pull/126.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #126


commit 17c0e917fe1d9a80d31134d305a9cc38a761f3cb
Author: Yuanuo 
Date:   2018-10-12T13:51:34Z

The feature of the transfer rate control are added to the sendfile.
The Sendfile feature has been added with the characteristics of the 
transfer rate control, which can be individually limited for each sendfile 
process.
Use a double value in megabytes per second.
has been tested by: APR, NIO, NIO2 these three kinds of connector modes.
And the initial parameter "sendfilerate" configuration support for global 
Defaultservlet.




---

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[GitHub] tomcat issue #126: The feature of the transfer rate control are added to the...

2018-10-12 Thread Yuanuo
Github user Yuanuo commented on the issue:

https://github.com/apache/tomcat/pull/126
  
Ok. It has been closed, but I still want to express my views here.

I am very sorry about my English level. These texts are all done with 
Google Translate.

1. In any actual environment, the resources and bandwidth of the server are 
limited, so the speed limit function is necessary.

2, Nginx, Apache, Lighttpd Web servers have Sendfile module to achieve 
high-performance data transmission. I am using Nginx now, the other two have 
not been studied. Nginx's Sendfile mode also supports speed limit, which is 
implemented using the "X-Accel-Limit-Rate" header. And the implementation 
principle of the speed limit is basically the same, in short, it is guaranteed 
to transmit only the bytes of certain data within one second, so the 
process/thread sleep wait will be generated. But does this speed limit feature 
make Nginx a low-performance web server? The answer is no, this feature will 
only work when you use it, but it is turned off by default. But this also 
provides a possibility for people to use.

3, we all know that Tomcat is not only used to transfer a few css or js, 
and according to the Tomcat implementation, to enable the Sendfile mode, the 
default sendfileSize is also 48KB, that is, only data larger than this amount 
will try to enable Sendfile transfer mode. In other applications, such as to do 
a file download server, you can't make any restrictions so that several 
download connections will run out of server bandwidth.

4, in the modern Web environment, generally do not directly use Tomcat as a 
Web server, but use Nginx+Tomcat or other working modes. If you are dealing 
with static resources, css, js, jpg, png, etc., most of them can be handed over 
to Nginx for direct processing without going through Tomcat. In this case, 
Tomcat's Sendfile will never be used. What does this mean? That is to say, the 
Sendfile function that everyone has to maintain will not be used, even if a lot 
of code is written to implement APR, NIO, NIO2 and other modes.

5, the code I submitted does not destroy the original working mode, which 
is what it is, these codes will not play any role by default. It will only be 
turned on after some parameters have been set. This gives people a possibility, 
but it is decided by people. On the contrary, even if there is a default 
high-performance NIO implementation of Sendfile, but people are worried that 
their server bandwidth is used up, and can not carry out any speed limit, then 
the default implementation of the Sendfile function will never be used, then 
everyone writes these What is the use of the code? Yes, you said that these 
requirements can be achieved by writing a Servlet or Filter yourself, yes, 
that's it. But everyone who uses Tomcat has to write a set of Servlets or 
Filters to implement this function. Who is the implementation of Tomcat's own 
implementation? I think this speed limit feature for Sendfile does not break 
any existing code and structure, but rather an enhancement to Tomcat.

6. Yes, there is no example of how to use it here. However, in the 
submitted code, the DefaultServlet has only been modified a few lines, and 
these lines (lines 2068-2070) are examples of how to use them. So some people 
may not have viewed the submitted code at all, and directly rely on other 
people's opinions to negate my code submission, showing that this is 
unacceptable, and I also doubt this kind of work attitude. Sorry! Since this 
has been closed, I am not going to describe the usage here.


Finally, no matter what, I decided to use Nginx's Sendfile to achieve my 
needs. This is how I use it in my current PHP code. This submission will be 
abandoned.


---

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org