Dear Sir,
I am doing performance
testing of my stateless session
ejb which calls a VFSIOService class . This class writes the file to the hard disk. I am using JunitPerf as a performance testing tool. I am simulating 50 concurrent users thorugh my JunitPerf code .Each user is uploading the file of 3MB size. Following is the JunitPerfCode :
public class JunitPerformanceTest {
public static Test suite() {
long maxTimeInMillis = 60000;
int concurrentUsers = 50;
Test test = new VfsEjbPerformanceTest("testAddFile");
Test timedTest = new TimedTest(test, maxTimeInMillis);
Test loadTest = new LoadTest(timedTest, concurrentUsers);
return loadTest;
}
public static void main(
String args[]) {
junit.textui.TestRunner.run(suite());
}
}
Following is my addFile method in VFSIOService class which does the File wtiting to the hard disk and is called by VFSFacadeBean.
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
boolean flag = fileParentPath.mkdirs();
// if(log.isDebugEnabled())
//log.debug(flag+"");
}
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();
fileTO = null;
}
catch(IOException exception)
{
// deleting the destination file
if(file != null)
file.delete();
throw new VFSException(ExceptionMsg.VFS.FILE_CREATION_ERROR);
}
}
}
Now this method is called by my ejb VFSFacadeBean.
The problem is that when I try to upload files of 50 users with each file size 3MB the websphere server becomes slow and the time taken to upload the file of every user goes very high (on average 12 to 15 min for each user).
When I try to upload file of a single user with file size 3 MB the time taken is 2 secs. Is there any setting for stateless session bean which has to be done in WebSphere . And why is my response time increasing for 50 users.My machine configuration are 512MB Ram and CPU P4 1.6GHZ