Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate network latency with Apache Tomcat?

Is it possible to configure Apache Tomcat to simulate network latency that a client would normally have when requesting data from server for requests over localhost? I'm trying to test how the front end of a Java Servlet application will respond to requests that have slow response times.

I know I could go in and add Thread.sleep(100) to all of my Servlet Java source files, but I'd rather have a solution that can be configured in Tomcat rather than in my actual application.

like image 827
Ivan Avatar asked Jul 01 '26 00:07

Ivan


2 Answers

You can simulate network latency by using a proxy on your localhost which introduces latency, bandwidth restrictions, and even drop packets.

DonsProxy will do the job. Here's a good article describing how to configure it to simulate a user on a poor network.

like image 199
Daisetsu Avatar answered Jul 03 '26 13:07

Daisetsu


You can implement a servlet filter and have it intercept all requests. In each of the request you would be doing this Thread.sleep or something else. All requests to your servlets will be delayed.

like image 42
user1452132 Avatar answered Jul 03 '26 15:07

user1452132



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!