Playframework Dev Mode: Never use in Production

Posted: March 5, 2011 in Play Framework
Tags: , ,

It may sound like an obvious point, but until recently the major reason I had for setting my applications to use PROD mode when I move my applications to a production environment, was so that my source code would not be visible in the event of a server side error. However, whilst looking through the source code today, I found a major compelling reason to never use Dev mode in a production environment.

First of all though, here a few things that Play does when you move into production mode that makes it a good idea to use the setting.

  • Play precompiles your source code for you, and does not check for code changes on the fly, adding a slight performance benefit
  • Play starts the application immediately (including any bootstrap jobs), rather than waiting for the first request, again adding a small performance benefit for first use
  • The 500 (server error) and 404 (page not found) pages do not show source code or your routes configuration, but instead show a standard error page
  • Runs more HTTP threads to handle incoming requests (unless specifically set in the application.conf). The exact value set is number of processors + 1

So all sounds pretty sensible, but not entirely critical. So, here is why it is critical.


Just like the @tests and @documentation URLs that can be used in Play, there is a largely unknown URL called @kill. As the name suggests, it simply performs a System.exit(0), which shuts down the Play server. The code first checks that the system is in Dev mode, and if it is, and the @kill request was received, the server is killed.

You will also get a nice output message printed to the logs @KILLED. Not exactly what you want your average user to be able to do on your shiny new application. Not that your average user will know that this feature exists, but it is better to be safe than sorry.

I assume that this facility has been made available, so that if you are running your application in a development set up, you can terminate the application remotely directly from the browser, without having to worry about accessing the server that it is running on. I can’t really think of any other good reasons why you would want to use this feature over simply terminating the command line or using the play stop command.

If you want to try it, just go to http://localhost:9000/@kill (assuming you have not changed your port, and you are running your play server locally in Dev mode).

So stick to PROD mode. Not only is it a better way to run your applications, it protects you from unwarranted server shut downs.

  1. Hi Wayne.
    You can export your project to war file and run it with Tomcat.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s