Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

12 users concurrents with 50 transactions each one.  RSS feed

 
Paco Martin Duque
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have developed a simple project to test the performance for a query on mySQL that always returns 1000 records ( but it may be differents).
I have to show the 1000 ones in a web page.

I use the following architecture:

A simple servlet (GetEmployeeServlet) that calls to a Java Manager (ActionManager) that does the connection on the mysql database and gathers the 1000 records --> The servlet get a ArrayList from the Action Manager method and writes on the page the results.

I get to down tomcat when the 12 users is running because tomcat log shows the message "out of memory" after 20 minutes.

Before I increase the memory, I'm going to improve the architecture.

I am thinking to prepare a component with a database connection cache to avoid to spend time on it and a DAO that centralizes the database logic.

After that I am thinking to change the simple servlet for the SPRING technology and change the DAO for HIBERNATE technology.

What's your opinions?
What do you think it is the architecture with more performance for this case?

Thanks in advance.
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really should profile your application to see what's using up all the memory. Without hard data you are just shooting in the dark.
That said, make sure you are closing your result sets, statements and database connections when you are done with them and make sure you aren't holding on to more data than you need to create a page.
You should be aware that Tomcat has a built-in database connection pool.
[ October 01, 2008: Message edited by: Joe Ess ]
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, I'd consider whether you really need to return 1000 rows per user. If you're dumping them all in a single web page, people probably aren't reading all those rows anyway. My eyes usually begin to water after the first hundred or so.

Spring/Hibernate or one of the other ORM technologies MAY help. It depends. Most of the good implementations have a data cache. If substantially the same data is being displayed for all users, they can get it from the cache. If, however, each user is viewing different data, caching's not such a big help, and can actually hurt, since there's overhead for the caching mechanism.

Another possibility may lie in your DBMS. When you're doing a paged web display, for example, like showing 25 records per page, it's often the case that rather than loading the entire 1000 rows into memory, you make the 1000-row request but only read in the 25 you're actually going to display, then make another request when the user selects another page. If you use Prepared Statements and a smart enough DBMS, the DBMS will keep enough context from the last page request that it can serve up the next one without having to do the whole query from scratch. I don't know offhand if MySQL presently does that or not, however.

By the way, what Joe's referring to is the Connection pool, which is actually a pluggable component for Tomcat (the default one is the Apache DBCP pooler). The caching mechanism is a record pool. It's almost always a good idea to use a connection pool. As I said earlier, whether record caching/pooling will help depends on how the system is being used.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!