>although I was surprised about the reported execution times at that time

Yes my test was a bit harsh :-)
ab -n 100 -c 10  http://localhost:8984/bsp/simple
Is 100 requests as fast as possible with 10 concurrent. I also had nearly 2Mb of parser code in XQuery generated by REX [1] just in one app.

Thanks for the tips.
/Andy

[1] http://www.bottlecaps.de/rex/


On 7 May 2014 11:24, Christian Grün <christian.gruen@gmail.com> wrote:
> However one thing to be aware of with the current implementation is that
> response times depend on the quantity of XQuery code defined, making large
> applications problematic. This was mentioned in Christian's recent "Upcoming
> features" email, so I am sure it will be addressed soon.

I agree with Andy (although I was surprised about the reported
execution times at that time). In one of our projects, we now have
around 500 KB of XQuery code, and the constant overhead for evaluating
a single REST request is about 40 ms - which may be too slow if you
have lots of requests per seconds.

However, if you encounter bottlenecks, there are already various ways
to improve performance (all of them undocumented, I guess - once
again, Wiki edits are welcome..):

* Move all XQuery modules without RESTXQ annotations into your
repository ("repo" directory) [1]. This can be done manually (there is
no need to use the REPO commands), and you can edit XQuery modules
directly in your repo directory.

* Only keep those XQuery modules in your restxq directory which are
required in your project.

The reason is that the restxq directory is scanned for changes every
time a new request takes place. We think about introducing a RELEASE
mode in a future version, in which various checks will be skipped that
are required during the development stage.

Hope this helps,
Christian

[1] http://docs.basex.org/wiki/Repository




>> Hello Yoann,
>>
>> You do not "need to do so", but I remember your project quite well and I
>> was one of the people who said you don't actually need PHP. From what I
>> saw and remember, I think RestXQ is simply a much better fit.
>>
>> RestXQ enables you to do complete server-side processing (just like PHP
>> does) using XQuery. You can define all sorts of options for your
>> functions using annotations and how it should be served to your users.
>>
>> Theoretically, this would also be possible using Rest. However, the Rest
>> interface is more intended for short queries and querying on a data set.
>> You will always have to submit your query and of course this is very
>> impractical and slow if you develop a whole web app.
>> But it might be a good idea to add something to the documentation to
>> make the distinction between rest and RestXQ clearer. So much we could
>> add to the docs, actually... :)
>>
>> Cheers,
>> Dirk
>>
>> On 07/05/14 10:44, Yoann Maingon wrote:
>> > Thx
>> >
>> > I look into the provided example. At first I was more going into Rest
>> > and
>> > not RestXq, but if I need to do so then I guess I need to spend some
>> > time
>> > on it.
>> > Open sourcing our projects is a good question.
>> > I still have some colleagues affraid to somehow loose what they've
>> > developped and I don't have a clear opinion about it. But I'd be happy
>> > to
>> > share code (you may regret it! I'm a bad developper !)
>> >
>> >
>> > *Cordialement / Best Regards,*
>> >
>> > *Yoann Maingon*
>> > Minerva France
>> >
>> > *+33 6 64 32 49 66*
>> >
>> > Download Aras Innovator - Téléchargez Aras
>> > Innovator<http://www.aras.com/support/downloads/downloadInnovator.aspx>
>> >
>> >
>> >
>> >
>> > 2014-05-07 10:18 GMT+02:00 Dirk Kirsten <dk@basex.org>:
>> >
>> >> Hi,
>> >>
>> >> I agree with Max that it would be a good idea to have a list of
>> >> projects
>> >> and examples, which are build on top of BaseX. A problem might be that
>> >> many applications which are build on top of BaseX are not open source.
>> >>
>> >> @Yoann: Please be aware that there is a Rest and RestXQ implementation
>> >> within BaseX, which are quite different. What you most likely want to
>> >> use is RestXQ. Some documentation is available at
>> >> https://docs.basex.org/wiki/RESTXQ
>> >> Using RestXQ itself, there is an example for a blog at
>> >> https://github.com/siserle/blog-example
>> >>
>> >> As Max already suggested, the main difference when you use it with
>> >> angular or some other framework is that you most likely want to return
>> >> JSON, so you have to change the output method.
>> >>
>> >> Cheers,
>> >> Dirk
>> >>
>> >> On 07/05/14 09:34, Maximilian Gärber wrote:
>> >>> Hi Yoann,
>> >>>
>> >>> I guess having examples like these would be helpful in general.
>> >>> Together with basex, we built a larger project for managing conference
>> >>> registrations etc. last year. I could extract some of the modules -
>> >>> maybe we could manage to publish them on some github repo or a
>> >>> dedicated site? @basex: maybe it is time for a basex contrib page?
>> >>>
>> >>> What you need, is some json endpoint which leverages the session
>> >>> module, checks the credentials and returns some json back to Angular
>> >>> (or JQuey)
>> >>>
>> >>> Besides that, you need to secure all your restxq endpoints with a
>> >>> authentication check:
>> >>>
>> >>>    if(not(session:logged-in())) then web:redirect($C:START-PAGE) else
>> >>> _:do-something-useful()
>> >>>
>> >>>
>> >>> Login example:
>> >>>
>> >>>
>> >>> import module namespace session =
>> >>> "http://basex.org/modules/web/session
>> >> ";
>> >>>
>> >>> declare
>> >>>   %restxq:path("/api/login/check")
>> >>>   %restxq:POST("{$content}")
>> >>>   %output:method("json")
>> >>>   %output:json("lax=yes")
>> >>>   function _:check(
>> >>>     $content as item()*
>> >>>   )
>> >>> {
>> >>>   let $user := $content//u/string()
>> >>>   let $pass := $content//p/string()
>> >>>
>> >>>   let $ok := _:check-user($user, $pass)
>> >>>
>> >>>     if ($ok) then
>> >>>       let $user-id := session:id()
>> >>>       let $role    := session:role()
>> >>>       return((),
>> >>>       <json objects="json">
>> >>>           <url>{_:redirect-url-from-role($role)}</url>
>> >>>         </json>
>> >>>        )
>> >>>    else
>> >>>        <json objects="json">
>> >>>         <error>Login failed.</error>
>> >>>       </json>
>> >>> };
>> >>>
>> >>>
>> >>> angular.module('login', [])
>> >>>   .config([
>> >>>       '$routeProvider',
>> >>>       function ($routeProvider) {
>> >>>         $routeProvider.when('/Logout', {
>> >>>           redirectTo: '/restxq/logout'
>> >>>         });
>> >>>     }])
>> >>>
>> >>>   .controller('LoginCtrl', [
>> >>>     '$scope', '$http', '$location',
>> >>>     function ($scope, $http, $location) {
>> >>>       $scope.login = function() {
>> >>>         var url = '/restxq/api/login/check';
>> >>>
>> >>>        //use jquery here, because angular does not detect auto-fill
>> >>> data
>> >>>         var payload = {
>> >>>           u: $('#u').val(),
>> >>>           p: $('#p').val()
>> >>>         };
>> >>>
>> >>>         $http.post(url, payload).
>> >>>         success(function(data) {
>> >>>           if (data.error) {
>> >>>           // trigger error status
>> >>>             $scope.loginForm.$error.failed = true;
>> >>>           } else {
>> >>>           // redirect
>> >>>             window.location.pathname = data.url;
>> >>>           }
>> >>>         }).
>> >>>         error(function(data, status, headers, config) {
>> >>>           alert("Could not load data from server.")
>> >>>         });
>> >>>       };
>> >>>   }]);
>> >>>
>> >>>  <div class="row" ng-controller="LoginCtrl">
>> >>>     <div class="span6 offset3">
>> >>>     <h2 class="alumni-name">Please Login</h2>
>> >>>
>> >>>       <div class="alert alert-error"
>> >>> ng-show="loginForm.$error.failed">
>> >>>         <p>
>> >>>           Incorrect login data. Please try again.
>> >>>         </p>
>> >>>       </div>
>> >>>       <form name="loginForm">
>> >>>         <table cellpadding="3">
>> >>>           <tr>
>> >>>             <td>Username&#160; </td>
>> >>>             <td><input type="text" name="u" id="u" ng-model="user"
>> >>> style="width:146px !important;margin:0"/></td>
>> >>>           </tr>
>> >>>           <tr>
>> >>>             <td>Password &#160; </td>
>> >>>             <td><input id="p" name="p" ng-model="password"
>> >>> style="width:146px !important;margin:0" type="password" /></td>
>> >>>           </tr>
>> >>>           <tr>
>> >>>             <td/>
>> >>>             <td><button ng-click="login()" class="btn"
>> >>> style="width:152px !important;margin:0">Login</button>
>> >>>             </td>
>> >>>           </tr>
>> >>>         </table>
>> >>>
>> >>>       </form>
>> >>>     </div>
>> >>>     </div>
>> >>>
>> >>>  Regards,
>> >>>
>> >>> Max
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> 2014-05-07 1:38 GMT+02:00 Yoann Maingon
>> >>> <yoann.maingon@mydatalinx.com>:
>> >>>> Hi,
>> >>>>
>> >>>> After xmlprague and my presentation at the BaseX user group I was
>> >>>> told
>> >> (and
>> >>>> I agree) that it wasn't really smart to use php for what I was
>> >>>> building
>> >> as
>> >>>> it had almost no added value as I could directly query basex using
>> >>>> the
>> >> Rest
>> >>>> Interface.
>> >>>>
>> >>>> Does anyone as some example using either angularjs or jquery ? I
>> >>>> think
>> >> I'm
>> >>>> struggling with the login. Even just trying with a Rest test tool, I
>> >> can see
>> >>>> that I have error messages in Basex telling me theat access was
>> >>>> refused.
>> >>>>
>> >>>>
>> >>>> Yoann Maingon
>> >>>> CEO - mydatalinx
>> >>>> +33664324966
>> >>
>> >> --
>> >> Dirk Kirsten, BaseX GmbH, http://basex.org
>> >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
>> >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
>> >> |   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
>> >> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
>> >>
>> >
>>
>> --
>> Dirk Kirsten, BaseX GmbH, http://basex.org
>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
>> |   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
>> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
>
>