[opencms-dev] I have modify some caching
Kosol Tuanveeradej
kosol.t at g-able.com
Fri Mar 11 06:18:09 CET 2005
Dear all
I have some performace test and some modify code in method
readFileHeader in org/opencms/db/generic/CmsVfsDriver.java to tell you
all . If it make advantage or disavantage please suggest me.
Testing Environment
- oracle8.16 p3 1.6 GHz. Ram 512 Mb.
- IIS webserve jk2 rediract to tomcat5 and Opencms6 a2 on p4 2.0 GHz
Ram 512 Mb.
First test.
opencms no static export no caching.
I use concurrent user 300 send request pages to webserver.
- Average response time about 70- more 100 secs perpage
Second test.
I have export all website to static on webserver.
I use concurrent user 300 send request to webserver.
- Average response time about 0.2 secs perpage (Verry good).
Third test
I have modify some code in org/opencms/db/generic/CmsVfsDriver.java,
method readFileHeader.
I have to do this because on production architecture I have two
webservers running under loadbalancer, on webserver i remove login
module from opencms, and have a application server for edit contents at
backend.
Other problem.
- exporting website use alot of time (lage website).
- when exporting web DB process will peak to 100% customer cannot access
DB on that time (have another program use DB too).
- I cannot export all website as i wish and server reside in customer's
datacenter, that i cannot walk in easily (sync two webservers by copy
static export).
-Thanks for Caching code form http://www.vipan.com/htdocs/cachehelp.html
(Vipan Singla) for testing, Thanks you.
Tesing result
- Average response time about 7 secs perpage at 500 concurrent users
(good enough compare with first test).
Then i send the modified code for yous all comments!!
and Thank you advance for your comment!
My english may not good.
Kosol Tuanveeradej
/**
* @see
org.opencms.db.I_CmsVfsDriver#readFileHeader(I_CmsRuntimeInfo, int,
java.lang.String, boolean)
*/
public CmsFile readFileHeader(I_CmsRuntimeInfo runtimeInfo, int
projectId, String path, boolean includeDeleted) throws CmsException {
CmsFile fileHead = null;
ResultSet res = null;
PreparedStatement stmt = null;
Connection conn = null;
String fileHead_Key = null;
/** tar add caching for this readFileHeader by
* check if file exist in fileCache get file from cache
* else read from database and put it into fileCache.
* return file
* read form database is original part of this readFileHeader.
*/
fileHead_Key = path +" [fileHead]";
if(projectId == 1){
fileHead = (CmsFile)cache.get(fileHead_Key);
}
if(fileHead == null){
// must remove trailing slash
path = removeTrailingSeparator(path);
try {
conn = m_sqlManager.getConnection(runtimeInfo);
stmt = m_sqlManager.getPreparedStatement(conn,
projectId, "C_RESOURCES_READ");
stmt.setString(1, path);
res = stmt.executeQuery();
if (res.next()) {
fileHead = createFile(res, projectId, false);
while (res.next()) {
// do nothing only move through all rows because
of mssql odbc driver
}
// check if this resource is marked as deleted
if ((fileHead.getState() ==
I_CmsConstants.C_STATE_DELETED) && !includeDeleted) {
throw new CmsException("[" +
this.getClass().getName() + ".readFileHeader/3] " + fileHead.getName(),
CmsException.C_RESOURCE_DELETED);
}
} else {
throw new CmsVfsResourceNotFoundException("[" +
this.getClass().getName() + ".readFileHeader/3] " + path);
}
} catch (SQLException e) {
throw m_sqlManager.getCmsException(this, null,
CmsException.C_SQL_ERROR, e, false);
} catch (CmsException ex) {
throw ex;
} catch (Exception exc) {
throw m_sqlManager.getCmsException(this, null,
CmsException.C_UNKNOWN_EXCEPTION, exc, false);
} finally {
m_sqlManager.closeAll(runtimeInfo, conn, stmt, res);
}
// file never exist in fileCache then put it in fileCache. :tar
if (projectId == 1){
cache.admit(fileHead_Key,fileHead);
}
}
return fileHead;
}
More information about the opencms-dev
mailing list