Tony
Tony

Reputation: 3805

Perfomance in Spring MVC app

I've got an app that adds file's content row by row into data base. If file is not so big (smaller, than 100 kB) it will work well, but I can not say the same about big files. I found out that INSERT query takes about 1 msc, so 50k INSERT takes 50 sec. I find it very slow. This is my plan:

So, every user will run new thread, if file is big. I mean that I can not use one instance of this thread, every user will run new. Is it a good idea or not? How would you do?

Upvotes: 2

Views: 62

Answers (1)

udalmik
udalmik

Reputation: 7988

Two points:

  • Why don't you use batch updates? I mean doing several inserts to database at one time. Network round trip costs a lot of time, you can increase the performance significantly.
  • Performing update asynchronously is a good idea. But actually it doesn't mean that you need to create new thread per user. It can be a fixed pool of threads (let's say 5) to do the job for all the users.

Upvotes: 3

Related Questions