I have a controller, when i render a twirl template and return it in my action. the play performance decrease about 5 time (15000 Requests per second in apache benchmark). but when i return json in this action play performance increase about 5 time (79000 Requests per second in apache benchmark). I have a very simple twirl template:
@(message: String)
@main("Welcome to Play") {
@message
}
Update: I find that when i use @routes.Assets.versioned instead of @routes.Assets.at to address assets this problem occurs.
<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
<script src="@routes.Assets.versioned("javascripts/hello.js")" type="text/javascript"></script>
There will be always difference between action returning raw data, and actions that need to parse and render some Twirl views view(s), additionally
versioned
asset checks the each file, so it adds additional jobs for whole process.Compare performance of two Twirl views, one with
versioned
method used other with manual adding the string, and consider how you can optimize your views.Also consider caching the Results where possible, it will for sure speed up the things.