Sunday 15 June 2014

java - Spring @Async saving searches -


There is a search input field on my java spring website where users can search for website content. I want to save asynchronous queries for users of my MySQL database for full functionality. I know that I can use @Sync annotation in Spring which specifies a pool-size with the following:

  & lt; Function: annotation-driven executor = "executable" /> & Lt; Function: Executable ID = "Exporter" pool-size = "100" />   

Question:

  • Is this a good solution for a high traffic website, more than 10,000 searches per minute ? Considering the possibility of pool exhaustion being an exception?
  • Is there a better solution?

    Take a look at this when all the threads in the pool are busy The job will be queued until only one thread is available. The maximum queue capacity and number of threads can be adjusted through the queueCapacity / maxPoolSize property (for queueCapacity default INTEGER.MAX_VALUE).

    One thing that you should be worried about is memory exhaustion. If you have fixed your queue capacity too much and your job runs for a long time, then all the jobs are ticking in the line of food in memory. May be.

    Also consider denying service, a hacker can attack by filling all the queue (hence running, rejecting the real user's job);

    Then I would say It has a good attitude in your sense, your controller will not have to wait until it is done, even though how much memory each line of work takes, how much memory space you have, how long it will be Sector will run.

    Good way is just best - guess some value, and setup Good thread pool / queue monitor / stats and adjust it over time.

No comments:

Post a Comment