zoukankan      html  css  js  c++  java
  • Springboot 内置tomcat 基本配置收集整理

    配置一:

    server:
    # tomcat 配置
      tomcat:
        # 接收队列长度
        accept-count: 1000
        # 最小空闲线程数
        min-spare-threads: 100
        # POST请求提交大小
        max-http-form-post-size: 50MB
        # 最大链接数
        max-connections: 1000
        # 最大线程数
        max-threads: 400
        #编码方式
        uri-encoding: UTF-8
        #链接建立超时时间
        connection-timeout: 10000
        #日志配配置
        accesslog:
          #是否启用
          enabled: true
          #目录
          directory: C:logs omcat${server.port}
          #文件日期格式
          file-date-format: yyyy-MM-dd
          #前缀
          prefix: access_log
          #后缀
          suffix: .log
          #日志格式,默认为common,也可自定义配置
          pattern: combined

    其他相关配置:

    server.tomcat.basedir:配置 Tomcat 运行日志和临时文件的目录。若不配置,则默认使用系统的临时目录。

    内存配置:

    要加“m”说明是MB,否则就是KB.
    -Xms:初始值
    -Xmx:最大值
    -Xmn:最小值
    java -Xms10m -Xmx80m -jar mod.jar & 时区设置 java -jar -Duser.timezone=GMT+08
    mod.jar &

    Spring Boot项目同路径下新建一同名配置文件

    项目为boot.jar,新建文件boot.conf,项目启动之后默认读取该配置文件

    1、jvm运行参数

    JAVA_OPTS="-Xms2048m -Xmx2048m -Xss512k"

    -Xms:初始Heap大小,使用的最小内存,cpu性能高时此值应设的大一些-Xmx:Java heap最大值,使用的最大内存

    上面两个值是分配JVM的最小和最大内存,取决于硬件物理内存的大小,建议均设为物理内存的一半。-XX:PermSize:设定内存的永久保存区域-XX:MaxPermSize:设定最大内存的永久保存区域-XX:MaxNewSize:-Xss 15120 这使得JBoss每增加一个线程(thread)就会立即消耗15M内存,而最佳值应该是128K,默认值好像是512k.+XX:AggressiveHeap 会使得 Xms没有意义。这个参数让jvm忽略Xmx参数,疯狂地吃完一个G物理内存,再吃尽一个G的swap。-Xss:每个线程的Stack大小-verbose:gc 现实垃圾收集信息-Xloggc:gc.log 指定垃圾收集日志文件-Xmn:young generation的heap大小,一般设置为Xmx的3、4分之一-XX:+UseParNewGC :缩短minor收集的时间-XX:+UseConcMarkSweepGC :缩短major收集的时间

    提示:此选项在Heap Size 比较大而且Major收集时间较长的情况下使用更合适。

    2、项目运行参数

    RUN_ARGS="--server.port=8081 --logging.level=INFO --spring.thymeleaf.cache=true --logging.file=/var/log/demo.lo

    日志模式配置:

    pattern的配置:

    %a - Remote IP address,远程ip地址,注意不一定是原始ip地址,中间可能经过nginx等的转发
    %A - Local IP address,本地ip
    %b - Bytes sent, excluding HTTP headers, or ‘-’ if no bytes were sent
    %B - Bytes sent, excluding HTTP headers
    %h - Remote host name (or IP address if enableLookups for the connector is false),远程主机名称(如果resolveHosts为false则展示IP)
    %H - Request protocol,请求协议
    %l - Remote logical username from identd (always returns ‘-‘)
    %m - Request method,请求方法(GET,POST)
    %p - Local port,接受请求的本地端口
    %q - Query string (prepended with a ‘?’ if it exists, otherwise an empty string
    %r - First line of the request,HTTP请求的第一行(包括请求方法,请求的URI)
    %s - HTTP status code of the response,HTTP的响应代码,如:200,404
    %S - User session ID
    %t - Date and time, in Common Log Format format,日期和时间,Common Log Format格式
    %u - Remote user that was authenticated
    %U - Requested URL path
    %v - Local server name
    %D - Time taken to process the request, in millis,处理请求的时间,单位毫秒
    %T - Time taken to process the request, in seconds,处理请求的时间,单位秒
    %I - current Request thread name (can compare later with stacktraces),当前请求的线程名,可以和打印的log对比查找问题

  • 相关阅读:
    Java回调理解 (step by step)
    Android中网络流量控制(防火墙)——Iptables
    JavaScript学习总结1
    怎样在Android实现桌面清理内存简单Widget小控件
    linux文件夹介绍
    git版本号回滚
    页面载入完毕后表单获得焦点
    (转)Arcgis for JS之Cluster聚类分析的实现
    (转)Arcgis for javascript实现百度地图ABCD marker的效果
    (转)Hadoop入门进阶课程
  • 原文地址:https://www.cnblogs.com/xin_ny/p/12732108.html
Copyright © 2011-2022 走看看