Mixed Write for GSON - jmeter

I am using GSON object model access to construct JSON to be used as body of my POST webservice calls in Jmeter.
Now I frequently encounter : GCC Out of memory exception with the error pointing to the code section=> gson.toJson(objectToSerialize).
From the past posts, it was suggested to use gson serialization with the streaming access model.
My current code does this: Create an object of an class by populating its variables and passes this class on to the GSON serializer, gets back the constructed JSON in form of string and I use them.
Could the experts suggest, is there a way that I could integrate streaming access model into my code without having to do much of a rework. Would this be memory efficient?
PS: I took a look into Mixed writes example specified in this link but unable to get around how to construct a JSON by passing one object of the class as we do in the object model:
https://sites.google.com/site/gson/streaming
Thank you!

Why don't you just use these variables in "Body Data" mode of the HTTP Request sampler like:
If your JSON payload is large you may have to amend Java HEAP size as default allocation is just 512MB and it may be not enough for more or less large load. If you don't have enough free RAM to fit JSON data size * number of virtual users you may have to consider Distributed Testing
The other option may be you using not very efficient scripting test element. It is recommended to use JSR223 Test Elements and Groovy as a language as other options are not performing that well.
See Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! guide for more information on

Related

JMETER Performance Testing - Dynamic Payload

While doing performance testing via JMETER, I encountered one usecase where the POST request call is taking the dynamic data from the website. So in that case when we run our script it fails as that data is no more available on the website.
Payload looks like given below. It is a POST CALL and the payload is changing everytime.
{"marketId":"U-16662943","price":{"up":98,"down":100,"dec":"1.98"},"side":"HOME","line":0,"selectionids":["W2-1"]}
Could anyone suggest how we can make this payload dynamic when we create a script in JMETER?
I can think of 3 possible options:
Duplicate data is not allowed. If this is the case you can use JMeter Functions like __Random(), __RandomString(), __counter() and so on
The data you're sending needs to be aligned with the data in the application somehow, in this case you can use JDBC PreProcessor in order to build a proper request body basing on the data from the application under test database
The data is present in previous response. In that case it's a matter of simple correlation, the dynamic values should be extracted from the previous response using suitable Post-Processors and variables needs to be sent instead of hard-coded parameters

Best practices for FlowFile content vs FlowFile attributes

I'm just getting started with Apache NiFi and I'm curious if there are any best practices around using a attributes vs content for a FlowFile. Currently, I have it setup to read a JSON message from a RabbitMQ queue, parse the JSON into attributes and use those attributes for downstream processing. This works, but I feel like its leaving the content of the FlowFile largely unused after JSON parsing and I'm wondering if I'm missing something. Alot of the processors seem more geared towards working with attributes but are there any disadvantages to primarily using attributes for processing?
In my use case, the RabbitMQ message would be an event that a new document has been made available and the flow I'm building would have branching logic based on the document type to extract data from the document via NLP processes. Currently, I'm storing the document text as and attribute but I'm wondering if there are any size considerations to account for with attributes. Some documents could be hundreds of pages and therefore lots of text.
Thanks!

In nifi usgae of Evaluate jsonpath processor will it affect performance impact because of attribute creation

I'm trying to integrate nifi REST API's with my application. So by mapping input and output from my application, I am trying to call nifi REST api for flow creation. So, in my use case most of the times I will extract the JSON values and will apply expression languages.
So, for simplifying all the use-cases I am using evaluate JSONpath processor for fetching all attributes using jsonpath and apply expression language function on that in extract processor. Below is the flow diagram regarding that.
Is it the right approach because for JSON to JSON manipulation having 30 keys this is the simplest way, and as I am trying to integrate nifi REST API's with my application I cannot generate JOLT transformation logic dynamically based on the user mapping.
So, in this case, does the usage of evaluating JSONpath processor creates any performance issues for about 50 use case with different transformation logic because as I saw in documentation attribute usage creates performance(regarding memory) issues.
Your concern about having too many attributes in memory should not be an issue here; having 30 attributes per flowfile is higher than usual, but if these are all strings between 0 - ~100-200 characters, there should be minimal impact. If you start trying to extract KB worth of data from the flowfile content to the attributes on each flowfile, you will see increased heap usage, but the framework should still be able to handle this until you reach very high throughput (1000's of flowfiles per second on commodity hardware like a modern laptop).
You may want to investigate ReplaceTextWithMapping, as that processor can load from a definition file and handle many replace operations using a single processor.
It is usually a flow design "smell" to have multiple copies of the same flow process with different configuration values (with the occasional exception of database interaction). Rather, see if there is a way you can genericize the process and populate the relevant values for each flowfile using variable population (from the incoming flowfile attributes, the variable registry, environment variables, etc.).

Jmeter JMS point-to-point with dynamic messgae content

I am new to jmeter. I am trying to setup JMS point-to-point load test script. The request message is a fixed-length format. I need a way to read fields from csv and arrange them in fixed-length format. I tried using javascript slice function by using csv data config variables and slicing to required length, concating them all in one line. But it is not working. May be my approach is wrong. Any pointers on how to make it work with fixed length format will help.
This is what I tried:
${__javascript((" ".slice(-6))+(("0000000000000000"+${Var2}).slice(-16)) + ((" " + ${Var3}).slice(-19))+((" "+${Var4}).slice(-3))}
where Var1,Var2..Var4 are from csv.
Jmeter version:3.3
MQ: IBM Websphere MQ
With a single input message I am able to execute the test. I need to dynamically populate values from csv and/or date/time functions and arrange them in fixed-length format.
You have a typo in your code, the function should be __javaScript (mind the capital S
Your approach should work, however using JavaScript is extremely inefficient as each time you call __javaScript() function JMeter invokes Rhino or Nashorn interpreter and this may ruin your test in case of high loads. Since JMeter 3.1 users are encouraged to use __groovy() function for scripting.
And last but not the least, in order to get the most performance I would recommend using __substring() function instead of your slice() function. You can install __substring() and other Custom JMeter Functions using JMeter Plugins Manager

what are most commonly used JMeter listeners

I am using JMeter for load testing and using listeners for getting the response results but I am not sure which are the most commonly used listeners which will give data for analysis.
I know Table view and tree view but those basic ones, kindly advice which listeners should I use.
JMeter documentation provides a very good overview of the listeners and when/how to use them.
While you are debugging and developing your plan, there's nothing better than View Results Tree, which also serves as a tester for RegEx, CSS/JQuery and XPath tester. However this particular listener must be disabled or deleted during the real load test, as it will eventually crash JMeter with OOM exception.
During the real load test you need to record statistics (how long requests took, etc.) and errors. In non-interactive mode, the best is to use Simple Data Writer with CSV format, which is considered to be very efficient. If you use interactive mode, or both (interactive and non-interactive modes), it's very convenient to use Aggregate Report or
Summary Report, since they display stats right away, and you can see immediately if something goes wrong. They also have ability to write to file, just like Simple Data Writer.
Finally, if you want to include some custom result collecting (not provided by any listeners), you can use BeanShell Listener or BSF Listener
In terms of organization, I find it convenient to separate successes and failures, so I always have 2 listeners:
For successes (in "Log/display only" option Successes is checked) I either record only statistics using Aggregate/Summary report (if test will run interactively and for a long time) or record file in CSV format (if I need a raw data about each request).
I always record failures (in "Log/display only" option Errors is checked) into file in XML format (for example using Simple Data Writer). XML format is not that efficient, but test is not supposed to have many failures (if it does, basically it should be stopped and analyzed). But XML format allows to record failing request and response headers and body, which is convenient for further debugging.
Hope this helps.
While executing the test better to avoid adding the listeners, only thing you can add simple data writer alone from that listeners you can generate any type listeners as you need.
while making the script ready you can use any type of listeners that will no be any issues.

Resources