JMeter Load Testing C# Rest APIs - Huge sample times - c#

I'm getting unusual issues when load testing my C# Rest APIs using JMeter Tool.
My API does a few database calls, it selects some data from one table, and returns it and manipulates it and inserts it into other tables.
If I run this API call on one instance, it executes in less than 3 seconds.
1 user, no ramp up = < 3 seconds
However, when running this same API call on 50 users on a 10 second ramp up time then I get the following results:
50 users, 10 second ramp-up period = increased sample time.
Am I configuring JMeter incorrectly, or is something wrong within my API call which is causing this?

Related

Azure pipeline concurrent (not parallel) tests execution for xunit tests

I am using azure pipeline to execute API tests, the tests are executed serially and I have hit the point where my job runs for over 1 hour - this means agent fails because 1 hour is the maximum job execution time. I have started to read how to execute tests in parallel, and in xunit tests should run in parallel by default when they are not in the same collection. In azure however, following https://learn.microsoft.com/en-us/azure/devops/pipelines/test/parallel-testing-vstest?view=azure-devops, to run tests parallelly it is required to use more than one agent and apparently more than 1 job. There are two cons in my case:
we have limited amount of agents and other people want to use them too, I do not want to occupy more agents than necessary;
I need to configure two firewall for cosmosdb for each job (1 job = 1 agent and each agent has new ip i need to add to firewall), this tasks takes 8 minutes and i need to configure 2 databases (16 minutes), each new job would mean i need to speend additional 16 minutes configuring firewalls.
So my question is - is it possible to run tests concurrent rather than parallel by utilizing same core? I have many thread.sleeps (but in my opinion i use them the correct way as i wait for some result for some time like 60 seconds, but i thread sleep for 2 seconds and every 2 seconds i'm polling in example databse if results are there) - thread.sleep means thread is sleeping and core should be available for other threads to run.
Apparently I have posted question too soon, found out that all I need to do is to set [assembly: CollectionBehavior(MaxParallelThreads = n)] to number I want (source: https://xunit.net/docs/running-tests-in-parallel). Default is number of logical processor and in case of azure agents this number is equal to 1.

How can i delete a large number of records in Salesforce using Apex code?

I have over 5000 Account records in Salesforce that need to be deleted.
I am currently using the following in my c# code
SalesForceEnterpriseService.DeleteResult[] delResult = _service.delete(ids);
and ids is a string array defined as follows: string[] ids.
When the above code runs , it gives an error: EXCEEDED_ID_LIMIT: delete id limit reached: 200.
Is there a way i can delete these 5000 records calling my service from within c# ?
Building Apex REST (or SOAP) service just for this sounds like overkill, the overhead of writing unit test, deploying... not worth it.
From C# - can you call that delete in a loop, 200 records at a time? It'll be bit more network traffic but should be straightforward.
From Apex - do you know how to run "execute anonymous"? delete [SELECT Id FROM Account WHERE Id IN ('001...', '001...'); should be good start, add LIMIT 1000 if the operation times out.
If you routinely need to process large amounts of data - consider using Bulk API. But it's REST (your thing looks like it uses SOAP) and it works bit different. You submit a job (csv/xml/json), start it and periodically poll "is it done yet". Whereas your SOAP call just takes that 200 and waits till server returns (synchronous vs asynchronous)
Check https://trailhead.salesforce.com/content/learn/modules/api_basics/api_basics_bulk and https://trailhead.salesforce.com/content/learn/modules/large-data-volumes/load-your-data if you're curious.

How to throttle webservice calls in a C# windows application

My application needs to call a WebService method to upload some xml.
The provider of this WebService has a restriction that my application cannot make more than 900 calls within a minute else it would be banned.
What kind of logic do I implement in my C# program which uses this webmethod to take care that more than 900 calls are not done in a minute.
Please note that I am not using WCF but simple httpwebrequest in my application.
Thanks in advance.
Keep a fixed sized queue of 900 elements. Push the timestamp in there for every call.
Before a pushing (every call), check the timestamp on the bottom end. If less than 1 min, do it. If more, fail or wait until it get to 1 minute

How to calculate social share count efficiently using C#

I am working on classified ads web application using asp.net Mvc-3 C#.
Every ad can share on social media like facebook,twitter,google plus ,linkedin.
I am calculating how many times ad is share on these website and saving this record in database.
Using this function
string jsonString = new System.Net.WebClient().DownloadString(URL-of-ad);
var serialize= new System.Web.Script.Serialization.JavaScriptSerializer();
var dictionary = serialize.Deserialize<Dictionary<string, string>>(jsonString);
var twitter = dict["count"];
var facebook= dict["share_count"];
// calculating for other website by this function
This is function is working fine but very time consuming for every ad .I have thousand of ads so i have to loop through thousand time and call this function for every ad.
I am calling this function twice in a day.
There is any other better and fast way to do this task?
Please give your suggestions.
You may think of improving your design
1 - Create a Windows Service and set it to run twice a day , most probably figure out when the traffic on your site is very minimal.
2- Move the Sharing count logic into windows service which will do it in another process and free up your main application.
3- Downloading something which is dependent upon the network speed so make yopur downloading Asynchronous rather than synchronous.
A few suggestions:
Run this in parallel, such as using Parrallel.ForEach, passing in the URL of the add, or an async version, such as DownloadStringAsync. Both will run multiple downloads at the same time.
Run this when the page is loaded that shows the add. Load the add then do a web service call to the server to get the count and share_count. It may be a bit more work but it will be more up to date and, if each add is shown rarely, this may be more efficient.
I assume you are not running this during page creation but, if you are, move it to a separate service or process as Saurabh suggests.

Webtest execution time much longer when in load test

I made a simple WebPerformanceTest in VS2012 which is just logging in and doing some basic jobs on the website. When ran, this test is only running for about a second or two.
Now, I made a load test, containing only this one webtest with a Constant load for 5 minutes and the mode is based on the number of virtual users. And here comes the funny part: No matter how much users I assign to this load test the number of tests executed is always the same as the number of users assigned. I also tried raising the load test execution time giving me the same result: one test = 5 minutes per user, whereas it only took the webtest about 1-2 seconds to execute.
Does anyone have any idea why the test is taking way longer (300 times) in the load test? What am I doing wrong here?
Edit: The machine is a Windows Server 2008 R2 with 4 cores # 3.00ghz and 8 GB RAM
Here's some images of the settings:
Notice the Run Duration: 5:00
You've set each test to run for five minutes. So basically it runs through the test then sits their idle for the rest of the time, closes the tests and then reports back to you that it took 5 minutes. You won't see any difference unless you change this setting or create a test that could take longer than 5 minutes to run.

Categories