Pro, you have taken (logback + log4j2) performance testing to be wrapped in check

EDITORIAL

Some time ago wrote an article (article link: Logback profile so written, TPS 10 times ), reaction is not bad, there are many users also expressed their views:

1 comments
2 comments
Opinions three

It boils down to this:

  • logback performance testing of synchronous and asynchronous TPS or less
  • 9102 years are still using logback

See the views of users and then continue to do the wave of testing and research

Server Hardware

  • Six-core CPU
  • 8G memory

test tools

  • JMeter
  • JProfile
  • APM(New Relic)

logback logging framework synchronous and asynchronous test

There is a problem before the following test results:

  • Test sample size is too small (ie, the number of threads and number of cycles performed little, before thread count of 100, 1 cycle, a total sample of 100)
  • Test number is too small, had only one test, the result in accidental
  • Two test results there is pollution, the number of samples is not the same

To solve the above problem, retest the number of threads will be changed to 200, 100 times each test cycle, the total number of samples to expand the number of samples 2w, and 200 times compared to the original test, and the test is repeated five times. The new test results are as follows:

logback synchronous and asynchronous test performance report

New test results show that the use logback logging framework synchronous and asynchronous TPS output log way less. The data made into a bar graph more intuitive

logback synchronous and asynchronous test results

But always felt asynchronous to write the log, access api thread will quickly respond to the client, TPS should have significant changes fishes. Can not figure went online access to some information, respond by saying APMperformance monitoring, synchronous and asynchronous TPS will have a greater difference, TPS is certainly there will be significant changes (cry), then use JMeter to send to monitor APM request ( JMeterparameter set to the number of threads 100, Ramp-up Period 0, 100 cycles): the APM test results are as follows:

APM- asynchronous log output
Monitoring the APM, within five minutes asynchronous execution log output TPS average 378rpm

APM- synchronous output log

Under APM monitoring, within five minutes to perform synchronization output log an average of 333rpm found TPS TPS synchronous and asynchronous comparison is not obvious

Although once again proved that the failure would not understand but later explored and friends, the sobering

I'm good food ah

TPS did not change significantly following reason: as the number of transactions per second TPS, each transaction includes the following three processes:

  • The user requests the server
  • The server's own internal processing
  • Server returned to the user

Own internal server request comprises accessing a database, the processing logic and print logs, synchronous and asynchronous only difference is in the way the printing log. From the test results, print log API access request takes only 5.3%, so the shortened time-consuming print log can not obviously improve the TPS, because the print time and network requests, time-consuming business processes negligible but the test results indicates that, although not significantly improve the asynchronous output TPS, but can reduce time-consuming printing logs. So use logback logging framework is recommended to use asynchronous output

Recommended log4j2 instead logback

log4j2 is an upgraded version of log4j 1.x, reference to some excellent design logback, and fixes some problems, brought some significant improvement, performance in terms of asynchronous been a huge boost, which in addition to providing Async Append asynchronous implementation also provided outside Async Log asynchronously, wherein Async Append asynchronous and asynchronous manner similar logback implementation, based on the Async Log LMAX Disruptor library, to achieve a high-performance asynchronous recorder. log4j2 asynchronous implementation of this test is based on Async Log. JMeter logback test parameters and test as before, threads 200, 100 cycles, repeated five. Logj2日志配置文件基本和 logback same configuration and asynchronous satisfy:

  • Console Print Log
  • Categories output log
  • By day rolling
  • The same log output format

Test results are as follows:

logback and log4j2 asynchronous test performance report
The TPS production as a bar graph
logback and log4j2 asynchronous test results

TPS promoted 6 times! ! ! And print logs takes almost no statistics to come out of the official test report, log4j2 and logback performance compared to more obvious. Attached official test report: Asynchronous Loggers Logging for Low-Latency

in conclusion

  • If you use logback framework, it is recommended to use asynchronous mode output log
  • Select the logging framework, recommended log4j2

    Last Attachment: test code

Original difficult, if reproduced, please indicate the source: https: //juejin.im/post/5d66a36c518825199701e2ad Author: how sweet it in

In addition to reprint a reward little money can do, recently playing docker, really want to buy a MacBookPro, although bought a low-performance Linux server may still want to buy a mbp

Not regressed, but lack of money, as long as everyone contributes a little love, I can afford to buy MacBookPro

Guess you like

Origin juejin.im/post/5d66a36c518825199701e2ad