Jetty的http模块

启用http模块,执行如下命令:

shell 复制代码
java -jar $JETTY_HOME/start.jar --add-modules=http

查看http模块的配置文件,执行如下命令:

shell 复制代码
cat $JETTY_BASE/start.d/http.ini

输出如下:

shell 复制代码
# ---------------------------------------
# Module: http
# Enables a clear-text HTTP connector.
# By default clear-text HTTP/1.1 is enabled, and clear-text HTTP/2 may be added by enabling the "http2c" module.
# ---------------------------------------
--modules=http

### Clear-Text HTTP Connector Configuration

## The host/address to bind the connector to.
# jetty.http.host=0.0.0.0

## The port the connector listens on.
# jetty.http.port=8080

## The connector idle timeout, in milliseconds.
# jetty.http.idleTimeout=30000

## The number of acceptors (-1 picks a default value based on number of cores).
# jetty.http.acceptors=1

## The number of selectors (-1 picks a default value based on number of cores).
# jetty.http.selectors=-1

## The ServerSocketChannel accept queue backlog (0 picks the platform default).
# jetty.http.acceptQueueSize=0

## The thread priority delta to give to acceptor threads.
# jetty.http.acceptorPriorityDelta=0

## Whether to enable the SO_REUSEADDR socket option.
# jetty.http.reuseAddress=true

## Whether to enable the SO_REUSEPORT socket option.
# jetty.http.reusePort=false

## Whether to enable the TCP_NODELAY socket option on accepted sockets.
# jetty.http.acceptedTcpNoDelay=true

## The SO_RCVBUF socket option to set on accepted sockets.
## A value of -1 indicates that the platform default is used.
# jetty.http.acceptedReceiveBufferSize=-1

## The SO_SNDBUF socket option to set on accepted sockets.
## A value of -1 indicates that the platform default is used.
# jetty.http.acceptedSendBufferSize=-1

各参数的说明,如下:

  • jetty.http.host

    指定监听的主机地址。

  • jetty.http.port

    指定监听的端口,默认值为8080。

  • jetty.http.idleTimeout

    服务端检查通信链接,假如在给定时间内发现没有收到或者写出数据,则判定该链接进入空闲状态。

    判定通信链接进入空闲状态前,等待的超时值,单位:毫秒。

    默认值为30000,即30秒。

  • jetty.http.acceptors

    指定acceptor的数量,默认值为1,即只创建一个acceptor对象。

    取值为-1时,则自动依据cpu核的数量来决定acceptor的数量。

  • jetty.http.selectors

    指定selector的数量,默认值为-1,即自动依据cpu核的数量来决定acceptor的数量。

  • jetty.http.acceptQueueSize

    等待accept操作时的队列的长度,默认值为0,即使用当前操作系统的默认值。

  • jetty.http.acceptorPriorityDelta
    acceptor线程的优先级。

  • jetty.http.reuseAddress

    重用本地监听地址的开关,默认值为true,即绑定地址时如遇到TIME_WAIT时允许绑定成功。

    TCP选项名为SO_REUSEADDR。

    参考资料,如下:

  • jetty.http.reusePort

    重用监听端口的开关,默认值为false。

    TCP选项名为SO_REUSEPORT。

  • jetty.http.acceptedTcpNoDelay

    是否开启TCP_NODELAY选项的开关,默认值为true。

    TCP选项名为TCP_NODELAY。

    参考资料如下:

  • jetty.http.acceptedReceiveBufferSize

    接收数据的缓冲区的大小,默认值为-1,即使用当前操作系统的默认值。

    TCP选项名为SO_RECVBUF。

    参考资料如下:

    查看操作系统默认值,执行如下命令:

    shell 复制代码
    sysctl -a|grep ipv4.tcp|grep mem

    输出,如下:

    shell 复制代码
    net.ipv4.tcp_mem = 44583	59446	89166
    net.ipv4.tcp_rmem = 4096	131072	6291456
    net.ipv4.tcp_wmem = 4096	16384	4194304
  • jetty.http.acceptedSendBufferSize

    发送数据时的缓冲区的大小,默认值为-1,即使用当前操作系统的默认值。

    TCP选项名为SO_SENDBUF。

相关推荐
夜之眷属23 分钟前
Core dump 崩溃排查:JVM 宕机后,那份 core 文件怎么用 gdb 还原现场
java·运维·服务器·jvm
长按助力退休26 分钟前
HTTP缓存从强缓存到协商缓存,前端性能优化第一步
http
波加曼大王26 分钟前
# vLLM不要迷信PagedAttention神话,聊聊线上藏着的内部碎片陷阱
java·架构
SL_staff30 分钟前
目标健康度自检清单:开发者视角下的目标-计划-任务链路断点诊断
java·开源·github
for_ever_love__34 分钟前
MySQL 高频面试题 30 问:索引、事务、锁、日志、主从与分库分表(MySQL 8.0 版)
java·数据库·spring boot·mysql·spring cloud·面试·总结
神仙别闹35 分钟前
基于C++实现的贪吃蛇游戏平台
java·c++·游戏
布吉岛的石头1 小时前
Java 程序员第 49 阶段11:Java 接 BERT:用 ONNX Runtime 做句向量推理
java·人工智能·python·深度学习·bert·transformer
niucloud-admin1 小时前
JAVA V6 多商户商城 开发文档——JAVA服务端
java·开发语言
alexlifexyz1 小时前
写了个 Claude Code 插件:AI 写的 Java 违反阿里规约,就写不进文件
java
威哥爱编程1 小时前
【AI全栈12-01】Spring Boot 为何是 AI 全栈后端优选
java·spring boot·后端