压测代码:
@SpringBootTest @Slf4j public class FastBootApplicationTest { /** * 并发数量 */ public static final int THREAD_NUM=14000;private static final String url="http://localhost:8084/dept/100"; public static void main(String[] args) { CountDownLatch countDownLatch = new CountDownLatch(THREAD_NUM); for (int i = 0; i < THREAD_NUM; i++) { new Thread(()-> { { try { //开始倒计数,每次减1,直到计够THREAD_NUM次 countDownLatch.countDown(); //阻塞等待 countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } HttpResponse execute = HttpRequest.get(url).execute(); log.info(Thread.currentThread().getName()+"----返回:{}",execute.body()); } },"thread"+i).start(); } } }