2 Replies Latest reply on Apr 3, 2007 1:35 PM by Dr. Screeny

    Cache startup problem on highloaded web application

    Dr. Screeny Newbie

      Hi !

      I'm developing a web application (servlet) for high number of users 20-30 request per second. I implemented Jboss cache (1.4.1sp2) it works fine with small number of users but when I try to loadtest my application I have performance problems at startup.
      My main servlet which generates dynamic content try to retrive the requested content from the cache. If it isn't exist generate it from database tables and before send it to the user store it in the cache.
      The problem is that when I try to test my application from 20-30 thread first time every thread try to generate and store the same content in the cache because cache is empty after the start. This generate very high load.
      I know there is cache loader but it isn't solve my problem because I need to refresh cache time to time and there will be the same problem.
      So, is there any idea? Maybe I should lock the cache until the first thread generate and store the content. How can stop other threads until the first lock the cache?

      Thanks for answers

        • 1. Re: Cache startup problem on highloaded web application
          Elias Ross Master


          If you're using a web application, I assume you're on two nodes. If you're using a cluster with replication, the replication should copy at startup and the new node shouldn't have load issues.

          • 2. Re: Cache startup problem on highloaded web application
            Dr. Screeny Newbie

            I'm on one node (one server, one jvm without clustering)

            My application flow is this:
            1. request to my servlet
            2. if content is in cache put it in response and send it to the client (end)
            3. if not cached generate content
            4. store generated content in cache
            5. put content in response and send it to the client (end)

            The problem is that with 20-30 request/sec (all request starts at same time or within 1 sec like a production system) every request skip 2. because the first time the cache is empty and goes to step 3. to generate content. Because step 3. is a relalatively slow process because of sql commands the 20-30 thread generate high load and can't serve requests.
            If I start one thread first and wait for the first response the next threads can use cached data and everything works fine, but it isn't a real case.