I want to create a Thread Group in jmeter to create users and their devices with many (for example 5000) devices.
I have no problem to create this test and I want to have the name of the users and device in a correlative order.
1. user1--device1
2. user2--device2
3. user3--device3
I already created the test but to create 5000 users and devices in the same Thread Group I need to run 5000 iterations with 3 requests each, using 1 thread, because otherwise I have the same user name repeated by multiple threads (for example with 3 threads)
1. user1--device1
2. user2--device2
3. user3--device3
4. user1--device1
5. user2--device2
6. user3--device3
7. user1--device1
8. user2--device2
9. user3--device3
My question is: is there any way to share the loop counter between threads in order to create 5000 users/devices with more than one thread (for example 20 threads).
This will help me a lot because instead of waiting for 20 minutes, it will be a minute to create the users.
Many thanks!
http://pastebin.com/S1izFC9r
Added explanation I want for example maximun 9 devices (counter_max) but I want to run it with 3 threads. I want the result be like that
thread1--user1-device1
thread2--user2--device2
thread3--user3--device3
thread1--user4--device4
thread2--user5--device5
thread3--user6--device6
thread1--user7--device7
thread2--user8--device8
thread3--user9--device9
I think you can implement it using __counter() function in "global" mode, like: ${__counter(FALSE,)}
__counter() function returns incremented value each time it's being called
in the "global" mode counter value is shared across threads
So you should be able to use as many threads as required and each thread will use the next counter value to create your users and devices with multiple threads.
See How to Use a Counter in a JMeter Test article for comprehensive information on using "counter" config element and function.
Related
executor.setCorePoolSize(5);
executor.setMaxPoolSize(5);
I have a UI app and backend in Spring. One method takes 15 sec to execute. I am trying to handle it via spring-boot asyn..but setting this as 5 restrict UI users for that functionality to 5?
when we set it..is it for one instance? or for all the instance...say for example this code runs then only 5 threads will be there...say 10 users login to that app..threads are 5..do it means for next 5 users UI will not be accessible..
core pool size - sets how many threads can run parallelly which means 5 users can access simultaneously. If more hits occur then it is stored in queue which is configured by setting max pool size
So, according to your configuration after 5 users the next five user requests will be in queue. After the queue is full all requests will be rejected.
Say if one request completes from the first five then one request out of the five in queue will start and so on.
Refer this for Threadpool reading in respect to spring-boot https://www.baeldung.com/thread-pool-java-and-guava
I have 2 threads, one to take Orders and the other one to distribute the orders.
My first thread must be able to get the orders gradually one by one from a file and display it in a JTextArea-1, while this is happening the other thread should be able to remove one order at a time from JTextArea-1 and paste it to another JTextArea-2.
I have created 2 threads and used MVC pattern (with 2 views and 1 model). The Threads are both displaying the values in the JTEXTAREA's at the same time which is not acceptable. How can i solve this issue?
I should have a minimum 5 seconds delay between the removing from JTextArea-1 and pasting into JTextArea-2. kindly help.
Fundamental lack of comprehension of concurrency alert!
This is not the appropriate way to deal with your problem, which probably doesn't even need threads in the first place.
But if you insist on using threads, what you want is a semaphore to block one thread until a condition for the other thread to act exists. A "FIFO blocking queue" would be appropriate here as well.
Using pauses and timing with concurrency is not effective as it is a non-deterministic system, and only lead to even more subtle failure scenarios.
You could simply just add a synchronized call that logs the text so that only 1 thread can perform that at one time.
I have a Java EE web application. Now when a particular request comes (say /xyz url patter) I want to do complex procesing as follows
Each of the following 3 steps are very complex and takes time.
Get data from one table from DB.Table has huge data and querying takes time.
Make a web service call to some other webserive A and get its data.
Make another web service call to some otheer webserice B and get its data .
Do some processing by using output of 1, 2, 3
1, 2, and 3 are independent of each other so can be called in parallel.
Now the questions are:
Can I do operations 1, 2, and 3 in three separate threads?
Is it advisable to create 3 threads for each request?
Should I use thread pooling?
To address your first question I go through the 4 steps:
Yes, if the database driver you are using allows concurrent access, respectively is safe to use from different threads.
A web service is normally designed to deal with different requests at the same time so this should work as well, the question here is how many threads you want to use (and how long it takes to process one request) and whether the web service will guard itself against too many requests at once.
The same applies here.
Yes, but you have to do synchronization here, as in: wait until all threads have received their results. You can realize this with a java.util.concurrent.CyclicBarrier
Second question
That depends on your data and especially how fast the web services will answer, you should try it out.
Third question Definitively, that's what they are for. This will also help you to structure your application.
1) Can i do operations 1 ,2 and 3 in three separate threads?
Yes, you can.
2) Is it advisable to create 3 threads for each request?
As long as these things don't depend on each other, and as long as you're not depending on getting these in the same transaction, then it seems like it should be ok. You will have to handle the case where one or more threads don't succeed, of course. You'll need a separate watchdog thread to cancel the threads if they take too long or if one comes back with a failure.
3) Should I use thread pooling?
Regardless of what else you do, whenever you use threads you should use a pool. That way if there's a problem where threads don't complete or go into some bad state or otherwise become unavailable, you protect your application from running out of threads.
I have a scenario in which I have to register a number of users and than run parallel with threads as the number of registered users and execute same set of actions by all the users in parallel. for this I have a jmx with few actions that should happened only once (in a setup thread with one thread count) and another thread group that runs with say 5 threads which is the number of the previously registered users, and I execute some operations using these users.
Now I want execute this whole scenario in parallel using 5 threads.
How do I come about doing this?
I used the include controller but thread groups are not executed as expected, I don't get 25 iterations for the actions that happen in a 5 threads group in the included jmx.
I'm not precisely sure what you're doing, and I know little of jmx, but here's a couple of ideas. One (or both) might be relevant.
The first one is that your threads might be sharing an instance field. If they have a common counter, for instance, you will do something 5 times rather than 25 times. Make sure your common variables (instance and class fields) are properly synchronized. Use local variables whenever possible. You must use them when their value applies to each thread rather than all threads.
The second is that you might be displaying results--or event stopping the program--before all threads have done their work. It's worst on single-core machines, but threads can and do run in any order imaginable, and in a few orders that are not. They can run one at a time, with the one started last running first. One can stop in the middle, and let all the other run to completion, then start up again. A bunch can run simultaneously (on different cores or swapping rapidly) while others do nothing.
I'd suggest putting in a bunch of logging/output statements (System.out.println is good enough) and seeing for yourself what's happening. It'll take you a while to make sense of your output, but once you do, you'll be able to start bringing things under control.
I want to run some kind of Thread continuously in app engine. What the thread does is
checks a hashmap and updates entries as per some business continuously.
My hashmap is a public memeber variable of class X. And X is a singleton class.
Now I know that appengine do not support Thread and it has somethinking called backend.
Now my question is: If I run backend continiously for 24*7 will I be charged?
There is no heavy processing in backend. It just updates a hashmap based on some condition.
Can I apply some trick so that am not charged? My webapp is not for commercial use and is for fun.
Yes, backends are billed per hour. It does not matter how much they are used: https://developers.google.com/appengine/docs/billing#Billable_Resource_Unit_Costs
Do you need this calculation to happen immediatelly? You could run a cron job, say ever 5 min and perform the task.
Or you can too enqueue a 10 minutes task and re-enqueue when is near to arrive to its 10 minutes limit time. For that you can use the task parameters to pass the state of the process to the next task or also you can use datastore.