web server apache tomcat11-25-Advanced IO and Tomcat

前言

整理这个官方翻译的系列,原因是网上大部分的 tomcat 版本比较旧,此版本为 v11 最新的版本。

开源项目

从零手写实现 tomcat minicat 别称【嗅虎】心有猛虎,轻嗅蔷薇。

系列文章

web server apache tomcat11-01-官方文档入门介绍

web server apache tomcat11-02-setup 启动

web server apache tomcat11-03-deploy 如何部署

web server apache tomcat11-04-manager 如何管理?

web server apache tomcat11-06-Host Manager App -- Text Interface

web server apache tomcat11-07-Realm Configuration

web server apache tomcat11-08-JNDI Resources

web server apache tomcat11-09-JNDI Datasource

web server apache tomcat11-10-Class Loader

web server apache tomcat11-11-Jasper 2 JSP Engine

web server apache tomcat11-12-SSL/TLS Configuration

web server apache tomcat11-13-SSI

web server apache tomcat11-14-CGI

web server apache tomcat11-15-proxy

web server apache tomcat11-16-mbean

web server apache tomcat11-17-default-servlet

web server apache tomcat11-18-clusting 集群

web server apache tomcat11-19-load balance 负载均衡

web server apache tomcat11-20-connectors 连接器

web server apache tomcat11-21-monitor and management 监控与管理

web server apache tomcat11-22-logging 日志

web server apache tomcat11-23-APR

web server apache tomcat11-24-Virtual Hosting and Tomcat

web server apache tomcat11-25-Advanced IO and Tomcat

web server apache tomcat11-26-maven jars

web server apache tomcat11-27-Security Considerations

web server apache tomcat11-28-Windows Service

web server apache tomcat11-29-Windows Authentication

web server apache tomcat11-30-The Tomcat JDBC Connection Pool

web server apache tomcat11-31-websocket

web server apache tomcat11-32-rewrite

web server apache tomcat11-33-CDI

web server apache tomcat11-34-Ahead of Time compilation support

介绍

重要提示:使用这些功能需要使用HTTP连接器。AJP连接器不支持它们。

异步写入

当使用HTTP连接器时,Tomcat支持使用sendfile发送大型静态文件。这些写操作在系统负载增加时会以最有效的方式异步执行。与使用阻塞写操作发送大型响应不同,可以将内容写入静态文件,并使用sendfile代码进行写入。缓存阀门可以利用这一点,将响应数据缓存到文件中,而不是将其存储在内存中。如果请求属性 org.apache.tomcat.sendfile.support 被设置为 Boolean.TRUE,则可以使用sendfile支持。

任何Servlet都可以通过设置适当的请求属性来指示Tomcat执行sendfile调用。还需要正确设置响应的内容长度。当使用sendfile时,最好确保请求或响应都没有被包装,因为响应主体将由连接器自身稍后发送,无法进行过滤。除了设置所需的3个请求属性之外,Servlet不应发送任何响应数据,但可以使用任何导致修改响应标头的方法(比如设置cookies)。

  • org.apache.tomcat.sendfile.filename:将作为String发送的文件的规范文件名
  • org.apache.tomcat.sendfile.start:作为Long的起始偏移量
  • org.apache.tomcat.sendfile.end:作为Long的结束偏移量

除了设置这些参数之外,还需要设置content-length头。Tomcat不会为您执行此操作,因为您可能已经将数据写入输出流。

请注意,使用sendfile将禁用Tomcat对响应的任何压缩操作。

相关推荐
野犬寒鸦8 分钟前
力扣hot100:相交链表与反转链表详细思路讲解(160,206)
java·数据结构·后端·算法·leetcode
ytadpole1 小时前
揭秘设计模式:工厂模式的五级进化之路
java·设计模式
计算机毕业设计木哥1 小时前
计算机毕设选题:基于Python+Django的B站数据分析系统的设计与实现【源码+文档+调试】
java·开发语言·后端·python·spark·django·课程设计
失散131 小时前
分布式专题——1.2 Redis7核心数据结构
java·数据结构·redis·分布式·架构
用户3721574261351 小时前
Python 实现 HTML 转 Word 和 PDF
java
a587691 小时前
Java核心概念精讲:TCP与UDP的区别、Java NIO的几个核心组件与HTTP和HTTPS的区别等(46-50)
java·面试·nio
渣哥2 小时前
ConcurrentHashMap 的 get 要不要加锁?一次“多此一举”的心路历程
java
愿你天黑有灯下雨有伞2 小时前
一种基于注解与AOP的Spring Boot接口限流防刷方案
java·spring boot·后端
MuMuMu#2 小时前
JAVA NIO学习笔记基础强化学习总结
java·学习·nio
拾忆,想起2 小时前
Redis复制延迟全解析:从毫秒到秒级的优化实战指南
java·开发语言·数据库·redis·后端·缓存·性能优化