System.out.println under high concurrency cause the application to pause

Today during the press serial number when measured to obtain the serial number by calling genSeqId method, concurrent 100, 16 pressure measuring machine and found that no matter how the pressure test, the amount of call time to reach 140w, ops this method of direct dropped 0 specifically illustrated as follows:

Enterprise pound 20190805172354

From the graph you can clearly see, the whole cliff-style presentation ops fell.

At that time much thought, puzzled, then later commented code System.out.println, and then to the pressure measured and found to return to normal:

 

Enterprise pound 20190805172329

The figure can be seen, down to the amount of one hundred million, due to the problem is not found, stopped pressure measurement.

System.out.println source later read a bit and found that it is not suitable for printing work under high concurrency, due to its internal operations to synchronize with a lot of Synchronized, thus resulting in the need for synchronous waiting operation between the two requests .

More specific instructions, see: https://softwareengineering.stackexchange.com/questions/246534/how-bad-is-it-calling-println-often-than-concatenating-strings-together-and-ca

Guess you like

Origin www.cnblogs.com/scy251147/p/11304570.html