There's a couple of questions with answers on tools or settings to simulate slow network conditions on different OSes, like
- Network tools that simulate slow network connection
- How do I simulate a low bandwidth, high latency environment?
Unfortunately, the answers don't mention a solution for my case, so it's not redundant or a duplicate.
I'm developing a web application (locally, with Node.js / Express on macOS, but that doesn't matter much) using a Redis cache and a MySQL database.
In order to do some (performance) testing on my local machine, I want to put load on that application (for example with ab
or JMeter
). Obviously, because the Redis cache and the MySQL database are running on the same machine as the web application, I have a stellar network connection (as in: none) between these three components.
I want to simulate different network connections between these components - as would be the case in a production setup with multiple servers - by downgrading the virtual 'connections' to Redis and MySQL (but with different latency and bandwidth settings per connection). The connections can be distinguished by the port numbers, but not by the hostname (which is localhost
for all three).
How can I simulate different network connection conditions for specific port numbers on the same machine?