spring boot 性能测试工具汇总【logback异步日志分析】

1. 使用JMeter进行简单的带json数据的post请求测试

https://www.jianshu.com/p/b61f70b67266

2. jmeter&badboy做压力测试

https://www.cnblogs.com/happy-today/p/7852277.html

3. 实操-logback异步日志分析对比

  • 接口耗时对比,
    50个线程,每个线程循环次数50次
    异步比同步少了20ms

异步日志
spring boot 性能测试工具汇总【logback异步日志分析】_第1张图片

实时
在这里插入图片描述

  • logback文件





<configuration scan="true" scanPeriod="60 seconds" debug="false">

    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <springProperty scope="context" name="applicationName" source="spring.application.name"/>
    
    <property name="prjName" value="zat-life-product-service"/>
    
    <property name="appName" value="zatLifeProductService"/>
    
    <property name="logDir" value="/alidata1/admin"/>
    
    <property name="maxHistory" value="30"/>
    
    <property name="source" value="micro"/>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <target>System.outtarget>
        <encoder charset="UTF-8">
            <pattern>%magenta(%d{HH:mm:ss:SSS} [%thread]) %cyan(%-5p) %green([%C{0}.%M:%L])--%msg%xEx%npattern>
        encoder>
    appender>

    <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${logDir}/${prjName}/logs/debug-%d{yyyy-MM-dd}-ss_${source}_app_${appName}_lt_debug.log
            FileNamePattern>
            <maxHistory>${maxHistory}maxHistory>
        rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d [%thread] %-5p [%c] [%F:%L][trace=%X{X-Trace-Id:-},span=%X{X-Span-Id:-},parent=%X{X-Parent-Id:-},name=%X{X-Span-Name:-},app=%X{appName:-},begintime=%X{begintime:-},endtime=%X{fin-X1-time:-}] - %msg%n
            pattern>
        layout>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUGlevel>  
            <onMatch>ACCEPTonMatch>
            <onMismatch>DENYonMismatch>
        filter>
    appender>

    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${logDir}/${prjName}/logs/info-%d{yyyy-MM-dd}-ss_${source}_app_${appName}_lt_info.log
            FileNamePattern>
            <maxHistory>${maxHistory}maxHistory>
        rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d [%thread] %-5p [%c] [%F:%L]
                [trace=%X{X-Trace-Id:-},span=%X{X-Span-Id:-},parent=%X{X-Parent-Id:-},name=%X{X-Span-Name:-},app=%X{appName:-},begintime=%X{begintime:-},endtime=%X{fin-X1-time:-}] - %msg%n
            pattern>
        layout>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFOlevel>  
            <onMatch>ACCEPTonMatch>
            <onMismatch>DENYonMismatch>
        filter>
    appender>

    <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${logDir}/${prjName}/logs/warn-%d{yyyy-MM-dd}-ss_${source}_app_${appName}_lt_warn.log
            FileNamePattern>
            <maxHistory>${maxHistory}maxHistory>
        rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d [%thread] %-5p [%c] [%F:%L][trace=%X{X-Trace-Id:-},span=%X{X-Span-Id:-},parent=%X{X-Parent-Id:-},name=%X{X-Span-Name:-},app=%X{appName:-},begintime=%X{begintime:-},endtime=%X{fin-X1-time:-}] - %msg%n
            pattern>
        layout>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARNlevel>  
            <onMatch>ACCEPTonMatch>
            <onMismatch>DENYonMismatch>
        filter>
    appender>

    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${logDir}/${prjName}/logs/error-%d{yyyy-MM-dd}-ss_${source}_app_${appName}_lt_error.log
            FileNamePattern>
            <maxHistory>${maxHistory}maxHistory>
        rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d [%thread] %-5p [%c] [%F:%L][trace=%X{X-Trace-Id:-},span=%X{X-Span-Id:-},parent=%X{X-Parent-Id:-},name=%X{X-Span-Name:-},app=%X{appName:-},begintime=%X{begintime:-},endtime=%X{fin-X1-time:-}]- %msg%n
            pattern>
        layout>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERRORlevel>  
            <onMatch>ACCEPTonMatch>
            <onMismatch>DENYonMismatch>
        filter>
    appender>

    
    <appender name="DEBUG_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        
        <discardingThreshold>0discardingThreshold>
        
        <queueSize>512queueSize>
        
        <appender-ref ref="DEBUG_FILE"/>
    appender>

    
    <appender name="INFO_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        
        <discardingThreshold>0discardingThreshold>
        
        <queueSize>512queueSize>
        
        <appender-ref ref="INFO_FILE"/>
    appender>

    
    <appender name="WARN_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        
        <discardingThreshold>0discardingThreshold>
        
        <queueSize>512queueSize>
        
        <appender-ref ref="WARN_FILE"/>
    appender>

    
    <appender name="ERROR_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        
        <discardingThreshold>0discardingThreshold>
        
        <queueSize>512queueSize>
        
        <appender-ref ref="ERROR_FILE"/>
    appender>

    
    <logger name="org.apache" level="INFO"/>
    <logger name="org.springframework" level="INFO"/>
    <logger name="com.zatech" level="INFO"/>
    <logger name="com.zhongan" level="INFO"/>

    <springProfile name="prd">
        <root>
            <level value="INFO"/>
            <appender-ref ref="INFO_ASYNC"/>
            <appender-ref ref="WARN_ASYNC"/>
            <appender-ref ref="ERROR_ASYNC"/>
        root>
    springProfile>
    <springProfile name="dev,test,uat,pre">
        <root>
            <level value="INFO"/>
            <appender-ref ref="STDOUT"/>
            

       <appender-ref ref="WARN_ASYNC"/>
       <appender-ref ref="INFO_ASYNC"/>
       <appender-ref ref="ERROR_ASYNC"/>



        root>
    springProfile>

configuration>

你可能感兴趣的:(java基础,spring,boot,测试工具,压力测试)