• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ejb Performance testing tool

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
Which is the best tool for Ejb performance testing.
I have seen JunitPerf tool on internet but i dont know whether I should go for it.
Thanks & regards ,
Siddharth
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you really want to test? Do you want to test how long it takes for your EJB code to execute for a single call? Do you want to test how many simultaneous users your EJB container as a whole can accomodate? Something else?
You could take a look at black-box testing tools such as Mercury LoadRunner, WinRunner, Grinder, etc. Also, it is possible to exercise your system using tools such as JUnitPerf and HttpUnit in combination. The biggest differences come in the usability aspects (GUI versus writing Java code), and whether you want to verify or measure (JUnitPerf can only verify that the execution times stay below what's expected, it can't report average throughput, response times, CPU usage, etc.).
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
What do you really want to test? Do you want to test how long it takes for your EJB code to execute for a single call? Do you want to test how many simultaneous users your EJB container as a whole can accomodate? Something else?
You could take a look at black-box testing tools such as Mercury LoadRunner, WinRunner, Grinder, etc. Also, it is possible to exercise your system using tools such as JUnitPerf and HttpUnit in combination. The biggest differences come in the usability aspects (GUI versus writing Java code), and whether you want to verify or measure (JUnitPerf can only verify that the execution times stay below what's expected, it can't report average throughput, response times, CPU usage, etc.).


Dear Sir,
Actually i have written a ejb(stateless session ejb) which calls a class called VFIOService. This class is responsible for writing and reading files from hard disk .I want such a tool which will simulate number of users who will be writing and reading their files with this ejb . Also i want to check the performance of this implemented ejb which will be in terms of response times . Can u plzzz suggest me a good tool for this purpose.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you want to check that with a given number of simultaneous users, the EJB invocations execute within a given response time expectation? If that's the case, I think you should try JUnitPerf (or plain JUnit and write the threading/multi-user stuff yourself).
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
I have implemented JunitPerf in my project and I have started getting results. My stateless session ejb is using a class called VFSIOservice which writes 3 Mb byte array size to the hard disk.
With JunitPerf I have silmulated 10 users who will be uploading their data of 3mb each . each user is taking 10 secs to upload the file . Now how should i achieve the result so that i can achieve 3 to 4 secs for each user.My VfsIOService is just using BufferedOutputStream to write the file.
Now my ejb is on the remote machine .I have deployed my ejb on that machine and I run it from my machine through JunitPerf. The machine on which ejb was deployed was having 512 mb ram with websphere running and 1.4ghz CPU.
I just wanted to ask that because the remote machine was having this configuration and the memory was so less that is why the response time was so slow???. I cannot run the ejb on my machine locally though i have websphere because when i deployed the ejb on my server and tested it with JunitPerf ,my server became slow and the response time was some where between 5 to 6 secs
Can u plzz help in this matter.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What size of buffer are you using with your BufferedOutputStream? You could try increasing or decreasing that and see whether it makes a difference. If the bottleneck is your network interface, I'm afraid there's nothing much you can do...
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my bufferedoutputstream is of 1024 size. i tested it by increasing its size but still no major affect is seen. sir , if this java io api does not give proper performance then should i go for some external io api which are written in c or c++. my ejb will call this api.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, 3 megabytes in 10 seconds is 300 kilobytes per second, which is really not too bad and may very well be in the upper limit of your network connection (unless you're using localhost instead of a physically remote machine).
I doubt you can improve the performance much without dropping the EJB (which first reads the input parameter into memory, and only then starts writing it into the BufferedOutputStream, I assume?) and switching into a streaming connection.
You could see some performance benefits by using C++ but the difference would be most probably insignificant compared to what you can achieve with Java (using the same approach that you would use in your C++ implementation).
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
Actually my project architecture is as follows:
1 First there is a stateless session ejb called RFS which sends the file data in the form of byte array to the other stateless session ejb which is called as VFS.Now this VFS calls the VFSIOService (a normal class) for writing this byte array to the hard disk.
2 Now in my project I have to do the VFS module of which i have finished the coding part.The RFS module which is to be done by another programmer is not finished yet.Now i have been told to do the performance testing of this VFS.
3 Sir what is this streaming connection which u have metioned in ur previous reply.can u plzz clarify ....
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With a "streaming connection", I meant that you would start writing the file right after receiving the first bytes from the caller. In other words, use an InputStream and OutputStream instead of passing around byte arrays. However, it sounds like you don't have that choice so maybe you should just leave it as it is.
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
Thanks for ur previous replies.Sir , I had gone through the java.io source code and for BufferedInputStream it is specified that this stream by default specifies 2048 bytes.Sir can i override this method and provide more buffering.Can i apply the same for BufferedOutputStream
Following is the source code of VFSIOService class which does reading and writing:
public class VFSIOService {
/**
* This is the constant which holds the byte size
* which can be used while reading and writing.
*/
public static final int BYTE_SIZE = 1024;
/**
* This is the constant which represents start offset in the array
*/
public static final int START_OFFSET = 0;
/**
* This is the constuctor .
*/
public VFSIOService() {
}
/**
* This method writes the file to the hard disk.
* This method calls the security service if the vault type is secure
*
* @param FileTOThe File object contains file related details
* @return void
* @throws VFSException
*/
public void addFile(FileTO fileTO) throws VFSException
{

//create the file object from absolute path
File file = null;
File fileParentPath = null;
BufferedOutputStream bout = null;
file = new File(fileTO.getAbsolutePath());

//get the parent path of the file
fileParentPath = new File(file.getParent());

//check parent path exists
if (fileParentPath.exists() == false)
{
//create directories
fileParentPath.mkdirs();
}

try
{
// Check the vault type
if (fileTO.getVaultType() == StorageTypeConst.TYPE_SECURE)
{
//get the security facade home
SecurityFacadeHome securityServiceHome = (SecurityFacadeHome)
ServiceLocator.getHome(JNDIConst.JNDI_SECURITYFACADE_HOME,
SecurityFacadeHome.class);

//get the remote reference
SecurityFacade securityServiceremote = securityServiceHome.create();

// call the encode method
securityServiceremote.encode(fileTO);

}
else if (fileTO.getVaultType() ==
StorageTypeConst.TYPE_REGULAR)
{

// create buffered output stream to the file
bout = new BufferedOutputStream(new
FileOutputStream(file),BYTE_SIZE);

//write the bytes to the file
bout.write(fileTO.getFileBytes(),
START_OFFSET,fileTO.getFileBytes().length);

}
else
{
//delete the above created folder
fileParentPath.delete();

// throw exception for invalid valut type
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);

}
}
catch(ServiceLocatorException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
catch(SecurityException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
catch(CreateException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
catch(FileNotFoundException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
catch(IOException exception)
{
// deleting the destination file
if(file != null)
file.delete();

throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
finally
{
try{
if(bout != null)
bout.close();
}
catch(IOException exception)
{
// deleting the destination file
if(file != null)
file.delete();
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}

}

}

/**
* This method writes the file to the hard disk and it calls
* the security service if the vault type is secure. This method is used when
* the file has to be overwritten on the disk
*
* @param FileTOThe File object contains file related details
* @param originalFilePathThe path of existing file which is to be deleted
* @return void
* @throws VFSException
*/
public void addFile(FileTO fileTO, String originalFilePath)
throws VFSException
{
try{
// call the above addFile method
addFile(fileTO);

//Check the absolutePath and originalFilePath are not same
if(!fileTO.getAbsolutePath().trim().equals(originalFilePath.trim()))
{
if(deleteFile(originalFilePath) == false )
{
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
}
}
catch(VFSException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
}
/**
* This method deletes the original file from the hard disk.
*
* @param originalFilePathThe original file path which is to be deleted
* @return boolean
*/
private boolean deleteFile(String originalFilePath)
{
File file = new File(originalFilePath );

//returns true if delete is successful else false
return file.delete();
}
/**
* This method reads the file from the hard disk.
* This method calls the security service if the vault type is secure
*
* @param FileTOThe File object contains file related details
* @return FileTO
* @throws VFSException
*/
public FileTO downLoadFile(FileTO fileTO) throws VFSException
{
BufferedInputStream bis = null;
try
{
//create file object from absolute path
File file = new File(fileTO.getAbsolutePath());

// Check for file existence
if( !file.exists() )
{
throw new VFSException(ExceptionMsg.VFS.FILE_DOWNLOAD_ERROR);

}
else
{
// Check the vault type
if (fileTO.getVaultType() == StorageTypeConst.TYPE_SECURE)
{

//get the security facade home
SecurityFacadeHome securityServiceHome = (SecurityFacadeHome)
ServiceLocator.getHome(JNDIConst.JNDI_SECURITYFACADE_HOME,
SecurityFacadeHome.class);

//get the remote reference
SecurityFacade securityServiceRemote =
securityServiceHome.create();

fileTO = securityServiceRemote.decode(fileTO);

}
else if (fileTO.getVaultType() ==
StorageTypeConst.TYPE_REGULAR)
{
bis = null;

// create input and output stream
bis = new BufferedInputStream(new
FileInputStream(file));
// create the byte array of file length
byte fileBytes[] = new byte[(int)file.length()];

// read the file and copy its contents into array
bis.read(fileBytes,START_OFFSET,fileBytes.length);

// set the file bytes read to fileTO file bytes
fileTO.setFileBytes(fileBytes);

}
else
{
// throw exception if vault type is invalid
throw new VFSException(ExceptionMsg.VFS.INVALID_VAULT_TYPE);

}

}//end of else

return fileTO;
}
catch(SecurityException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_DOWNLOAD_ERROR);
}
catch(ServiceLocatorException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_DOWNLOAD_ERROR);
}
catch(FileNotFoundException exception)
{
throw new VFSException(ExceptionMsg.VFS.FILE_DOWNLOAD_ERROR);
}
catch(IOException exception){

throw new VFSException(ExceptionMsg.
VFS.FILE_DOWNLOAD_ERROR);
}
catch(CreateException exception)
{
throw new VFSException(ExceptionMsg.
VFS.FILE_DOWNLOAD_ERROR);
}
finally
{
try{

if(bis != null)
bis.close();

}catch(IOException exception){

throw new VFSException(ExceptionMsg
.VFS.FILE_DOWNLOAD_ERROR);
}
}

}

}
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
the above source code has two methods.The method addFile does the file writing. and downLoadFile reads the file from hard disk. The FilTO class will have fileBytes member variable which are to be written to the file.
Thanks & regards,
Siddharth K
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, I believe the only way to improve the performance is to start doing the work earlier (using Input/OutputStreams instead of byte[] and File). I'll move this discussion into the performance forum. Maybe you could get more advice there.
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
Do u mean to say that instead of passing byte array my stateless session ejb should receive outputstream object which will hold the bytes.
And this outputstream object should be created by the caller.
Siddharth k
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The parameters for remote EJB calls need to be serializable so you can't pass an InputStream unless you use a local interface for the second (VFS?) EJB. Then again, if you use a local interface there's no need anymore to use an InputStream because the byte[] will not be copied (pass-by-reference instead of pass-by-value).
In other words, leave it as it is. The InputStream would be helpful in a case where both EJBs would be local and the client could pass in a FileInputStream etc. In that case, the data would not be duplicated anywhere but instead a reference to the FileInputStream would be passed from one class to another.
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear sir,
thanks for ur advice. Sir i am doing the performance testing of my VFS ejb and I have written the test code with JunitPerf. My JunitPerf test program simulates 20 users. When i test my VFS ejb locally the ejb takes lot of time to respond . I think cpu is taking time for creating 20 threads which is why there is delay in the response time. How should i test my ejb. I mean should i test it remotely . I had done this before and the response time is much better than testing it locally because i think my ejb is executing on a remote machine and the threads for those 20 users are created on some other machine. Sir the basic question is how should i test my ejb with JunitPerf. Plz help
Thanks,
Siddharth K
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sid - please take a moment to read our display name policy and edit your display name to something which looks like a real name. "Sid Kirad" or "Siddarth Kirad" would be fine, but "SidFrompune" (Sid from Pune) is not - it's obviously fictitious. Thanks.
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim
Nice catch! But how did you do that?
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any book for EJB performance tuning?
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go to http://www.javaperformancetuning.com for a list of performance books and tools including my own at http://www.jamonapi.com
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by SidFrompune Kirad:
1 First there is a stateless session ejb called RFS which sends the file data in the form of byte array to the other stateless session ejb which is called as VFS.Now this VFS calls the VFSIOService (a normal class) for writing this byte array to the hard disk.


So the SLSB RFS sends the byte array (in the FileTO) to another SLSB called VFS. Does this call use the remote interface? If so you'll be serializing and deserializing the entire byte array for that call. If these beans are in the same container, consider using the local interface to avoid this unnecessary overhead.
Also, make sure you're measuring exactly what you want. If your JUnitPerf test involves connecting to the VFS bean from a client and sending it a byte array, then you're also testing the time it takes to send the byte array over your network -- something that won't be happening in the real system (from my understanding and assuming same container for the RFS/VFS beans). If that's the case, the actual performance will be better than your measurements.
 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,
We are using EJB1.1 in our project though RFS and VFS are in the same container. Sir I am performing the testing with JunitPerf on the same machine. The JunitPerf test code is running on the same machine where EJB is installed. Sir, plzz let me know, if by changing the Ejb from 1.1 to 2.0 this will improve performance. Sir when i test the ejb locally with JunitPerf does the remote call in Ejb1.1 harms the performance
Thanks & regards,
Siddharth K
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes using EJB 1.1 will harm performance because you are not able to use local interfaces (thus, you have to rely on pass-by-value semantics which causes the byte[] to be copied for each call instead of just passing a reference to the existing byte[]).
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some EJB 1.1 conatiners allow pass by reference semantics, this fetaure is proprietary.
 
reply
    Bookmark Topic Watch Topic
  • New Topic