• REST Service - performance issue..

    By Petter Kjeilen 1 decade ago

    Hi !

    I'm using the REST Service control in an XPage (XAgent) and I experience slow performance..

    Code:


        xmlns:xe="http://www.ibm.com/xsp/coreex">

        
            
                                 count="3000">
                    
                

            

        

    The XAgent is called using : http:////xRestService.xsp/Read?view=lookupREST

    Server is Domino 8.5.3 with UP1
    The view (lookupREST) is FTIndexed and has 15 non-computed columns.
    I've experimented with setting the count (number of returned rows).

    Setting count = 10, data is returned in 60ms (average from 20 requests)
    Setting count = 100, data is returned in 2s (average from 20 requests) (!)
    Setting count = 1000, data is returned in 2s (average from 20 requests)
    Setting count = 3000, data is returned in 5.5s (average from 20 requests) (!)

    Result: returning 10 is fast, 100 is very slow, 1000 is slow, 3000 is very slow..

    I was hoping it was faster. Should I expect faster response than this ?
    I've testet the overall server http performance with other xpages, forms, pages etc, and I find it good.

    I've also tested with using the viewJsonService. I find it slower. Using 3000 as count averages to about 10 seconds.

    So, questions is should I expect faster reponse times than this ? What could be possible cause(s) for this slow performance ?
    Or is this performing as expected ?

    Any information/ tips would be greatly appreciated Smile

    Regards,
    Petter Kjeilen

    • Some answers ...

      By Dave Delay 1 decade ago

      I just spent some time investigating this.  I'm using different data (the AllContacts view in XPagesExt.nsf), but my results are similar to yours.  In particular:

      • viewItemFileService is marginally faster than viewJsonService
      • viewItemFileService returns 10 entries in a fraction of a second
      • viewItemFileService returns 1000 entries in about two seconds

       

      I didn't notice a spike in the response time for 100 entries.  In fact, the relationship between the number of entries requested and response time was roughly linear.  (I also averaged results over 20 attempts.)
       

      Is this performing as expected?  Well, when you ask for 1000 entries, we have to load each one into memory and convert it to JSON.  This takes time.  We might be able to make this faster in the future, but frankly I would be more concerned if the results  were not linear.
       

      In short, I don't think there is anything you can do to improve the performance.  I would recommend you think about the effect of concurrent requests.  If you have hundreds of concurrent requests each asking for thousands of entries, the server could become memory bound and slow down significantly.  It's probably a good idea to get no more than a few hundred entries per request.
       

      Regards,
       

      -- Dave Delay

      • RE: Some answers...

        By Petter Kjeilen 1 decade ago

        Hi Dave,

        Thanks a lot for your feedback and your testing Smile

        I was of course hoping for another answer regarding performance, but now I know what to deal with.

        I'm using this approach to load data into a grid (Extjs). I now understand that loading 3000 rows (documents) into the
        grid is not the way to go due to processing/ loading time. I'll look into a paging/ buffering solution..

        Well, just out of curiosity, how is the underlying view processed ? If only viewName is specified, will only summary data be read ? Or, will it read the value from the underlying document ? What about the a search is performed ?

        Would it (theoretically) be possible to create a Custom REST Service which did the view processing quicker ?

        I remebered this blogpost regarding view processing (seems like the Notes.jar is the bottleneck here..) :
        http://www.mindoo.com/web/blog.nsf/dx/31.03.2010220936KLERN4.htm

         

        Regards,
        Petter Kjeilen

        • Implementation of viewItemFileService ...

          By Dave Delay 1 decade ago

          Since this is the extension library, most of the source code is available.  See the com.ibm.domino.services plugin -- in particular the com.ibm.domino.services.rest.das.view.RestViewNavigatorFactory class.  That class contains an inner class called NOINavigator that does most of the work for different types of queries (paging, search by key, FT search, etc).  You will see that NOINavigator uses the Java back-end classes (Notes.jar) to read view entries.

           

          Does viewItemFileService open individual documents?  No.  It just reads summary data.

           

          I haven't profiled the code, but it may be true that Notes.jar is the bottleneck.  That would certainly jive with the Mindoo blog posts.  In the long term, we will definitely have to investigate this.  Meanwhile, I hope you can live with a solution that defers loading some rows of data into your grid.

           

          Regards,

           

          -- Dave

          • RE; Implementation of viewItemFileService ...

            By Petter Kjeilen 1 decade ago

            Hi Dave,

            Thanks for the info !

            I also tested using readviewentries at view level and specifying outputformat=JSON

            E.g -> http:////lookupREST?readviewentries&count=3000&outputformat=JSON

            I now get data back in 3 seconds (half the time).. Great for just getting the data. Problem is that I also need
            to be able to sort + filter data on server side.

            Question : Can I combine search, sortColumn and sortOrder (all of them at the same time) on the REST service ? Can't get this working..

            Thanks again for your help !

            Regards,
            Petter
             

            • Some additional info...

              By Petter Kjeilen 1 decade ago

              Did you implement FTSearchSorted when performing a search on the view ? Especially if the sortColumn is specified this should be the case..

            • Yes and yes

              By Dave Delay 1 decade ago

              The viewItemFileService implementation supports combining search and sort parameters.  For example, I just tested these parameters and got back good results:

               

              search=aaron&sortcolumn=LastName&sortorder=descending

               

              Caveats are the db must be FT indexed, you must specify the sort column by programmatic name, and the view design must in fact have that column sorted.

               

              And, yes.  We use FTSearchSorted to do the work.

               

              -- Dave

              • Thanks !

                By Petter Kjeilen 1 decade ago

                Thanks !

              • RE: Implementation of viewItemFileService ...

                By Petter Kjeilen 1 decade ago

                Hi Dave,

                I can't seem to get the combination of search, sortColumn and sortOrder to work..

                If I only use sortColumn and sortOrder it works.

                If I only use search it works.

                If I use them all (search, sortColumn and sortOrder), I get the result from the search, but it's not sorted..
                I've tried with different columns (programmatic name) + both ascending and descending.

                I'm using the Extension Library that comes with Upgrade Pack 1. Could that be the case ?

                From which version of Extension Library is FTSearchSorted implemented ?

                 

                Thanks for your info !

                regards,
                Petter Kjeilen

                • Post UP1 ...

                  By Dave Delay 1 decade ago

                  Sorry about that.  We add the call to FTSearchSorted after 8.5.3 UP1.  It's been in OpenNTF builds since early 2012 though.

                   

                  -- Dave

                  • RE: Post UP1 ...

                    By Petter Kjeilen 1 decade ago

                    Thanks for your quick response Dave !

                    Ok, so I'm thinking, what are my options..

                    I could wait for UP2 (any info on when we can expect to see this ?), or I can write my own Custom REST service (if desired functionality is possible to accomplish) ? , or I can use the Domino Data Service (it's working when search, sortcolumn and sortorder are all in use, but returns JSON is a bit different way..) ?

                    Any suggestions ?  Smile

                    Everything is possible, it just takes a bit more time...

                    regards,
                    Petter Kjeilen

                     

                    • Can you use an OpenNTF release?

                      By Dave Delay 1 decade ago

                      We have no plans to release an 8.5.3 UP2.  RIght now we are concentrating on 9.0.  The fix you are looking for will be in 9.0, but waiting for 9.0 might not be a reasonable option.

                       

                      Please double check the data service.  It depends on the same code as the REST control with viewItemFileService.  In other words, there is one place where we added FTSearchSorted.  I wouldn't expect the data service to handle search and sortcolumn in UP1.

                       

                      If you can deploy a recent extlib release from OpenNTF, I think that would be the best solution.  You can stick with viewItemFileService and the combination of search and sortcolumn should work as expected.

                       

                      Thanks.

                       

                      -- Dave

                      • RE: Can you use an OpenNTF release?

                        By Petter Kjeilen 1 decade ago

                        Hi Dave,

                        You are ofcourse correct regarding REST and Domino Data Service (DAS ?) when it comes to searching (and sorting..) I was a bit to quick in my testing.. Doesn't work for Domino Data Service when using UP1.

                        As a developer I would like to use the latest and greatest, but this code is to be used in a production environment, and thus having a supported solution/ software is reauired by the admins..

                        For now the solution will be to have 1 server with OpenNTF version of ExtLib, and then replicate databases that require the latest and greatest code to this server. We're talking web client only, no xpinc..

                        That brings me to another issue.. Working with both OpenNTF version of ExtLib + UP1 version from the same instance of Domino Designer is not supported (to my knowledge..) This means I end up with running the OpenNTF dev environment in VMWare. Do you know if there are any best practices on developing for both versions ?

                        Lastly, could you please also add a @count or @searchcount (similar to @toplevelentries), which holds the count for the entries actually returned ?

                        Thanks !