Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:25:12+00:00 2026-05-24T20:25:12+00:00

I have a web application written using Java servlets. I am using Tomcat 7

  • 0

I have a web application written using Java servlets. I am using Tomcat 7 as my servlet engine, but have used Glassfish previously and had the exact same issue.

The page in question has a “statistics” section that is updated every 5 minutes. The statistics take about 30 seconds to generate due to the size of the MySQL tables involved.

When I get a page load, I show the cached statistics. After everything in the page has been rendered, I flush and then close the output stream. I then update the statistics. This way, no user has to ever wait ~30 seconds for the page to load and the statistics update after the page has already been completely sent.

The problem is that if I refresh the page while it’s running the query, the page doesn’t load until the query has completed, which means that although the initial user doesn’t have any delay, after that there is a long delay.

Why is the application effectively stalling? Shouldn’t Tomcat be able to use another worker thread to handle the request, even though one thread is still busy?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:25:13+00:00Added an answer on May 24, 2026 at 8:25 pm

    What might be happening is your data is being “locked for update” while the update is taking place – it depends on exactly how the data is being recalculated.

    A good way to work around this is to make the new calculation into a separate data area, then switch over to using the new data after it’s all done. One way to implement this is using a database view and a version number, like this:

    create table my_statistics (
      id int not null primary key auto_increment,
      version int not null,
      -- other columns with your data
    );
    
    create table stats_version (current_version int); -- holds just one row
    
    create view stats as
    select * 
    from stats_version v
    join my_statistics s on s.version = v.current_version);
    

    Put your new stats into the table with a version number of current_version + 1. After all calculations have been made. Then a simple update stats_version set current_version = current_version + 1 will switch to using the new data. This last statement takes just milliseconds to execute, so locking waits are tiny.

    After switching, you can delete the old stats to save space.

    Using the “switch” approach makes the update and “atomic update” – the update happens “instantly and completely”, so users don’t see a partially changed dataset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web application written in java using Eclipse. It has just one servlet
I have a simple web application written in java which has servlets accessing the
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321
I have a web application, written in ColdFusion, which periodically starts using 100% of
I'm working on a web application written in Java using the Tapestry 5.1.0.5 framework.
I have existing Java application that is using Acegi for authentication/authorization. Our new web
I have a web application written in C# that consumes several internal web services.
I need a little help on this subject. I have a Web application written
I have a web application that was originally written on .Net 1.1 Framework. I
I have inherited a poorly written web application that seems to have errors when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.