Edge Caching With Play 2, Heroku, and CloudFront

Web applications are primarily comprised of data, services, and the User Interface (UI). The UI is comprised of HTML, CSS, images, and probably JavaScript. In the traditional web architecture all of the UI assets are static files except the HTML which is dynamically generated by the server. In the modern web architecture the entire UI is static files that consume RESTful / JSON services. The static files for the UI must be downloaded to the client so the less time it takes for them to be downloaded, the better the overall performance of the application.

The Magic Behind Heroku’s “git push” Deployment

In my spare time I help out with a little app called [Greg’s Toolkit][1] that was built before I knew about Heroku. The app runs on EC2 and deploying new versions of the app is pretty tedious. Here is the deployment instructions copied directly from the project’s wiki:

./gradlew war
scp  ./gft_server/build/libs/gft_server.war api.gregstoolkit.com:
ssh api.gregstoolkit.com
cd /opt/apache-tomcat-7.0.21
sudo -u www-data bin/shutdown.sh
cd webapps/ROOT
sudo rm -r *
sudo -u www-data jar -xvf ~/gft_server.war
sudo -u www-data sed -i 's/dev/prod/' WEB-INF/web.xml
cd ../..
sudo -u www-data bin/startup.sh

That certainly isn’t as cumbersome as some deployment methods but it is time consuming, error-prone, and causes downtime.

Client/Server Apps with HTML5 & Java at OSCON 2012

This Friday at OSCON 2012 I’ll be doing a presentation about Client/Server Apps with HTML5 and Java. Here is the session description:

The web application landscape is rapidly shifting back to a Client/Server architecture. This time around the Client is JavaScript, HTML, and CSS in the browser. The tools and deployment techniques for these types of applications are abundant and fragmented. This session will teach you how to pull together jQuery, LESS, Twitter Bootstrap, and some CoffeeScript to build the Client. The Server could be anything that talks HTTP but this session will use the Play Framework. You will also learn how to deploy Client/Server web apps on the cloud using a Content Delivery Network (Amazon CloudFront) for the Client and a Cloud Application Provider (Heroku) for the Server.

Getting Started with Play 2, Scala, and Squeryl

My friend Ryan Knight and I co-authored an article which has just been published on Artima: Getting Started with Play 2, Scala, and Squeryl. This article will help you get started building a Play 2 application from scratch that uses Scala and Squeryl for ORM. The article also covers how use ScalaTest, JSON, jQuery, CoffeeScript, and deployment on Heroku. Give it a try and let me know how it goes!

Optimizing Play 2 for Database-Driven Apps

Update: There is now a detailed doc in Play’s documentation about configuring Play’s thread pools.

Last week Matt Raible and I presented the Play vs. Grails Smackdown at ÜberConf. The goal of the session was to compare Play 2 + Java with Grails by creating the same app with each framework. We used a number of criteria for the comparison including some benchmarks. You can read more about the results in Matt’s session recap blog. After presenting the results we learned that it’s pretty important to optimize Play 2’s Akka threading system in these types of applications. Play 2 is optimized out-of-the-box for HTTP requests which don’t contain blocking calls (i.e. asynchronous). Most database-driven apps in Java use synchronous calls via JDBC so Play 2 needs a bit of extra configuration to tune Akka for these types of requests.