ANN: Async blog post

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ANN: Async blog post

Graeme Rocher
Administrator
I wrote a blog post about the upcoming async features for those interested


Cheers

--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

omayka
Hello Graeme,

I am trying out the new async feature and my controller aciton looks like:

def async_action_without_wait() {
        Promise p1 = task {
            execp1()
            log.info("p1 done")
            2 * 2
        }
        Promise p2 = task {
            execp1()
            log.info("p2 done")
            4 * 4
        }
        Promise p3 = task {
            execp1()
            log.info("p3 done")
            8 * 8
        }
        onComplete([p1, p2, p3]) { List result ->
            log.info("waitAll done")
            render "p1: ${result[0]}, p2: ${result[1]}, p3: ${result[2]}"
        }

    }

so what I want to do is :
run 3 tasks in parallel
after the result is there: render the result composition

unfortunatelly if I run this code on tomcat 7.0.50, then some requests returns with error 500 and it is reproducable, but some requests do not. This does not happen any more if I replace onComplete by waitAll, but then the request is not non-blocking any more.

Can you explain please how to render a composition of async tasks properly?

Many thx!

PS: my full experiment is located here: https://github.com/omayevskiy/async_grails_experiment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

Graeme Rocher-2
What is the exception?


On Wed, Jan 15, 2014 at 4:44 PM, omayka <[hidden email]> wrote:
Hello Graeme,

I am trying out the new async feature and my controller aciton looks like:

def async_action_without_wait() {
        Promise p1 = task {
            execp1()
            log.info("p1 done")
            2 * 2
        }
        Promise p2 = task {
            execp1()
            log.info("p2 done")
            4 * 4
        }
        Promise p3 = task {
            execp1()
            log.info("p3 done")
            8 * 8
        }
        onComplete([p1, p2, p3]) { List result ->
            log.info("waitAll done")
            render "p1: ${result[0]}, p2: ${result[1]}, p3: ${result[2]}"
        }

    }

so what I want to do is :
run 3 tasks in parallel
after the result is there: render the result composition

unfortunatelly if I run this code on tomcat 7.0.50, then some requests
returns with error 500 and it is reproducable, but some requests do not.
This does not happen any more if I replace onComplete by waitAll, but then
the request is not non-blocking any more.

Can you explain please how to render a composition of async tasks properly?

Many thx!

PS: my full experiment is located here:
https://github.com/omayevskiy/async_grails_experiment



--
View this message in context: http://grails.1312388.n4.nabble.com/ANN-Async-blog-post-tp4642701p4653318.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Graeme Rocher
Grails Project Lead
SpringSource
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

omayka
2014-01-15 19:15:42,273 [Actor Thread 9] ERROR gpars.LoggingPoolFactory  
- Async execution error: No thread-bound request found: Are you
referring to request attributes outside of an actual web request, or
processing a request outside of the originally receiving thread? If you
are actually operating within a web request and still receive this
message, your code is probably running outside of
DispatcherServlet/DispatcherPortlet: In this case, use
RequestContextListener or RequestContextFilter to expose the current
request.
Message: No thread-bound request found: Are you referring to request
attributes outside of an actual web request, or processing a request
outside of the originally receiving thread? If you are actually
operating within a web request and still receive this message, your code
is probably running outside of DispatcherServlet/DispatcherPortlet: In
this case, use RequestContextListener or RequestContextFilter to expose
the current request.
     Line | Method
->>  102 | doCall       in
eval.AsyncController$_async_action_without_wait_closure5
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    746 | whenAllBound in groovyx.gpars.group.PGroup
|     58 | access$000 . in     ''
|    757 | doRun        in groovyx.gpars.group.PGroup$6
|     66 | call . . . . in groovyx.gpars.MessagingRunnable
|     60 | doRun        in groovyx.gpars.dataflow.impl.ThenMessagingRunnable
|     66 | call . . . . in groovyx.gpars.MessagingRunnable
|     62 | run          in groovyx.gpars.dataflow.DataCallback$1
|   1110 | runWorker .  in java.util.concurrent.ThreadPoolExecutor
|    603 | run          in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . .  in java.lang.Thread
Error |

Am 15.01.2014 18:52, schrieb Graeme Rocher-2 [via Grails]:
> What is the exception?
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

omayka
One more thing:
sometime but very rarely I get the result of render twice
then it looks like:


p1: 4, p2: 16, p3: 64p1: 4, p2: 16, p3: 64

instead of just

p1: 4, p2: 16, p3: 64
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

Owen Rubel
In reply to this post by omayka
Hey Grame, thanks for the post. I'm more interested in making these work with CommanObjects for more complex objects. I'm not always building and returning simple objects which match the tables perfectly. I'm going to have to do joins across tables or even across databases and use that returned data.

Keys from RDBMS's and NOSQL systems will be joining data together and i want to be able to use CommandObjects to do validation. Is there a way I can use Gpars or something on those?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

omayka
In reply to this post by Graeme Rocher-2
On 15.01.2014 18:52, Graeme Rocher-2 [via Grails] wrote:
What is the exception?


Today I also ran a couple of gatling tests agains grails + tomcat nio connector

my very basic async action looks like:
def async_index() {
    task {
      render('Your new application is ready.')
    }
  }


STATISTICS
Requests
Executions
Response Time (ms)
Total OK KO % KO Min Max Mean Std Dev 95th pct 99th pct Req/s
 Global Information
593501 593453 48 0 %
0 540 2 12 10 20 9888
 async_index
593501 593453 48 0 %
0 540 2 12 10 20 9888

The performance is good, but the not successful responses are not good. Running same test agains a sync_index (without task) do not produce such errors.

The catalina.out says:
[Actor Thread 2598] ERROR gpars.LoggingPoolFactory  - Async execution error: null
java.lang.NullPointerException

It seems to be some trouble with gpars.

additional my gatling simulation:

class GrailsSimulation extends Simulation {

    val grailsTest = scenario("Async grails experiment").during(1 minutes) {
        exec(http("async_index").get("/async_grails_experiment-0.1/async/async_index"))
    } inject(atOnce(100 users))

    setUp(grailsTest)
       .protocols(http.baseURL("http://localhost:8765"))

}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

omayka
In reply to this post by Graeme Rocher-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

Graeme Rocher-2
Seems worthy of a JIRA issue with steps to reproduce


On Thu, Jan 16, 2014 at 12:33 PM, omayka <[hidden email]> wrote:
propably my problem is related to:
http://grails.1312388.n4.nabble.com/WebRequestPromiseDecorator-and-long-running-tasks-td4651540.html

View this message in context: Re: ANN: Async blog post
Sent from the Grails - user mailing list archive at Nabble.com.



--
Graeme Rocher
Grails Project Lead
SpringSource
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ANN: Async blog post

omayka
Thx! Would be cool to see this working.

On 16.01.2014 13:52, Graeme Rocher-2 [via Grails] wrote:
Seems worthy of a JIRA issue with steps to reproduce


On Thu, Jan 16, 2014 at 12:33 PM, omayka <[hidden email]> wrote:
propably my problem is related to:
http://grails.1312388.n4.nabble.com/WebRequestPromiseDecorator-and-long-running-tasks-td4651540.html

View this message in context: Re: ANN: Async blog post
Sent from the Grails - user mailing list archive at Nabble.com.



--
Graeme Rocher
Grails Project Lead
SpringSource



If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/ANN-Async-blog-post-tp4642701p4653349.html
To unsubscribe from ANN: Async blog post, click here.
NAML

Loading...