Posts Tagged ‘routing’
Disable Gaelyk reloading routes on every Request in DEV mode
I’m working on a little client/server app with C# WPF 4.5 as frontend and Gaelyk on Google App Engine (GAE) as server backend. While testing the load of my app on development server, I discovered a high single core load on my server and a very bad response time once the requests per second was higher than around 10.
After some testing hours I found that Gaelyk reloades the routes.config file on every request to check for changes as I didn’t have timestamps on my filesystem or I did not start with admin rights. Anyway instead of checking if the file has changed, the RoutesFilter always creates a new GroovyShell and runs the routes.config as script, thus compiling it which in turn resulted in a high single core load and a bad request time. As you can imagine constant recompiling stresses the server and I observed a delay of 150ms per request just for reevaluating the routes.config file on every request. Wow, that sums up quickly.
Well, in production mode this will not be done and on deveploment mode this is normaly not a problem but in my case I have many users that query the server once a second and the check for file modification is not working.
But as I do not change the routes often (and if I will just have to restart Gaelyk) I looked around how to disable this behaviour and discovered you can configure your own route filter in web.xml
<!-- Use custom routes filter to disable reloading of routes.config for every request for development server --> <filter> <filter-name>RoutesFilter</filter-name> <filter-class>utils.NoReloadRoutesFilter</filter-class> </filter>
Then just extend the RouteFilter class:
package utils import groovyx.gaelyk.routes.RoutesFilter; class NoReloadRoutesFilter extends RoutesFilter { private boolean init = false @Override synchronized void loadRoutes() { if (!init) { init = true super.loadRoutes() } } }
That’s it. It may be an uncommen problem but it was a problem for me 🙂
Greetings,
GHad