Perform Stress Test on C#

Asked

Viewed 790 times

14

I have the following scenario: There is a Windows Service, done in C#, which is used to synchronize data from a local database to a cloud base and need to perform some stress and charge, with this, I thought to carry out the following test:

  1. How would this service behave with instabilities in the network? For example, the internet has fallen in the middle of the process and with that is impossible for a while to perform synchronization.
  2. Simulate server slowness that causes the process to take longer to run.
  3. Simulate a large data load.

I would like to know how I can simulate these test cases, especially case 1, since this is something that the system needs to deal with, as it is an already predicted scenario that usually occurs in the environment Windows Service is installed.

I have read that normally, in the case of Windows Service, the ideal is to export the dll of him to test his public methods in this scenario, but I don’t know to what extent this is true.

  • Indirectly related question: https://answall.com/a/216574/57801

2 answers

4

What I believe can help the question:

  1. I don’t know how your architecture was modeled, but the use of some of Jobs' libraries might solve it. Take a look at Hangfire, which has automatic Schedule in exceptions. This way if a network Exception or something else is triggered, you don’t have to worry about rescheduling the call execution.

  2. Unfortunately, there’s no simple way to do that. I think you should get an idea of the type of server your service will run, so maybe a machine with Hyper-V where you create server simulations with more/less resources is the way. Processing slowness is not only due to the execution, but also to the processing on the server, available memory. It has this reference in MSDN that can give you a way: https://blogs.msdn.microsoft.com/vijaysk/2012/10/26/tools-to-simulate-cpu-memory-disk-load/

  3. If your architecture is totally disconnected, the correct thing would be to separate the logic of the service itself, and perform Unit-tests or load-tests on that layer. There are "n" libraries for Unit test, including Visual Studio has a load-tests tool.

  • This 1 my system already does this, wanted to know how I could make a test simulating his behavior when it occurs.

  • I believe that create a Unit-test, where you point to an inaccessible host, or even a port that does not respond in an accessible time and timeout connection. Or maybe a service in the same test, in web API or any other that does a Wait or anything simple, for a time that forces to give timeout. But this is a difficult scenario to test with Unit test, because it depends on the environment. I had a situation, but not in services, with Android, where we kept a wi-fi connection on, but we took the network cable from the server to simulate connection timeout. A little grotesque but functional.

3

Well, answering the list:

  1. The system has to be atomic, i.e., it must be transacted to maintain data integrity.

  2. To simulate, simply change the hosts of the machine to an invalid ip and set a timeout in the transaction (mentioned in item 1)

  3. I don’t know exactly how the system and its architecture is, depending on what this data load can be obtained using Jmeter as a client.

  • 1

    I didn’t feel like your second item. For an invalid/inaccessible host it is not simulating slowness, but simulating server loss (it is no longer reachable); it would be more like problem 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.