4 Replies Latest reply: Oct 11, 2013 10:29 AM by tdsacilowski RSS

    Active Sessions

    tdsacilowski

      Before I begin, this thread is related to an older one I created some time ago. I didn't know if I should add to that one or start a new one...

       

      Just to recap, I had built a customer queueing application where some of the pages have the following functionality:

      1. An automatic report region refresh every 5 seconds
        • Dynamic Action refresh
        • Uses the Timer Plugin
      2. An AJAX function which calls an OnDemand process and refreshes an html region with a person's name every 5 seconds
        • Using the apex.server.process Javascript API
        • Also uses the Timer Plugin

       

      Below is the Javascript for #2 above:

      apex.server.process(
          'F_NEXT_STUDENT',
          { x01:  '&P401_WORKSTATION_IN.'},
          { type: 'GET',
            async: false,
            dataType: 'text',
            success: function(pData) { apex.jQuery('#next_student_div').html(pData); }
            /*,
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.status);
                alert(thrownError);
            }*/
      });
      
      

       

      All together there are about 20 machines that display a page that has one of the above 5 second refreshes. The application is also public; there is no authentication. From my understanding about how APEX handles sessions there is a max session length (8 hours in my case) even for public sessions. As a page is rendered, a hidden form variable is created called p_instance and the AJAX calls send this to the server to process the request within the active session. In theory, the application shouldn't be generating a lot of new sessions since once a page is loaded it is used simple to display an updating value. In other words, there's no user interaction. No page reloads, no new items being set in session state.

       

      However, I'm seeing A LOT of new sessions being generated. Looking at page 4350 (Active Sessions) within the, I'm seeing almost 90,000 sessions. I've had to turn off activity logging because it's generating way too many redo logs and such. I ran the following query on WWV_FLOW_SESSIONS$:

       

      select
          remote_addr,
          count(*)
      from
          APEX_040200.wwv_flow_sessions$
      where
          trunc(created_on) = trunc(sysdate)
      group by remote_addr
      order by 2 desc;
      
      

       

      with the following results:

       

      IP addressCount
      192.xxx.xxx.xxx17307
      192.xxx.xxx.xxx8756
      192.xxx.xxx.xxx4455
      192.xxx.xxx.xxx4436
      192.xxx.xxx.xxx4434
      192.xxx.xxx.xxx4368
      192.xxx.xxx.xxx3773
      192.xxx.xxx.xxx3764
      192.xxx.xxx.xxx3739
      192.xxx.xxx.xxx3734
      192.xxx.xxx.xxx3712
      192.xxx.xxx.xxx3705
      192.xxx.xxx.xxx3704
      192.xxx.xxx.xxx3701
      192.xxx.xxx.xxx3699
      192.xxx.xxx.xxx3692
      192.xxx.xxx.xxx3681
      192.xxx.xxx.xxx3668
      192.xxx.xxx.xxx3653
      192.xxx.xxx.xxx3652
      192.xxx.xxx.xxx3611
      192.xxx.xxx.xxx3148
      192.xxx.xxx.xxx101
      192.xxx.xxx.xxx3
      192.xxx.xxx.xxx3
      192.xxx.xxx.xxx2
      192.xxx.xxx.xxx2
      192.xxx.xxx.xxx2
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1
      192.xxx.xxx.xxx1

       

      Using firebug to examine the AJAX requests, it seems that it's using the same p_instance value each time the request is sent so I'm not sure if I'm reading the data correctly or not. I do, however, know that there is some sort of issue that keeps hanging up my Glassfish server:

      [#|2013-10-09T04:12:08.528-0400|WARNING|oracle-glassfish3.1.2|com.sun.grizzly.config.GrizzlyServiceListener|_ThreadID=11;_ThreadName=Thread-2;|GRIZZLY0023: Interrupting idle Thread: http-thread-pool-80(168).|#]

       

      [#|2013-10-09T04:12:08.528-0400|SEVERE|oracle-glassfish3.1.2|grizzly|_ThreadID=11;_ThreadName=Thread-2;|doSelect exception

      1. java.util.concurrent.RejectedExecutionException: The thread pool's task queue is full, limit: 4096

                      at com.sun.grizzly.util.AbstractThreadPool.onTaskQueueOverflow(AbstractThreadPool.java:473)

                      at com.sun.grizzly.util.SyncThreadPool.execute(SyncThreadPool.java:191)

                      at com.sun.grizzly.util.GrizzlyExecutorService.execute(GrizzlyExecutorService.java:162)

                      at com.sun.grizzly.http.StatsThreadPool.execute(StatsThreadPool.java:127)

                      at com.sun.grizzly.NIOContext.execute(NIOContext.java:510)

                      at com.sun.grizzly.NIOContext.execute(NIOContext.java:488)

                      at com.sun.grizzly.SelectorHandlerRunner.handleSelectedKey(SelectorHandlerRunner.java:370)

                      at com.sun.grizzly.SelectorHandlerRunner.handleSelectedKeys(SelectorHandlerRunner.java:263)

                      at com.sun.grizzly.SelectorHandlerRunner.doSelect(SelectorHandlerRunner.java:200)

                      at com.sun.grizzly.SelectorHandlerRunner.run(SelectorHandlerRunner.java:132)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                      at java.lang.Thread.run(Thread.java:662)

      |#]

      That first error (GrizzlyServiceListener) is showing up thousands of times and I have a feeling that it's related to these sessions somehow.

       

      Any ideas why I'm seeing so many active sessions?

        • 1. Re: Active Sessions
          Mike Kutz

          tdsacilowski wrote:

           

          All together there are about 20 machines that display a page that has one of the above 5 second refreshes. The application is also public; there is no authentication. From my understanding about how APEX handles sessions there is a max session length (8 hours in my case) even for public sessions. As a page is rendered, a hidden form variable is created called p_instance and the AJAX calls send this to the server to process the request within the active session. In theory, the application shouldn't be generating a lot of new sessions since once a page is loaded it is used simple to display an updating value. In other words, there's no user interaction. No page reloads, no new items being set in session state.

           

           

          no interaction, 24/7 uptime, refreshing every 5s, and it is all public.....

          I'd almost look at a slightly different architecture.

           

          option one:

          have a basic, static web page that calls an APEX REST service.

          This html file and any neccessary css, js files will reside on the same webserver as the APEX listener, but in a different WAR file.

           

          option two:

          make a simple java swing app using JDBC to connect directly to the database.

          use Oracle Wallet technology so you don't have to hardcode the name/password in plain text.

          have the DBA create an account with very limited access and a profile to guarantee it will never suck-up DB resources.

          *** IIRC -- the OCI version includes the capability of triggering an event (in Java) when a table gets update. ****

           

          APEX is a very good tool.

          But, for your case, it sounds like it is overkill for your requirements.

           

          MK

          • 2. Re: Active Sessions
            tdsacilowski

            Perhaps I wasn't clear in my description... The 20 machines I referred to are the only ones displaying pages with the 5-second auto refresh AJAX calls. There are other stations that users do interact with such as check-in kiosks and administration and reporting workstations. I merely pointed out the others since those are the ones creating all of these active sessions.

            • 3. Re: Active Sessions
              Mike Kutz

              I understand completely.  I was suggesting the different architecture for these these 20+ computers only.

              For the machines where people type stuff in... keep APEX.

               

              (side note:  use the /*+ CACHE */ hint for the SELECT statement that these machines use.)

               

              As far as your multiple sessions goes, it sounds like: every time a machine refreshes, a new session is created.

              I agree, I don't think that should happen.  (I'd get Oracle Support involved.)

              In the meantime, see if you can create a RESTful service that returns the same information, and modify your "now severing ____" page to use that service.

              (A modified version of my Option 1 above.)

              • 4. Re: Active Sessions
                tdsacilowski

                Sorry about my response... After re-reading your post I now see what you meant, and it makes sense. I was already thinking that maybe a RESTful service might make more sense for those specific pages and your post reaffirmed that I should look into it. As for all those active sessions, yes, it does seem odd. Hopefully Oracle Support can help.

                 

                I will try the above and report back with my updates.

                 

                Thanks!