Ratpack case uses

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Ratpack case uses

Roger
Hi,

I was just wondering whether Ratpack could be used to build a full blown restful API service. Is it asking to much from it? Most presentations and blogs I have seen about ratpack seem to mention that it is mostly useful to build really small web services. Has any major big players in the industry been using ratpack to build large web applications. Is Ratpack not mature enough compared to others such as Scalatra or spray akka? Just feels that using Grails to build a restful web service is a bit of an overkill. Will be grateful to get any feedback on experiences on using Ratpack for large web applications.

Thanks

Roger
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

Luke Daley
Administrator
Hi Roger,

The intention is that Ratpack can be used for serious API servers, but there aren't any examples out there to look at for this. Ratpack doesn't place many restrictions on how you write your app to avoid the problems you experience with conventional frameworks once your app expands and matures. However, this means that keeping this clean and organised is more your responsibility instead of the frameworks.

Ratpack is definitely not as mature as Scalatra or Spray Akka. I wouldn't encourage building mission critical systems on Ratpack right now. Ratpack is built on a very mature stack (Netty and Guice), but its API is still in flux.

Whether or not you should use Ratpack is hard to say. It depends on a few different factors.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

dylanmei
What kind of suggestions do you have regarding tuning Ratpack for performance?

I'm not sure where one can tinker. The documentation on the bootstrapping page seems to suggest I can do this but it I get MissingMethodException.

ratpack {

    handlers {
        get {
            render "hello groovy"
        }
    }

    launchConfig {
        mainThreads Runtime.getRuntime().availableProcessors() * 10
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

Luke Daley
Administrator
Those docs are a bit misleading unfortunately.

How are you running your app? Is it via Gradle? or a standalone script?

Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

dylanmei
I am running example-ratpack-gradle-groovy-app in EC2 (not heroku). I added a get handler that goes to a third-party service and renders the results. On first glance it appears slower than a comparable Node.js application that does the same thing.

Outside of JAVA_OPTS I'd like to know how to tune ratpack/netty to get the most out of our particular application.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

Luke Daley
Administrator
Is this third party service request blocking?
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

dylanmei
Aha okay, of course. I don't get anything for free, do I? I'm getting the kinds of results I was after with the changes, below.

I'm still left wondering how to interact with LaunchConfig from groovy.

import ratpack.example.services.*
import static ratpack.groovy.Groovy.*

ratpack {
    modules {
        register new ServiceModule()
    }

    handlers {
        get {
            render "hello ratpack"
        }

        get("token") { TokenService tokenService ->
//            def token = tokenService.getToken()
//            render groovyTemplate("token.html", token: token.value)
            exec getBlocking(),
                { tokenService.getToken() },
                { render groovyTemplate("token.html", token: it.value) }
        }
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

Luke Daley
Administrator
So is it still slower than expected?

LaunchConfig can't be changed from the Groovy code because that's after launch. You can either control it via system properties, or via a ratpack.properties file on the classpath.

The sysprops available are here: http://www.ratpack.io/manual/current/api/ratpack/launch/LaunchConfigFactory.Property.html

If you're running the app via ./gradlew run then it will be in reload mode and will be slower.

On 12 Nov 2013, at 4:43 pm, dylanmei [via Ratpack Forum] <[hidden email]> wrote:

> Aha okay, of course. I don't get anything for free, do I? I'm getting the kinds of results I was after with the changes, below.
>
> I'm still left wondering how to interact with LaunchConfig from groovy.
>
> import ratpack.example.services.*
> import static ratpack.groovy.Groovy.*
>
> ratpack {
>     modules {
>         register new ServiceModule()
>     }
>
>     handlers {
>         get {
>             render "hello ratpack"
>         }
>
>         get("token") { TokenService tokenService ->
> //            def token = tokenService.getToken()
> //            render groovyTemplate("token.html", token: token.value)
>             exec getBlocking(),
>                 { tokenService.getToken() },
>                 { render groovyTemplate("token.html", token: it.value) }
>         }
>     }
> }
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://forum.ratpack.io/Ratpack-case-uses-tp224p236.html
> To start a new topic under Ratpack Forum, email [hidden email]
> To unsubscribe from Ratpack Forum, click here.
> NAML

--

Luke Daley.

Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

dylanmei
Ok great, thanks for that tip!

We did much better with the exe getBlocking() changes, requests went from ~20/sec to ~55/sec which given the nature of the third-party service we are hitting is about right.

I see you've just been adding blocking { ... }.then  { ... } which will work great for me! (And looking at is helping me find my way around the code.)  Looking forward to the next release.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpack case uses

Luke Daley
Administrator
Great!

There are some minor optimizations still to make internally, but we don't add too much on top of Netty which is very fast. My benching (while non exhaustive) has been good.

BTW, the new version of blocking/then is now available. The dependency group has changed to ratpack.io (you'll need to update your build.gradle).

There are still heavy API changes going on at this point, but this will settle down soon.